
/* Raya Census V2 UI
   - Modern light/dark themes using CSS variables
   - RTL friendly
*/

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root{
  --font: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;

  /* Light (default) */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, .12);

  --primary: #2563eb;
  --primary-2: #1d4ed8;

  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;

  --shadow: 0 14px 40px rgba(2, 6, 23, .10);
  --shadow-soft: 0 10px 24px rgba(2, 6, 23, .08);

  --radius: 14px;
}

/* Dark */
:root[data-theme="dark"]{
  --bg: #0b1220;
  --surface: rgba(17,24,39,.72);
  --surface-2: rgba(255,255,255,.06);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255,255,255,.12);

  --primary: #60a5fa;
  --primary-2: #93c5fd;

  --shadow: 0 18px 60px rgba(0,0,0,.35);
  --shadow-soft: 0 12px 30px rgba(0,0,0,.28);
}

html, body { height: 100%; }

body{
  font-family: var(--font);
  background: radial-gradient(1200px 500px at 10% -10%, rgba(37, 99, 235, .10), transparent 60%),
              radial-gradient(900px 400px at 90% 0%, rgba(245, 158, 11, .08), transparent 55%),
              var(--bg);
  color: var(--text);
}

/* Bootstrap overrides */
a{ color: var(--primary); text-decoration: none; }
a:hover{ color: var(--primary-2); text-decoration: underline; }

.text-muted, .muted{ color: var(--muted) !important; }

.container{ max-width: 1200px; }

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.shadow-soft{ box-shadow: var(--shadow-soft) !important; }

