/* ============================================================
   Aidacare MS-GP BAU Knowledge Portal — Main Stylesheet
   ============================================================ */

:root {
  --navy:        #0f2d52;
  --navy-dark:   #091e38;
  --navy-mid:    #163a6a;
  --blue:        #1a56db;
  --blue-lt:     #2563eb;
  --blue-pale:   #dbeafe;
  --teal:        #0891b2;
  --teal-lt:     #e0f2fe;
  --violet:      #6d28d9;
  --violet-lt:   #ede9fe;
  --amber:       #b45309;
  --amber-lt:    #fef3c7;
  --green:       #065f46;
  --green-lt:    #d1fae5;
  --red:         #b91c1c;
  --red-lt:      #fee2e2;
  --orange:      #c2410c;
  --orange-lt:   #ffedd5;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-400:    #9ca3af;
  --gray-500:    #6b7280;
  --gray-600:    #4b5563;
  --gray-700:    #374151;
  --gray-800:    #1f2937;
  --gray-900:    #111827;
  --white:       #ffffff;
  --sidebar-w:   260px;
  --topbar-h:    60px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.14);
  --transition:  0.18s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--gray-50); color: var(--gray-800); line-height: 1.6; min-height: 100vh; }
a { color: var(--blue-lt); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ---- Layout ---- */
.app-shell { display: flex; min-height: 100vh; }

/* ---- Topbar ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 100;
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; box-shadow: var(--shadow);
}
.topbar-brand { display: flex; align-items: center; gap: .75rem; }
.topbar-brand img { height: 34px; width: auto; }
.topbar-brand .brand-text { font-size: .95rem; font-weight: 700; letter-spacing: .01em; color: var(--white); }
.topbar-brand .brand-sub { font-size: .7rem; color: rgba(255,255,255,.65); font-weight: 400; display: block; line-height: 1.2; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-search { position: relative; }
.topbar-search input {
  width: 260px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  color: var(--white); border-radius: 20px; padding: .4rem 1rem .4rem 2.2rem;
  font-size: .85rem; outline: none; transition: var(--transition);
}
.topbar-search input::placeholder { color: rgba(255,255,255,.55); }
.topbar-search input:focus { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.4); }
.topbar-search .search-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); opacity: .6; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.1);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--white); transition: var(--transition); font-size: .85rem;
}
.topbar-btn:hover { background: rgba(255,255,255,.2); }
#sidebar-toggle { display: none; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w); background: var(--navy-dark);
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  overflow-y: auto; z-index: 90;
  transition: transform var(--transition);
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.sidebar-section { padding: .75rem .75rem .25rem; }
.sidebar-section-label {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: rgba(255,255,255,.35);
  padding: 0 .5rem .35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem;
  border-radius: var(--radius); color: rgba(255,255,255,.72);
  font-size: .82rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border: none; background: none; width: 100%; text-align: left;
  text-decoration: none;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: var(--white); text-decoration: none; }
.sidebar-link.active { background: var(--blue-lt); color: var(--white); }
.sidebar-link .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .75; }
.sidebar-link.active .nav-icon { opacity: 1; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.07); margin: .5rem .75rem; }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  flex: 1;
  min-height: 100vh;
}
.page-container { padding: 2rem; max-width: 1400px; }

/* ---- Page Header ---- */
.page-header { margin-bottom: 2rem; }
.page-header .breadcrumb { font-size: .78rem; color: var(--gray-500); margin-bottom: .5rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.page-header .breadcrumb a { color: var(--blue-lt); }
.page-header h1 { font-size: 1.65rem; font-weight: 700; color: var(--gray-900); line-height: 1.25; }
.page-header p { color: var(--gray-600); font-size: .9rem; margin-top: .35rem; max-width: 700px; }
.page-header .header-meta { display: flex; gap: 1rem; margin-top: .75rem; flex-wrap: wrap; }
.page-header .header-meta .meta-item { font-size: .75rem; color: var(--gray-500); display: flex; align-items: center; gap: .3rem; }

/* ---- Cards ---- */
.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
}
.card-header h2, .card-header h3 {
  font-size: .95rem; font-weight: 600; color: var(--gray-900);
}
.card-body { padding: 1.25rem; }
.card-footer { padding: .85rem 1.25rem; background: var(--gray-50); border-top: 1px solid var(--gray-100); }

/* ---- Stat Cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: .5rem;
}
.stat-card .stat-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-sub { font-size: .78rem; color: var(--gray-500); }
.stat-card .stat-icon { width: 36px; height: 36px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: .25rem; }
.stat-blue .stat-value { color: var(--blue-lt); } .stat-blue .stat-icon { background: var(--blue-pale); color: var(--blue-lt); }
.stat-teal .stat-value { color: var(--teal); } .stat-teal .stat-icon { background: var(--teal-lt); color: var(--teal); }
.stat-violet .stat-value { color: var(--violet); } .stat-violet .stat-icon { background: var(--violet-lt); color: var(--violet); }
.stat-green .stat-value { color: var(--green); } .stat-green .stat-icon { background: var(--green-lt); color: var(--green); }
.stat-amber .stat-value { color: var(--amber); } .stat-amber .stat-icon { background: var(--amber-lt); color: var(--amber); }
.stat-red .stat-value { color: var(--red); } .stat-red .stat-icon { background: var(--red-lt); color: var(--red); }

/* ---- Badges / Pills ---- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 600; padding: .2rem .6rem; border-radius: 20px;
}
.badge-blue { background: var(--blue-pale); color: var(--navy); }
.badge-teal { background: var(--teal-lt); color: var(--teal); }
.badge-green { background: var(--green-lt); color: var(--green); }
.badge-amber { background: var(--amber-lt); color: var(--amber); }
.badge-red { background: var(--red-lt); color: var(--red); }
.badge-violet { background: var(--violet-lt); color: var(--violet); }
.badge-orange { background: var(--orange-lt); color: var(--orange); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { background: var(--gray-50); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); padding: .6rem 1rem; text-align: left; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: top; color: var(--gray-700); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ---- Grid layouts ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }

/* ---- Nav cards (clickable module/system tiles) ---- */
.nav-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: var(--transition); text-decoration: none; color: inherit;
  display: block;
}
.nav-card:hover { border-color: var(--blue-lt); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; color: inherit; }
.nav-card .nc-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: .85rem; font-size: 1.3rem; }
.nav-card h3 { font-size: .9rem; font-weight: 600; color: var(--gray-900); margin-bottom: .3rem; }
.nav-card p { font-size: .78rem; color: var(--gray-500); line-height: 1.45; }
.nav-card .nc-footer { margin-top: .75rem; display: flex; align-items: center; justify-content: space-between; }

