/* ============================================================
   NAVTTC M&E Dashboard - Theme & Layout
   ============================================================ */
:root {
  --navy: #15803d;
  --navy-2: #1f9d52;
  --green: #16864a;
  --gold: #d4a017;
  --sidebar-w: 264px;
  --card-radius: 14px;
  --shadow: 0 6px 24px rgba(13, 38, 76, .08);
  --bs-primary: #15803d;
}
[data-bs-theme="dark"] {
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --card-bg: #161c2b;
}

* { box-sizing: border-box; }
body {
  background: #e8f5ee;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  margin: 0;
}
[data-bs-theme="dark"] body { background: #0d1117; color: #d7dde8; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, #0b4a26 100%);
  color: #dfe6f5; display: flex; flex-direction: column; z-index: 1040;
  box-shadow: 2px 0 20px rgba(0,0,0,.15);
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 10px; background: var(--gold);
  color: #0b4a26; font-weight: 800; font-size: 22px; display: grid; place-items: center;
}
.brand-name { font-weight: 800; letter-spacing: 1px; font-size: 18px; }
.brand-sub { font-size: 11px; opacity: .7; letter-spacing: 2px; }

.inst-card {
  margin: 8px 14px 14px; padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
}
.inst-card .fw-semibold { color: #fff; }

.nav-menu { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-menu::-webkit-scrollbar { width: 6px; }
.nav-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 6px; }
.nav-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,.45); padding: 14px 12px 6px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 9px; color: #cdd8ee; text-decoration: none; font-size: 14px; margin-bottom: 2px;
  transition: all .15s ease;
}
.nav-link i { font-size: 17px; width: 20px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: var(--gold); color: #0b4a26; font-weight: 600; box-shadow: 0 4px 12px rgba(212,160,23,.4); }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1); }

.sidebar-backdrop { display: none; }

/* Topbar */
.topbar {
  background: var(--bs-body-bg); border-bottom: 1px solid rgba(0,0,0,.06);
  padding: 8px 16px; backdrop-filter: blur(6px);
}
[data-bs-theme="dark"] .topbar { border-bottom-color: rgba(255,255,255,.07); }
.nav-av { color: var(--bs-body-color); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--navy-2);
  color: #fff; display: grid; place-items: center; font-weight: 700;
}
.theme-toggle { border-radius: 50%; width: 36px; height: 36px; padding: 0; }
.inst-select { max-width: 220px; cursor: pointer; }

/* Global search */
.global-search { position: relative; min-width: 240px; flex: 1 1 280px; max-width: 420px; }
.global-search .input-group-text { background: var(--bs-body-bg); }
.global-search .form-control:focus { box-shadow: 0 0 0 .2rem rgba(21,128,61,.18); border-color: #15803d; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px;
  background: var(--bs-body-bg); border: 1px solid var(--bs-border-color, rgba(0,0,0,.12));
  border-radius: 12px; box-shadow: var(--shadow); z-index: 1080; max-height: 70vh; overflow-y: auto; padding: 4px 0;
}
.search-results:not(.show) { display: none; }
.search-group + .search-group { border-top: 1px solid var(--bs-border-color, rgba(0,0,0,.08)); }
.search-group-title {
  padding: 8px 14px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--bs-secondary-color); font-weight: 700; display: flex; align-items: center; gap: 6px;
}
.search-item {
  display: block; padding: 8px 14px; text-decoration: none; color: inherit;
  border-left: 3px solid transparent; transition: background .12s ease;
}
.search-item:hover { background: rgba(21,128,61,.10); border-left-color: #15803d; }
.si-title { font-weight: 600; font-size: 14px; line-height: 1.2; }
.si-sub { font-size: 12px; color: var(--bs-secondary-color); margin-top: 2px; }
.search-empty { padding: 14px 16px; color: var(--bs-secondary-color); font-size: 13px; }

/* Content */
.content { flex: 1; }
.page-header h1 { font-weight: 800; letter-spacing: -.5px; }

/* Cards */
.card { border: none; border-radius: var(--card-radius); box-shadow: var(--shadow); background: var(--bs-body-bg); }
.card-title { font-weight: 700; }
.kpi-card { overflow: hidden; position: relative; }
.kpi-card .kpi-icon {
  position: absolute; right: -8px; bottom: -12px; font-size: 72px; opacity: .08;
}
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.kpi-label { font-size: 13px; color: var(--bs-secondary-color); }
.kpi-strip {
  height: 4px; border-radius: 4px; margin-top: 10px;
}
.kpi-card:hover { transform: translateY(-3px); transition: transform .2s ease; }

.mini-stat { display: flex; align-items: center; gap: 10px; }
.mini-stat .pill { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; }

/* Tables */
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--bs-secondary-color); border-bottom: 2px solid rgba(0,0,0,.08); }
[data-bs-theme="dark"] .table thead th { border-bottom-color: rgba(255,255,255,.1); }

/* Status pills */
.pill-yes   { background:#dcfce7; color:#166534; }
.pill-no    { background:#fee2e2; color:#991b1b; }
.pill-warn  { background:#fef9c3; color:#854d0e; }
[data-bs-theme="dark"] .pill-yes  { background:rgba(22,133,74,.25); color:#86efac; }
[data-bs-theme="dark"] .pill-no   { background:rgba(220,53,69,.25); color:#fca5a5; }
[data-bs-theme="dark"] .pill-warn { background:rgba(202,138,4,.25); color:#fde68a; }

/* Charts */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.sm { height: 240px; }

/* Gauge / ring text */
.ring-val { fill: var(--bs-body-color); }

/* Photo gallery */
.photo-card { border-radius: 12px; overflow: hidden; cursor: pointer; position: relative; }
.photo-card .ph {
  aspect-ratio: 4/3; display: grid; place-items: center; font-size: 44px; color:#15803d;
  background: linear-gradient(135deg,#e8f5ee,#dbe5f5);
}
[data-bs-theme="dark"] .photo-card .ph { background:linear-gradient(135deg,#1a2233,#222d44); color:#7fa7ff; }
.photo-card .caption {
  position: absolute; left:0; right:0; bottom:0; padding:8px 10px;
  background: linear-gradient(0deg, rgba(0,0,0,.75), transparent); color:#fff; font-size: 12px;
}

/* Alert highlight */
.alert-critical { border-left: 5px solid #dc3545; }

/* Mobile */
@media (max-width: 991.98px) {
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035;
  }
}

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #15803d 0%, #0b4a26 50%, #06301a 100%); }
.auth-card { width: 100%; max-width: 410px; border-radius: 18px; padding: 34px; background:#fff; box-shadow: 0 30px 60px rgba(0,0,0,.3); }
.auth-logo { width:64px; height:64px; border-radius:14px; background:#15803d; color:#fff; display:grid; place-items:center; font-weight:800; font-size:26px; margin:0 auto 14px; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: rgba(11,61,145,.03); }

.footer { border-top: 1px solid rgba(0,0,0,.06); }
[data-bs-theme="dark"] .footer { border-top-color: rgba(255,255,255,.07); }
