/* ==========================================================
   Kakamega County PMS — Demo styles
   Tailwind CDN handles utilities; this file is for fonts,
   resets, and a few cohesive component classes.
   ========================================================== */

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

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --success:        #10b981;
  --success-light:  #d1fae5;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --slate-50:       #f8fafc;
  --slate-100:      #f1f5f9;
  --slate-200:      #e2e8f0;
  --slate-300:      #cbd5e1;
  --slate-500:      #64748b;
  --slate-700:      #334155;
  --slate-900:      #0f172a;
  --sidebar-w:      256px;
  --topbar-h:       64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Public top nav ---------- */
.public-nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--slate-200);
}

/* ---------- App layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--slate-200);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px 8px;
  border-bottom: 1px solid var(--slate-100);
  margin-bottom: 14px;
}
.sidebar-brand .logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: grid; place-items: center;
  color: #fff; font-weight: 800;
}
.sidebar-section {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--slate-500); padding: 14px 10px 6px 10px; letter-spacing: 0.6px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--slate-700); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background 0.15s ease;
}
.sidebar-link:hover { background: var(--slate-100); }
.sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-search {
  background: var(--slate-100);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px 8px 38px;
  width: 340px; max-width: 100%;
  font-size: 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m21 21-4.34-4.34M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; background-size: 16px;
}
.topbar-search:focus { outline: none; border-color: var(--primary); background-color: #fff; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--slate-100); color: var(--slate-700);
  border: 0; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--slate-200); }
.notif-dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: #fff; font-weight: 600;
  display: grid; place-items: center; font-size: 13px;
}

/* ---------- Content ---------- */
.page-content { padding: 28px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--slate-500); font-size: 14px; margin: 4px 0 0 0; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 20px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 18px 20px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.kpi-card:hover { border-color: var(--slate-300); box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.kpi-label { font-size: 12px; color: var(--slate-500); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi-delta { font-size: 12px; margin-top: 4px; font-weight: 500; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.badge.completed { background: var(--success-light); color: #047857; }
.badge.ongoing   { background: var(--primary-light); color: var(--primary-dark); }
.badge.planning  { background: #f3e8ff; color: #6b21a8; }
.badge.stalled   { background: var(--danger-light); color: #b91c1c; }
.badge.delayed   { background: var(--warning-light); color: #92400e; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--slate-700); border-color: var(--slate-200); }
.btn-secondary:hover { background: var(--slate-50); border-color: var(--slate-300); }
.btn-ghost { background: transparent; color: var(--slate-700); }
.btn-ghost:hover { background: var(--slate-100); }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; padding: 12px 16px; font-weight: 600; font-size: 12px;
  color: var(--slate-500); background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200); text-transform: uppercase; letter-spacing: .4px;
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--slate-100); color: var(--slate-700); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: var(--slate-50); }

/* ---------- Phase tracker ---------- */
.phase-track { display: flex; align-items: center; }
.phase-step { flex: 1; text-align: center; position: relative; }
.phase-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--slate-200); color: var(--slate-500);
  display: grid; place-items: center; margin: 0 auto 8px;
  font-weight: 600; font-size: 12px; position: relative; z-index: 1;
}
.phase-step.done .phase-dot { background: var(--success); color: #fff; }
.phase-step.active .phase-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 6px var(--primary-light); }
.phase-step::after {
  content: ''; position: absolute; top: 14px; left: 50%; right: -50%;
  height: 2px; background: var(--slate-200); z-index: 0;
}
.phase-step.done::after { background: var(--success); }
.phase-step:last-child::after { display: none; }
.phase-label { font-size: 12px; color: var(--slate-700); font-weight: 500; }
.phase-step.active .phase-label { color: var(--primary-dark); font-weight: 600; }

/* ---------- Progress ---------- */
.progress { background: var(--slate-100); height: 8px; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--slate-200); margin: 16px 0; }
.muted { color: var(--slate-500); }
.section-title { font-size: 16px; font-weight: 600; margin: 0 0 14px 0; }
.gradient-hero {
  background: radial-gradient(1100px 500px at 70% -100px, rgba(37,99,235,.15), transparent),
              radial-gradient(900px 500px at 10% 0%,  rgba(99,102,241,.10), transparent);
}
.pic-thumb { aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--slate-100); }
.pic-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.scroll-x { overflow-x: auto; }
.scroll-x::-webkit-scrollbar { height: 8px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 4px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar-search { width: 100%; }
}