/* ---- Section headers ---- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.section-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.section-header p { font-size: .82rem; color: var(--gray-500); }

/* ---- Alert / info boxes ---- */
.alert { border-radius: var(--radius); padding: .85rem 1rem; font-size: .85rem; display: flex; gap: .7rem; align-items: flex-start; margin-bottom: 1rem; }
.alert-icon { flex-shrink: 0; margin-top: .1rem; }
.alert-info { background: var(--blue-pale); color: var(--navy); border-left: 3px solid var(--blue-lt); }
.alert-warn { background: var(--amber-lt); color: #78350f; border-left: 3px solid var(--amber); }
.alert-danger { background: var(--red-lt); color: var(--red); border-left: 3px solid var(--red); }
.alert-success { background: var(--green-lt); color: var(--green); border-left: 3px solid #10b981; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--gray-200); margin-bottom: 1.5rem; overflow-x: auto; }
.tab-btn {
  padding: .65rem 1.1rem; font-size: .83rem; font-weight: 600;
  color: var(--gray-500); border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: var(--transition);
}
.tab-btn:hover { color: var(--gray-800); }
.tab-btn.active { color: var(--blue-lt); border-bottom-color: var(--blue-lt); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Accordion ---- */
.accordion-item { border: 1px solid var(--gray-200); border-radius: var(--radius); margin-bottom: .5rem; overflow: hidden; }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; cursor: pointer; background: var(--white);
  font-size: .88rem; font-weight: 600; color: var(--gray-800);
  transition: var(--transition);
}
.accordion-header:hover { background: var(--gray-50); }
.accordion-header .acc-icon { transition: transform .2s; flex-shrink: 0; }
.accordion-item.open .accordion-header .acc-icon { transform: rotate(180deg); }
.accordion-body { display: none; padding: 1rem 1.1rem; background: var(--gray-50); border-top: 1px solid var(--gray-200); font-size: .85rem; color: var(--gray-700); }
.accordion-item.open .accordion-body { display: block; }

/* ---- Search results overlay ---- */
#search-overlay {
  display: none; position: fixed; top: var(--topbar-h); left: var(--sidebar-w); right: 0;
  z-index: 200; background: rgba(0,0,0,.4); padding: 1.5rem;
}
#search-results-box {
  background: var(--white); border-radius: var(--radius-lg);
  max-width: 700px; max-height: 70vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); padding: 1.25rem;
}
.search-result-item { padding: .85rem 0; border-bottom: 1px solid var(--gray-100); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item h4 { font-size: .88rem; font-weight: 600; color: var(--blue-lt); margin-bottom: .2rem; }
.search-result-item p { font-size: .78rem; color: var(--gray-500); }
.search-result-item .badge { margin-top: .3rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; font-size: .85rem; font-weight: 600;
  border-radius: var(--radius); border: none; cursor: pointer;
  transition: var(--transition); white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--blue-lt); color: var(--white); }
