/* =============================================================
   PAS — Policy Administration System
   Stylesheet: navy/teal scheme, sidebar layout, mobile-first
   ============================================================= */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --navy:          #1a2b4a;
  --navy-dark:     #111e34;
  --navy-light:    #243660;
  --teal:          #00897b;
  --teal-dark:     #00695c;
  --teal-light:    #e0f2f1;
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --radius:        10px;
  --shadow-sm:     0 1px 4px rgba(0,0,0,.08);
  --shadow:        0 2px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 4px 24px rgba(0,0,0,.14);
  --transition:    .2s ease;
  --font:          'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: .9rem;
  color: #2c3e50;
  background: #f0f2f5;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
img { max-width: 100%; }

/* ── Utility classes ─────────────────────────────────────────── */
.text-navy  { color: var(--navy) !important; }
.text-teal  { color: var(--teal) !important; }
.bg-navy    { background: var(--navy) !important; color: #fff; }
.bg-teal    { background: var(--teal) !important; color: #fff; }
.fw-medium  { font-weight: 500; }
.x-small    { font-size: .75rem; }
.font-mono, .font-monospace { font-family: 'Courier New', monospace !important; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-navy {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 7px;
  transition: background var(--transition), transform var(--transition);
}
.btn-navy:hover, .btn-navy:focus {
  background: var(--navy-dark);
  color: #fff;
  transform: translateY(-1px);
}
.btn-teal {
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 7px;
  transition: background var(--transition), transform var(--transition);
}
.btn-teal:hover, .btn-teal:focus {
  background: var(--teal-dark);
  color: #fff;
  transform: translateY(-1px);
}
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}
.btn { border-radius: 7px; font-weight: 500; font-size: .875rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: .02em; border-radius: 5px; }

/* ── ══════════════════════════════════════════════════════════ ══
   Auth Pages
   ══════════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 50%, var(--teal) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}
.auth-header {
  background: var(--navy);
  color: #fff;
  text-align: center;
  padding: 2rem 2rem 1.5rem;
}
.auth-header h4 { color: #fff; margin-bottom: .25rem; }
.auth-header .text-muted { color: rgba(255,255,255,.65) !important; }
.brand-icon-lg {
  width: 64px; height: 64px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
}
.auth-body { padding: 2rem; }
.auth-footer {
  border-top: 1px solid #f0f2f5;
  padding: .75rem 2rem;
  text-align: center;
  background: #fafbfc;
}

/* ── ══════════════════════════════════════════════════════════ ══
   App Layout — Sidebar + Main
   ══════════════════════════════════════════════════════════════ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}
.brand-icon {
  width: 38px; height: 38px;
  background: var(--teal);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.brand-name small {
  display: block;
  font-size: .68rem;
  font-weight: 400;
  color: rgba(255,255,255,.55);
  letter-spacing: .04em;
}

.sidebar-user {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: #fff; line-height: 1.3; }
.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .05em; }

.sidebar-nav { padding: .75rem 0; flex: 1; }
.nav-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.38);
  padding: 1rem 1.5rem .35rem;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .58rem 1.5rem;
  color: rgba(255,255,255,.75);
  font-size: .87rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: rgba(0,137,123,.2);
  color: #fff;
  border-left-color: var(--teal);
}
.nav-badge {
  margin-left: auto;
  font-size: .65rem;
  padding: .2em .55em;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 1rem 1.5rem;
}
.btn-logout {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.75);
  border: none;
  border-radius: 7px;
  padding: .45rem 1rem;
  font-size: .82rem;
  display: flex; align-items: center; gap: .5rem;
  width: 100%; text-align: left;
  transition: background var(--transition);
  text-decoration: none;
}
.btn-logout:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ── Sidebar Overlay (mobile) ────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
.sidebar-overlay.active { display: block; }

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

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.35rem;
  color: var(--navy);
  padding: .25rem .5rem;
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--transition);
}
.topbar-toggle:hover { background: #f0f2f5; }
.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
  flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.topbar-notif { position: relative; }
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: #ef4444;
  color: #fff; font-size: .6rem; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: translate(30%, -30%);
}

/* ── Page Content ─────────────────────────────────────────────── */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  border: 1px solid #e8ecf0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: #fff;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  padding: .9rem 1.25rem;
  display: flex; align-items: center; gap: .5rem;
}
.card-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}
.card-body { padding: 1.25rem; }
.card-footer { background: #fafbfc; border-top: 1px solid #e8ecf0; padding: .75rem 1.25rem; }

/* ── Stat Cards ───────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  font-size: 1.75rem;
  margin-bottom: .5rem;
  display: block;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: .25rem;
}
.stat-label {
  font-size: .78rem;
  color: #6c757d;
  font-weight: 500;
}
.stat-trend {
  font-size: .75rem;
  font-weight: 600;
  margin-top: .4rem;
}
.stat-trend.up   { color: #16a34a; }
.stat-trend.down { color: #dc2626; }

/* ── Filter Bar ───────────────────────────────────────────────── */
.filter-bar {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: var(--radius);
  padding: .875rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
  box-shadow: var(--shadow-sm);
}
.filter-bar .form-control,
.filter-bar .form-select { font-size: .85rem; border-radius: 7px; }

/* ── Tables ───────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
  background: #f8f9fc;
  color: var(--navy);
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-color: #e8ecf0;
  white-space: nowrap;
  padding: .65rem 1rem;
}
.table td { padding: .65rem 1rem; vertical-align: middle; border-color: #e8ecf0; }
.table tbody tr:hover { background: #f8f9fc; }
.table-responsive { border-radius: var(--radius); overflow: hidden; }

/* ── Member Avatars ───────────────────────────────────────────── */
.member-avatar-sm {
  width: 34px; height: 34px;
  background: var(--navy-light);
  color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem;
  flex-shrink: 0;
}
.member-avatar-lg {
  width: 72px; height: 72px;
  background: var(--navy-light);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.5rem;
  flex-shrink: 0;
}

/* ── Member Profile Header ────────────────────────────────────── */
.member-profile-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1.75rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.member-name { font-size: 1.25rem; font-weight: 700; color: #fff; margin-bottom: .2rem; }
.member-meta { font-size: .82rem; color: rgba(255,255,255,.7); }
.member-no   { font-family: monospace; font-size: .95rem; color: rgba(255,255,255,.9); }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: #9ca3af;
}
.empty-state i {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 1rem;
  opacity: .4;
}
.empty-state h5 { color: #6b7280; margin-bottom: .5rem; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination-wrap {
  padding: .75rem 1.25rem;
  border-top: 1px solid #e8ecf0;
  display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap;
}
.page-link {
  border-radius: 7px !important;
  color: var(--navy);
  font-size: .82rem;
  padding: .3rem .65rem;
  border-color: #e8ecf0;
  transition: background var(--transition);
}
.page-link:hover { background: #f0f2f5; color: var(--navy); }
.page-item.active .page-link { background: var(--navy); border-color: var(--navy); }

/* ── Spinner overlay ──────────────────────────────────────────── */
.spinner-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(255,255,255,.6);
  z-index: 9999;
  align-items: center; justify-content: center;
}
.spinner-overlay.active { display: flex; }
.spinner-border.text-navy { color: var(--navy) !important; }

/* ── Chart container ──────────────────────────────────────────── */
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }

/* ── Form Elements ────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 7px;
  border-color: #d1d5db;
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,137,123,.15);
}
.form-label { font-weight: 600; font-size: .82rem; color: #374151; margin-bottom: .35rem; }
.input-group-text { background: #f8f9fc; border-color: #d1d5db; color: #6b7280; font-size: .875rem; }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); font-size: .875rem; border: none; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #eff6ff; color: #1e40af; }

/* ── Modals ───────────────────────────────────────────────────── */
.modal-content { border: none; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-header { background: var(--navy); color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 1rem 1.5rem; }
.modal-title { color: #fff; font-weight: 700; font-size: .95rem; }
.modal-header .btn-close { filter: brightness(0) invert(1); opacity: .75; }
.modal-header .btn-close:hover { opacity: 1; }
.modal-body   { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid #e8ecf0; background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

/* ── Nav Tabs ─────────────────────────────────────────────────── */
.nav-tabs { border-bottom: 2px solid #e8ecf0; }
.nav-tabs .nav-link {
  font-size: .85rem; font-weight: 600;
  color: #6b7280;
  border: none; border-radius: 0;
  padding: .65rem 1.25rem;
  transition: color var(--transition);
}
.nav-tabs .nav-link:hover { color: var(--navy); }
.nav-tabs .nav-link.active {
  color: var(--navy);
  border-bottom: 2px solid var(--navy);
  background: none;
  margin-bottom: -2px;
}

/* ── Progress Bars ────────────────────────────────────────────── */
.progress { height: 8px; border-radius: 8px; background: #e8ecf0; }
.progress-bar { border-radius: 8px; }
.progress-bar.bg-navy { background: var(--navy) !important; }
.progress-bar.bg-teal { background: var(--teal) !important; }

/* ── List Groups ──────────────────────────────────────────────── */
.list-group-item { border-color: #e8ecf0; font-size: .875rem; padding: .75rem 1rem; }
.list-group-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.list-group-item:last-child  { border-radius: 0 0 var(--radius) var(--radius); }
.list-group-item.active { background: var(--navy); border-color: var(--navy); }

/* ── Info rows (dl/dt/dd) ─────────────────────────────────────── */
dl.info-grid { margin: 0; }
dl.info-grid dt { font-size: .78rem; color: #6b7280; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
dl.info-grid dd { font-size: .9rem; color: #111; margin-bottom: .85rem; }

/* ── Toast container ──────────────────────────────────────────── */
.toast-container { z-index: 9999; }

/* ── Custom scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ══════════════════════════════════════════════════════════════
   Responsive — Tablet & Mobile
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}

@media (max-width: 767.98px) {
  .stat-value { font-size: 1.45rem; }
  .filter-bar { padding: .75rem 1rem; }
  .filter-bar .form-control,
  .filter-bar .form-select { font-size: .82rem; }
  .table { font-size: .82rem; }
  .table td, .table th { padding: .5rem .65rem; }
  .card-header { padding: .75rem 1rem; }
  .card-body   { padding: 1rem; }
  .auth-body   { padding: 1.5rem 1.25rem; }
  .member-profile-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .topbar-actions .btn-sm { font-size: .78rem; padding: .3rem .6rem; }
}

@media (max-width: 575.98px) {
  .page-content { padding: .75rem; }
  .stat-card { padding: .9rem; }
  .stat-icon { font-size: 1.4rem; }
  .stat-value { font-size: 1.25rem; }
  .pagination-wrap { justify-content: center; }
  .topbar-title { font-size: .9rem; }
  .filter-bar { gap: .5rem; }
}

/* ── Print styles ─────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .topbar-toggle, .sidebar-overlay,
  .filter-bar .btn, .btn, .nav-tabs, form { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; page-break-inside: avoid; }
}
