/* ============================================================
   TASIWA - Main Stylesheet
   Tanzania Sickle Cell Warriors Organization
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Playfair+Display:wght@600;700&display=swap');

/* ── CSS Variables ── */
:root {
  --primary:        #C62828;
  --primary-dark:   #8E0000;
  --primary-light:  #EF5350;
  --primary-pale:   #FFEBEE;
  --accent:         #FF6F00;
  --sidebar-bg:     #1A0A0A;
  --sidebar-hover:  #2D1010;
  --sidebar-active: #C62828;
  --sidebar-text:   #E8D5D5;
  --sidebar-muted:  #9E7777;
  --sidebar-width:  260px;
  --topbar-h:       64px;
  --bg:             #F5F6FA;
  --surface:        #FFFFFF;
  --border:         #E8ECF0;
  --text:           #1A1A2E;
  --text-muted:     #6B7280;
  --text-light:     #9CA3AF;
  --success:        #2E7D32;
  --success-light:  #E8F5E9;
  --warning:        #E65100;
  --warning-light:  #FFF3E0;
  --info:           #0277BD;
  --info-light:     #E1F5FE;
  --danger:         #C62828;
  --danger-light:   #FFEBEE;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  --radius:         10px;
  --radius-sm:      6px;
  --radius-lg:      16px;
  --font-main:      'DM Sans', sans-serif;
  --font-display:   'Playfair Display', serif;
  --transition:     0.22s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transition: width var(--transition);
}

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--topbar-h);
}
.sidebar-logo {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo svg { width: 22px; height: 22px; fill: #fff; }
.sidebar-brand-text { overflow: hidden; }
.sidebar-brand-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-tagline {
  font-size: 0.65rem;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Nav */
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }
.nav-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 16px 18px 6px;
}
.nav-item { display: block; position: relative; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active {
  background: var(--primary);
  color: #fff;
}
.nav-link .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: .75;
}
.nav-link.active .nav-icon,
.nav-link:hover .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}
.nav-link.active .nav-badge { background: rgba(255,255,255,.3); }

/* Bottom nav */
.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 8px 0;
}

/* ── MAIN LAYOUT ── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-title span { color: var(--text-muted); font-weight: 400; font-size: .875rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }
.topbar-btn .badge-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid #fff;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}
.user-info { text-align: right; }
.user-info strong { display: block; font-size: .8rem; font-weight: 600; line-height: 1.2; }
.user-info small { color: var(--text-muted); font-size: .7rem; text-transform: capitalize; }

/* ── PAGE CONTENT ── */
.page-content { padding: 24px; flex: 1; }
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.page-header p { color: var(--text-muted); font-size: .875rem; margin-top: 4px; }
.breadcrumb { font-size: .8rem; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--primary); }
.breadcrumb span { margin: 0 6px; }

/* ── STAT CARDS ── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 1200px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .stat-cards { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.red   { background: var(--primary-pale); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.blue  { background: var(--info-light); color: var(--info); }
.stat-icon.orange{ background: var(--warning-light); color: var(--warning); }
.stat-body { flex: 1; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-change {
  font-size: .72rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--primary); }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { color: var(--primary); }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── TABLES ── */
.table-responsive { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #FAFBFC; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── BADGES / PILLS ── */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-pill.aa     { background: #E8F5E9; color: #2E7D32; }
.badge-pill.as     { background: #E3F2FD; color: #1565C0; }
.badge-pill.ac     { background: #FFF8E1; color: #F57F17; }
.badge-pill.ss     { background: #FFEBEE; color: #C62828; }
.badge-pill.sc     { background: #FCE4EC; color: #AD1457; }
.badge-pill.inconclusive { background: #F3E5F5; color: #6A1B9A; }
.badge-pill.active     { background: var(--success-light); color: var(--success); }
.badge-pill.inactive   { background: #ECEFF1; color: #546E7A; }
.badge-pill.pending    { background: var(--warning-light); color: var(--warning); }
.badge-pill.completed  { background: var(--success-light); color: var(--success); }
.badge-pill.facility   { background: var(--info-light); color: var(--info); }
.badge-pill.community  { background: #F3E5F5; color: #7B1FA2; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #1B5E20; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8E0000; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: .8rem; }
.btn-icon      { padding: 7px; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--primary); margin-left: 3px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198,40,40,.1);
}
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
.form-control.is-invalid { border-color: var(--primary); }
.form-error { font-size: .75rem; color: var(--primary); margin-top: 4px; }
.form-hint  { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 90px; resize: vertical; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input[type=radio],
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 768px) {
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #A5D6A7; }
.alert-danger  { background: var(--danger-light); color: var(--primary); border: 1px solid #EF9A9A; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #FFCC80; }
.alert-info    { background: var(--info-light); color: var(--info); border: 1px solid #81D4FA; }

/* ── PAGINATION ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
}
.page-link {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.page-link:hover { background: var(--primary-pale); border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .4; cursor: default; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.95);
  transition: transform var(--transition);
}
.modal-overlay.show .modal-box { transform: scale(1); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-close {
  width: 30px; height: 30px;
  border: none; background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--primary-pale); color: var(--primary); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px;
}

/* ── SEARCH & FILTERS ── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap svg {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}
.search-input-wrap .form-control { padding-left: 34px; }

/* ── CHART CONTAINER ── */
.chart-container { position: relative; height: 260px; }

/* ── UTILITY ── */
.text-primary { color: var(--primary); }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--primary); }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.ms-auto { margin-left: auto; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #3D1515 60%, #1A0A0A 100%);
}
.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(198,40,40,.3) 0%, transparent 70%);
}
.login-brand { text-align: center; position: relative; z-index: 1; }
.login-logo {
  width: 80px; height: 80px;
  background: var(--primary);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 32px rgba(198,40,40,.4);
}
.login-logo svg { width: 44px; height: 44px; fill: #fff; }
.login-brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: #fff;
  margin-bottom: 8px;
}
.login-brand p { color: rgba(255,255,255,.6); font-size: .9rem; max-width: 280px; margin: 0 auto; }
.login-stats { margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.login-stat { text-align: center; background: rgba(255,255,255,.07); border-radius: 10px; padding: 16px; }
.login-stat .val { font-size: 1.5rem; font-weight: 700; color: var(--primary-light); }
.login-stat .lbl { font-size: .75rem; color: rgba(255,255,255,.5); margin-top: 4px; }

.login-right {
  width: 420px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-form-wrap { width: 100%; }
.login-form-wrap h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 6px;
}
.login-form-wrap p { color: var(--text-muted); margin-bottom: 30px; font-size: .875rem; }

@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
}

/* ── SECTION DIVIDER ── */
.section-sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── CONDITIONAL BLOCKS ── */
.conditional-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 8px;
  display: none;
}
.conditional-block.show { display: block; }

/* ── STOCK INDICATOR ── */
.stock-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.stock-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }
.stock-fill.high   { background: var(--success); }
.stock-fill.medium { background: var(--warning); }
.stock-fill.low    { background: var(--primary); }

/* ── SIDEBAR COLLAPSE on mobile ── */
@media (max-width: 900px) {
  .sidebar { width: 0; }
  .main-wrapper { margin-left: 0; }
  .sidebar.open { width: var(--sidebar-width); }
}