.btn-primary:hover { background: var(--blue); color: var(--white); text-decoration: none; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); color: var(--gray-800); text-decoration: none; }
.btn-outline { background: none; color: var(--blue-lt); border: 1.5px solid var(--blue-lt); }
.btn-outline:hover { background: var(--blue-pale); text-decoration: none; }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ---- Misc utilities ---- */
.text-muted { color: var(--gray-500); }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .73rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.tbd { color: var(--amber); font-style: italic; font-size: .8rem; }
.source-tag { font-size: .68rem; color: var(--gray-400); font-style: italic; }

/* ---- Process flow ---- */
.process-flow { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.pf-step { background: var(--blue-pale); border: 1px solid var(--blue-lt); border-radius: var(--radius); padding: .5rem .85rem; font-size: .8rem; font-weight: 600; color: var(--navy); white-space: nowrap; }
.pf-arrow { color: var(--gray-400); font-size: 1rem; }

/* ---- Detail list ---- */
.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: .6rem 1rem; font-size: .85rem; }
.detail-list .dl-label { color: var(--gray-500); font-weight: 600; }
.detail-list .dl-value { color: var(--gray-800); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  #search-overlay { left: 0; }
  #sidebar-toggle { display: flex !important; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .page-container { padding: 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list .dl-label { margin-bottom: -.2rem; }
}

/* ---- Login page ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-mid) 60%, var(--teal) 100%); padding: 2rem; }
.login-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; overflow: hidden; }
.login-header { background: var(--navy); padding: 2rem; text-align: center; }
.login-header img { height: 48px; margin: 0 auto 1rem; }
.login-header h1 { color: var(--white); font-size: 1.1rem; font-weight: 700; }
.login-header p { color: rgba(255,255,255,.6); font-size: .8rem; margin-top: .3rem; }
.login-body { padding: 2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--gray-700); margin-bottom: .4rem; }
.form-input {
  width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); font-size: .9rem; color: var(--gray-800);
  outline: none; transition: var(--transition); background: var(--white);
}
.form-input:focus { border-color: var(--blue-lt); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-footer { background: var(--gray-50); padding: 1rem 2rem; border-top: 1px solid var(--gray-100); text-align: center; font-size: .73rem; color: var(--gray-400); }
.error-msg { background: var(--red-lt); color: var(--red); border-radius: var(--radius); padding: .6rem .9rem; font-size: .82rem; margin-bottom: 1rem; display: none; }
.error-msg.show { display: block; }