.table{
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  border-color: var(--border);
}
.table thead th{
  color: var(--text);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.table td, .table th{ border-top: 1px solid var(--border); }
.table tbody tr:hover{ background: rgba(37,99,235,.06); }

.form-label, label{ font-weight: 700; color: var(--text); }
.form-control, .form-select, textarea{
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.form-control::placeholder{ color: rgba(71,85,105,.65); }
:root[data-theme="dark"] .form-control::placeholder{ color: rgba(156,163,175,.65); }

.form-control:focus, .form-select:focus, textarea:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 .25rem rgba(37,99,235,.15);
  background: var(--surface);
  color: var(--text);
}

.navbar{
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.navbar .navbar-brand{ font-weight: 800; letter-spacing: .2px; color: var(--text) !important; }
.navbar .nav-link{ color: var(--muted) !important; font-weight: 700; }
.navbar .nav-link:hover{ color: var(--text) !important; }

.btn{
  border-radius: 12px;
  font-weight: 800;
}
.btn-primary{
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover{
  background: var(--primary-2);
  border-color: var(--primary-2);
}
.btn-outline-surface{
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline-surface:hover{
  background: var(--surface-2);
  color: var(--text);
}

.alert{
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

/* Dashboard stats */
.stat{
  background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(99,102,241,.10));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}
:root[data-theme="dark"] .stat{
  background: linear-gradient(135deg, rgba(96,165,250,.12), rgba(99,102,241,.10));
}
.stat .k{ font-size: 28px; font-weight: 900; }
.stat .t{ color: var(--muted); font-weight: 700; }

/* Tabs */
.nav-tabs{
  border-bottom: 1px solid var(--border);
}
.nav-tabs .nav-link{
  border: 0 !important;
  color: var(--muted) !important;
  font-weight: 900;
  border-radius: 12px 12px 0 0;
}
.nav-tabs .nav-link.active{
  background: var(--surface);
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-bottom-color: transparent !important;
}

/* Small polish */
.page-title{
  font-weight: 900;
  letter-spacing: .2px;
}
.surface{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.theme-icon{
  width: 18px; height: 18px;
  display: inline-block;
  vertical-align: -3px;
}



/* ===== V3.1 Pro UI Enhancements ===== */

/* Smooth transitions */
*{ transition: background-color .2s ease, color .2s ease, border-color .2s ease; }
@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; animation: none !important; }
}

/* Sidebar Pro */
:root{
  --sb-w: 280px;
  --sb-w-collapsed: 88px;
}

/* ensure saas shell uses variables */
.saas-sidebar{
  width: var(--sb-w);
  flex: 0 0 var(--sb-w);
}

.saas-sidebar{
  background: linear-gradient(180deg, rgba(37,99,235,.22) 0%, rgba(15,23,42,.80) 35%, rgba(15,23,42,.92) 100%);
  border-left: 1px solid rgba(255,255,255,.10);
}

:root[data-theme="light"] .saas-sidebar{
  background: linear-gradient(180deg, rgba(37,99,235,.10) 0%, rgba(255,255,255,.92) 30%, rgba(248,250,252,.98) 100%);
  border-left: 1px solid rgba(15,23,42,.10);
}

.brand-dot{
  width: 10px; height: 10px; border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #93c5fd, #2563eb);
  box-shadow: 0 0 0 6px rgba(37,99,235,.15);
}

/* nav link with icon */
.sidebar-link{
  gap: .75rem;
  padding: .7rem .9rem;
  border-radius: 14px;
  border: 1px solid transparent;
}

.sidebar-link .nav-ico{
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: .92;
}

.sidebar-link:hover{
  transform: translateY(-1px);
}

.sidebar-link.active{
  background: rgba(37,99,235,.18);
  border-color: rgba(37,99,235,.28);
  box-shadow: 0 10px 24px rgba(37,99,235,.14);
}

:root[data-theme="light"] .sidebar-link.active{
  background: rgba(37,99,235,.12);
}

/* Collapsed state */
body.sb-collapsed .saas-sidebar{
  width: var(--sb-w-collapsed);
  flex-basis: var(--sb-w-collapsed);
}

body.sb-collapsed .saas-sidebar .brand-title,
body.sb-collapsed .saas-sidebar .muted,
body.sb-collapsed .saas-sidebar .sidebar-section,
body.sb-collapsed .saas-sidebar .sidebar-link span.label{
  display:none !important;
}

body.sb-collapsed .saas-sidebar .sidebar-link{
  justify-content: center;
  padding: .7rem .5rem;
}

body.sb-collapsed .saas-sidebar .sidebar-link .nav-ico{
  width: 20px; height: 20px;
}

.sidebar-actions{
  display:flex;
  gap:.5rem;
}

.icon-btn{
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: .45rem .6rem;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
}
.icon-btn:hover{ filter: brightness(1.05); }

/* Topbar polish */
.topbar{
  background: rgba(255,255,255,.60);
}
:root[data-theme="dark"] .topbar{
  background: rgba(2,6,23,.45);
}

/* Soft animations */
.fade-up{
  animation: fadeUp .35s ease both;
}
@keyframes fadeUp{
  from{ opacity:0; transform: translateY(8px); }
  to{ opacity:1; transform: translateY(0); }
}

/* Dashboard colored stats */
.stat.stat--blue{
  background: linear-gradient(135deg, rgba(37,99,235,.18), rgba(255,255,255,.04));
  border-color: rgba(37,99,235,.22);
}
.stat.stat--green{
  background: linear-gradient(135deg, rgba(16,185,129,.18), rgba(255,255,255,.04));
  border-color: rgba(16,185,129,.22);
}
:root[data-theme="light"] .stat.stat--blue{
  background: linear-gradient(135deg, rgba(37,99,235,.10), rgba(255,255,255,.90));
}
:root[data-theme="light"] .stat.stat--green{
  background: linear-gradient(135deg, rgba(16,185,129,.10), rgba(255,255,255,.90));
}

/* Relation badge darker */
.badge-soft{
  background: rgba(148,163,184,.25);
  color: var(--text);
  border: 1px solid rgba(148,163,184,.35);
  font-weight: 700;
}
:root[data-theme="light"] .badge-soft{
  background: rgba(15,23,42,.06);
  border-color: rgba(15,23,42,.10);
}

/* Theme toggle button */
.theme-toggle{
  display:flex; align-items:center; justify-content:center; gap:.45rem;
}
.theme-toggle svg{ width:16px; height:16px; }


.stat--purple{background: linear-gradient(135deg, rgba(124,58,237,.22), rgba(59,130,246,.18)); border:1px solid rgba(124,58,237,.18);}


/* V4.4.2 fixed light sidebar/topbar */
.saas-sidebar{background:#f8fafc !important;border-left:1px solid rgba(15,23,42,.08) !important;backdrop-filter:none !important}
:root[data-theme="light"] .saas-sidebar,:root[data-theme="dark"] .saas-sidebar{background:#f8fafc !important;border-left:1px solid rgba(15,23,42,.08) !important}
.topbar{background:#ffffff !important;border-bottom:1px solid rgba(15,23,42,.08) !important;backdrop-filter:none !important}
:root[data-theme="light"] .topbar,:root[data-theme="dark"] .topbar{background:#ffffff !important;border-bottom:1px solid rgba(15,23,42,.08) !important}
.brand-title,.sidebar-link,.sidebar-link .label,.sidebar-link .nav-ico,.topbar .muted,.saas-sidebar .fw-semibold,.saas-sidebar .role-pill,.btn-outline-surface{color:#0f172a !important}
.sidebar-link:hover{background:rgba(37,99,235,.06) !important}
.sidebar-link.active{background:rgba(37,99,235,.10) !important;border-color:rgba(37,99,235,.18) !important;box-shadow:none !important}


/* Household head details polish */
.household-head-wrap{padding-top:1rem}
.household-hero{
  display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;
  padding:1rem 1.1rem;border:1px solid var(--border);border-radius:16px;
  background:linear-gradient(135deg, rgba(37,99,235,.06), rgba(99,102,241,.04));
}
.household-hero-name{font-size:1.9rem;font-weight:900;line-height:1.3;color:var(--text)}
.household-hero-id{
  min-width:74px;text-align:center;padding:.55rem .8rem;border-radius:999px;
  background:var(--surface);border:1px solid var(--border);font-weight:900;color:var(--primary)
}
.household-section-card{
  background:var(--surface);border:1px solid var(--border);border-radius:16px;
  padding:1rem;box-shadow:var(--shadow-soft)
}
.section-title{font-weight:900;font-size:1rem;margin-bottom:.9rem;color:var(--text)}
.household-info-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.85rem}
.info-box{
  background:var(--surface-2);border:1px solid var(--border);border-radius:14px;
  padding:.85rem .95rem;min-height:88px
}
.info-box-wide{grid-column:1/-1}
.info-label{font-size:.82rem;color:var(--muted);margin-bottom:.35rem;font-weight:700}
.info-value{font-size:1rem;font-weight:800;color:var(--text);word-break:break-word}
.info-sub{font-size:.82rem;color:var(--muted);margin-top:.3rem}
.note-panel{
  min-height:160px;white-space:pre-wrap;background:var(--surface-2);border:1px solid var(--border);
  border-radius:14px;padding:.95rem;color:var(--text)
}
.child-households-list{display:flex;flex-direction:column;gap:.7rem}
.child-household-item{
  display:flex;align-items:center;justify-content:space-between;gap:.75rem;
  padding:.85rem .95rem;background:var(--surface-2);border:1px solid var(--border);
  border-radius:14px;text-decoration:none;color:var(--text)
}
.child-household-item:hover{background:rgba(37,99,235,.06);text-decoration:none}
.empty-soft{
  background:var(--surface-2);border:1px dashed var(--border);border-radius:14px;
  padding:1rem;color:var(--muted)
}
@media (max-width: 991.98px){
  .household-hero{flex-direction:column;align-items:flex-start}
}
@media (max-width: 767.98px){
  .household-info-grid{grid-template-columns:1fr}
  .household-hero-name{font-size:1.45rem}
}