/* ============================================================
   TOAST / MODAL / LIGHTBOX / DROPDOWNS
   ============================================================ */

#toast-container {
  position: fixed; top: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--slate-900); color: #fff;
  padding: 11px 16px 11px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  transform: translateX(420px); opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
  min-width: 260px; max-width: 380px; pointer-events: auto;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: #047857; }
.toast-error   { background: #b91c1c; }
.toast-info    { background: #1e293b; }
.toast-icon { font-weight: 700; }

.modal-wrap {
  position: fixed; inset: 0; z-index: 1900;
  opacity: 0; transition: opacity .2s ease;
}
.modal-wrap.show { opacity: 1; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative; background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
  margin: 60px auto;
  max-width: 560px; width: calc(100% - 32px);
  max-height: 86vh;
  display: flex; flex-direction: column;
  transform: translateY(20px); transition: transform .2s ease;
}
.modal-wrap.show .modal-card { transform: translateY(0); }
.modal-sm { max-width: 400px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 780px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--slate-200);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent; border: 0;
  font-size: 26px; line-height: 1; color: var(--slate-500);
  cursor: pointer; padding: 0 6px;
}
.modal-close:hover { color: var(--slate-900); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--slate-100);
}

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--slate-700); text-transform: uppercase;
  letter-spacing: .4px; margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--slate-200); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.export-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--slate-200);
  border-radius: 10px; cursor: pointer; font-size: 13px;
}
.export-opt:hover { border-color: var(--primary); }
.export-opt input { margin-top: 3px; }

.upload-zone {
  position: relative; border: 2px dashed var(--slate-300);
  border-radius: 12px; padding: 26px; text-align: center;
  background: var(--slate-50); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0;
}

.lightbox {
  position: fixed; inset: 0; z-index: 1950;
  background: rgba(0,0,0,.9);
  display: grid; place-items: center;
  cursor: zoom-out; opacity: 0;
  transition: opacity .2s ease;
}
.lightbox.show { opacity: 1; }
.lightbox img {
  max-width: 92vw; max-height: 88vh;
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.lightbox-cap {
  position: absolute; bottom: 24px; left: 50%;
  transform: translateX(-50%); color: #fff;
  background: rgba(0,0,0,.45); padding: 6px 14px;
  border-radius: 999px; font-size: 13px;
}

/* Dropdown panels (notification, user menu) */
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.12);
  min-width: 280px; z-index: 100; overflow: hidden;
}
.dropdown-head {
  padding: 12px 16px; border-bottom: 1px solid var(--slate-100);
  font-size: 12px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: .4px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13.5px; color: var(--slate-700);
  text-decoration: none; cursor: pointer;
}
.dropdown-item:hover { background: var(--slate-50); }
.dropdown-item.danger { color: #dc2626; }
.dropdown-item.danger:hover { background: #fef2f2; }
.dropdown-foot {
  padding: 10px 16px; border-top: 1px solid var(--slate-100);
  font-size: 12px; text-align: center;
}
.dropdown-foot a { color: var(--primary); font-weight: 600; }

.topbar-icon-wrap { position: relative; }

/* Filter chips */
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--slate-100); color: var(--slate-700);
  border: 0; cursor: pointer; transition: background .15s;
}
.chip:hover { background: var(--slate-200); }
.chip.active { background: var(--primary); color: #fff; }

