/* =============================================
   MSB Insurance — Admin Panel CSS (Clean v2)
   ============================================= */

:root {
  --navy:        #003366;
  --navy-dark:   #002244;
  --royal:       #4169e1;
  --orange:      #ff8200;
  --success:     #16a34a;
  --danger:      #dc2626;
  --warning:     #d97706;
  --info:        #0284c7;
  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --bg-body:     #f1f5f9;
  --bg-card:     #ffffff;
  --border:      #e5e7eb;
  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 1px 6px rgba(0,0,0,.08);
  --shadow-md:   0 4px 20px rgba(0,0,0,.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ── LAYOUT ─────────────────────────────────── */
.admin-body {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy-dark, #002244);
  background: #001f3f;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand-icon { font-size: 1.5rem; }
.sidebar-brand-name {
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: .62rem;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.sidebar-nav { padding: 10px 0; flex: 1; }
.sidebar-nav-group { margin-bottom: 4px; }
.sidebar-nav-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.3);
  padding: 10px 20px 4px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.sidebar-nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}
.sidebar-nav-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--orange);
}
.sni-icon {
  font-size: .9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.sni-badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 100px;
  min-width: 18px;
  text-align: center;
}
.sidebar-logout { color: rgba(255,120,120,.75) !important; }
.sidebar-logout:hover {
  background: rgba(220,38,38,.12) !important;
  color: #f87171 !important;
}

/* ── TOPBAR ─────────────────────────────────── */
.admin-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  z-index: 90;
  box-shadow: var(--shadow);
}
.topbar-menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.topbar-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--navy);
  border-radius: 2px;
}
.topbar-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.topbar-icon-btn {
  position: relative;
  font-size: 1.1rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  text-decoration: none;
}
.topbar-badge {
  position: absolute;
  top: -3px; right: -5px;
  background: var(--orange);
  color: #fff;
  font-size: .6rem;
  font-weight: 800;
  border-radius: 100px;
  padding: 1px 4px;
  min-width: 16px;
  text-align: center;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
}
.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--royal));
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-user-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}
.topbar-user-role {
  font-size: .72rem;
  color: var(--text-muted);
}
.topbar-user-info { display: flex; flex-direction: column; gap: 1px; }

/* ── MAIN CONTENT ───────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px 28px;
  min-height: calc(100vh - var(--topbar-h));
  width: calc(100% - var(--sidebar-w));
}

/* ── MOBILE OVERLAY ─────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ── PAGE HEADER ────────────────────────────── */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 2px;
}
.admin-page-sub { font-size: .82rem; color: var(--text-muted); }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── STAT CARDS ─────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 16px 14px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card-orange { border-top-color: var(--orange); }
.stat-card-navy   { border-top-color: var(--navy); }
.stat-card-blue   { border-top-color: var(--royal); }
.stat-card-green  { border-top-color: var(--success); }
.stat-card-purple { border-top-color: #7c3aed; }
.stat-card-warning{ border-top-color: var(--warning); }
.stat-card-icon   { font-size: 1.3rem; margin-bottom: 6px; }
.stat-card-num    {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}
.stat-card-label  { font-size: .75rem; color: var(--text-muted); margin-bottom: 6px; }
.stat-card-link   {
  font-size: .75rem;
  font-weight: 600;
  color: var(--royal);
  text-decoration: none;
  margin-top: auto;
}
.stat-card-link:hover { color: var(--navy); }

/* ── ADMIN CARD ─────────────────────────────── */
.admin-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.admin-card-title { font-size: .9rem; font-weight: 700; color: var(--navy); }
.admin-card-action {
  font-size: .8rem;
  color: var(--royal);
  font-weight: 600;
  text-decoration: none;
}
.admin-card-body { padding: 18px; }
.admin-card-body.p0 { padding: 0; }

/* ── TWO COL LAYOUT ─────────────────────────── */
.admin-two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 0;
}

/* ── QUICK ACTIONS ──────────────────────────── */
.quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qa-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #f8faff;
  border: 1px solid #e8ecf8;
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  transition: all .15s;
  position: relative;
}
.qa-item:hover { background: #eef2fb; border-color: var(--royal); }
.qa-icon { font-size: 1rem; }
.qa-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--orange);
  color: #fff;
  font-size: .63rem;
  font-weight: 700;
  border-radius: 100px;
  padding: 1px 5px;
}

/* ── TABLE ──────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  background: #f8faff;
  padding: 10px 14px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 11px 14px;
  font-size: .85rem;
  color: var(--text-primary);
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: #fafbff; }
.tr-highlight td { background: #fffbeb !important; }
.table-empty {
  text-align: center;
  padding: 40px 20px !important;
  color: var(--text-muted);
  font-size: .88rem;
}
.td-name  { font-weight: 600; color: var(--navy); font-size: .88rem; }
.td-sub   { font-size: .76rem; color: var(--text-muted); margin-top: 2px; }
.td-ellipsis {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── ACTION BUTTONS ─────────────────────────── */
.action-cell { white-space: nowrap; }
.action-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .76rem;
  font-weight: 600;
  background: #eef2fb;
  color: var(--navy);
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
  border: none;
  margin-right: 3px;
}
.action-btn:hover     { background: var(--navy); color: #fff; }
.action-btn-red       { background: #fef2f2; color: var(--danger); }
.action-btn-red:hover { background: var(--danger); color: #fff; }
.action-btn-green     { background: #f0fdf4; color: var(--success); }

/* ── BADGES ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: .71rem;
  font-weight: 700;
  background: #f3f4f6;
  color: #555;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: var(--danger); }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* Status badges */
.badge-info         { background: #dbeafe; color: #1d4ed8; }
.badge-warning      { background: #fef9c3; color: #a16207; }
.badge-success      { background: #dcfce7; color: #15803d; }
.badge-danger       { background: #fee2e2; color: var(--danger); }
.badge-primary      { background: #ede9fe; color: #6d28d9; }
.badge-secondary    { background: #f3f4f6; color: #6b7280; }

/* ── FILTER BAR ─────────────────────────────── */
.filter-form .filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: inherit;
  outline: none;
  transition: border .15s;
}
.filter-input:focus { border-color: var(--navy); }
.filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: inherit;
  outline: none;
  transition: border .15s;
  background: #fff;
  cursor: pointer;
  min-width: 130px;
}
.filter-select:focus { border-color: var(--navy); }

/* ── STATUS TABS ────────────────────────────── */
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.stab {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: #fff;
  border: 1.5px solid var(--border);
  text-decoration: none;
  transition: all .15s;
}
.stab:hover, .stab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ── FORM CONTROLS ──────────────────────────── */
.admin-label {
  display: block;
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.admin-form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  font-family: inherit;
  outline: none;
  transition: border .15s;
  background: #fff;
  color: var(--text-primary);
}
.admin-form-control:focus { border-color: var(--navy); }
textarea.admin-form-control { resize: vertical; }
.form-group  { margin-bottom: 14px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.admin-section-divider {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--royal);
  padding: 12px 0 8px;
  border-bottom: 2px solid #f0f4fb;
  margin-bottom: 14px;
  margin-top: 6px;
}

/* ── DETAIL VIEW ────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
.detail-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.detail-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  padding: 9px 0;
  width: 130px;
  vertical-align: top;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.detail-table td {
  padding: 9px 0;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-primary);
}
.detail-table tr:last-child td { border-bottom: none; }

/* ── MEMBER CELL ────────────────────────────── */
.member-cell { display: flex; align-items: center; gap: 9px; }
.member-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy), var(--royal));
  color: #fff;
  font-size: .77rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── ACTIVITY LIST ──────────────────────────── */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--royal);
  flex-shrink: 0;
  margin-top: 5px;
}
.activity-text { font-size: .84rem; color: var(--text-primary); line-height: 1.5; }
.activity-time { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }

/* ── PAGINATION ─────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  justify-content: center;
}
.page-btn {
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .83rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  transition: all .15s;
}
.page-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-info { font-size: .82rem; color: var(--text-muted); }

/* ── FLASH ──────────────────────────────────── */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: .87rem;
  font-weight: 500;
  margin-bottom: 16px;
}
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }
.flash-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── BUTTONS ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover { background: #002a55; }
.btn-orange {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
.btn-orange:hover { background: #e06000; }
.btn-outline {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-outline:hover { background: var(--navy); color: #fff; }
.admin-btn-sm { padding: 7px 14px !important; font-size: .8rem !important; }

/* ── LOGIN PAGE ─────────────────────────────── */
body.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #003366 0%, #4169e1 100%);
  min-height: 100vh;
  padding: 20px;
}

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 1100px) {
  .stat-cards { grid-template-columns: repeat(3, 1fr); }
  .admin-two-col { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-topbar {
    left: 0;
  }
  .admin-main {
    margin-left: 0;
    width: 100%;
    padding: 18px 16px;
  }
  .topbar-menu-btn { display: flex; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .topbar-user-info { display: none; }
}

@media (max-width: 600px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .admin-page-header { flex-direction: column; align-items: flex-start; }
  .quick-actions-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
}