/* =============================================================
   KSD Municipality Customer Care System
   ============================================================= */

:root {
  --blue:       #0d3875;
  --blue-dark:  #092a58;
  --blue-mid:   #1a5da8;
  --blue-light: #e8f0fb;
  --gold:       #e8a020;
  --gold-light: #fef3dc;
  --green:      #1a8a4a;
  --red:        #c0392b;
  --text:       #1c2b3a;
  --muted:      #5a6a7e;
  --border:     #d6e0ec;
  --bg:         #f4f7fb;
  --white:      #ffffff;
  --ksd-blue:   #0d3875;
  --ksd-gold:   #e8a020;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
  --shadow:     0 4px 18px rgba(0,0,0,.1);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.13);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}
.main-content { flex: 1; }
a { color: var(--blue); }
img { max-width: 100%; }

/* ── Navbar ────────────────────────────────────────────────── */
.ksd-navbar {
  background: var(--blue-dark) !important;
  border-bottom: 3px solid var(--gold);
  padding: .5rem 0;
}
.ksd-navbar .navbar-brand { gap: .75rem; }
.navbar-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 6px; background: rgba(255,255,255,.1); padding: 2px; }
.brand-text .brand-name { font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-text .brand-sub  { font-size: .65rem; color: rgba(255,255,255,.6); line-height: 1; letter-spacing: .02em; }
.ksd-navbar .nav-link { color: rgba(255,255,255,.82) !important; font-size: .875rem; font-weight: 500; padding: .45rem .8rem !important; border-radius: 6px; transition: all .18s; }
.ksd-navbar .nav-link:hover { color: var(--gold) !important; background: rgba(255,255,255,.06); }
.ksd-navbar .navbar-toggler { border-color: rgba(255,255,255,.3); }
.text-ksd { color: var(--blue) !important; }
.btn-nav-report {
  background: var(--gold); color: var(--blue-dark) !important;
  font-weight: 700; font-size: .82rem;
  padding: .45rem 1rem !important; border-radius: 6px;
  border: none; display: inline-flex; align-items: center; gap: .4rem;
  transition: background .18s, transform .18s;
}
.btn-nav-report:hover { background: #f0b030; transform: translateY(-1px); }

/* ── Footer ────────────────────────────────────────────────── */
.ksd-footer { background: var(--blue-dark); border-top: 3px solid var(--gold); color: rgba(255,255,255,.65); padding: 1rem 0; flex-shrink: 0; }

/* ── Flash alerts ──────────────────────────────────────────── */
.alert-dismissible { border-radius: 0; margin: 0; }

/* =============================================================
   HOME PAGE
   ============================================================= */

/* ── Hero ───────────────────────────────────────────────────── */
.hp-hero {
  background: linear-gradient(160deg, var(--blue-dark) 0%, var(--blue) 55%, var(--blue-mid) 100%);
  padding: 4rem 0 5rem;
  position: relative;
  overflow: hidden;
}
/* Diagonal stripe accent */
.hp-hero::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 70px;
  background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 20px;
  padding: .3rem .9rem;
  font-size: .78rem; font-weight: 600;
  color: rgba(255,255,255,.85);
  letter-spacing: .04em;
  margin-bottom: 1.2rem;
}
.hero-eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4cde80;
  box-shadow: 0 0 0 3px rgba(76,222,128,.28);
}
.hero-title {
  font-size: 3.2rem;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 900;
  color: #fff;
  line-height: 1.12;
  letter-spacing: -.025em;
  margin-bottom: 1rem;
}
.hero-title .accent { color: var(--gold); }
.hero-lead {
  font-size: 1.05rem;
  color: rgba(255,255,255,.75);
  max-width: 480px;
  margin-bottom: 2rem;
  line-height: 1.7;
}
/* Hero CTA buttons */
.btn-hero-gold {
  display: inline-flex; align-items: center; gap: .6rem;
  background: var(--gold); color: var(--blue-dark);
  font-weight: 800; font-size: .95rem;
  padding: .85rem 1.75rem;
  border-radius: var(--radius); border: none;
  text-decoration: none;
  box-shadow: 0 6px 24px rgba(232,160,32,.4);
  transition: all .2s;
}
.btn-hero-gold:hover { background: #f0b030; color: var(--blue-dark); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(232,160,32,.5); }
.btn-hero-outline {
  display: inline-flex; align-items: center; gap: .6rem;
  background: rgba(255,255,255,.1); color: #fff;
  font-weight: 600; font-size: .95rem;
  padding: .85rem 1.75rem;
  border-radius: var(--radius); border: 1.5px solid rgba(255,255,255,.28);
  text-decoration: none;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: all .2s;
}
.btn-hero-outline:hover { background: rgba(255,255,255,.18); color: #fff; transform: translateY(-2px); }
.hero-note { font-size: .78rem; color: rgba(255,255,255,.5); margin-top: .75rem; }
.hero-note a { color: var(--gold); text-decoration: none; }
.hero-note a:hover { text-decoration: underline; }

/* ── Hero tracker card ─────────────────────────────────────── */
.tracker-card {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-lg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.tracker-card-head {
  background: rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding: 1rem 1.4rem;
  font-size: .875rem; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: .5rem;
}
.tracker-card-body { padding: 1.4rem; }
.tracker-form {
  display: flex;
  background: rgba(255,255,255,.1);
  border: 1.5px solid rgba(255,255,255,.22);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.2rem;
  transition: border-color .2s;
}
.tracker-form:focus-within { border-color: var(--gold); }
.tracker-form input {
  flex: 1; background: none; border: none; outline: none;
  color: #fff; font-size: .9rem; font-weight: 500;
  padding: .85rem 1rem;
  font-family: 'Courier New', monospace;
  letter-spacing: .06em;
}
.tracker-form input::placeholder { color: rgba(255,255,255,.38); font-family: -apple-system, sans-serif; letter-spacing: 0; }
.tracker-form button {
  background: var(--gold); color: var(--blue-dark);
  border: none; padding: 0 1.25rem;
  font-size: .9rem; font-weight: 800;
  cursor: pointer; white-space: nowrap;
  transition: background .18s;
}
.tracker-form button:hover { background: #f0b030; }
/* Stat pills inside tracker */
.stat-pills { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat-pill {
  flex: 1; min-width: 0;
  background: rgba(0,0,0,.2);
  border-radius: 8px;
  padding: .65rem .5rem;
  text-align: center;
}
.stat-pill-val { font-size: 1.25rem; font-weight: 800; color: #fff; line-height: 1; }
.stat-pill-lbl { font-size: .62rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .07em; margin-top: .2rem; }

/* ── Stat strip ────────────────────────────────────────────── */
.stat-strip { background: #fff; border-bottom: 1px solid var(--border); }
.stat-strip-item { padding: 1.1rem .5rem; text-align: center; }
.stat-strip-icon { font-size: 1.4rem; margin-bottom: .3rem; }
.stat-strip-val { font-size: 1.5rem; font-weight: 900; color: var(--text); line-height: 1; }
.stat-strip-lbl { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .2rem; }

/* ── Section helpers ───────────────────────────────────────── */
.sec-tag {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue);
  font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .28rem .9rem;
  border-radius: 20px;
  margin-bottom: .6rem;
}
.sec-title { font-size: 2rem; font-size: clamp(1.5rem, 2.5vw, 2rem); font-weight: 800; color: var(--text); letter-spacing: -.02em; margin-bottom: .4rem; }
.sec-sub { color: var(--muted); max-width: 540px; }

/* ── Category cards ─────────────────────────────────────────── */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.cat-tile {
  display: flex; align-items: center; gap: .9rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  text-decoration: none; color: var(--text);
  position: relative; overflow: hidden;
  transition: all .2s;
  cursor: pointer;
}
.cat-tile::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--c);
  transform: scaleY(0); transition: transform .2s;
}
.cat-tile:hover { border-color: var(--c); box-shadow: 0 6px 20px rgba(0,0,0,.09); transform: translateY(-2px); color: var(--text); background: var(--bg); }
.cat-tile:hover::before { transform: scaleY(1); }
.cat-tile-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 10px;
  background: rgba(0,0,0,.06);
  color: var(--c);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  transition: all .2s;
}
.cat-tile:hover .cat-tile-icon { background: var(--c); color: #fff; }
.cat-tile-label { font-weight: 700; font-size: .88rem; line-height: 1.25; }
.cat-tile-sub { font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.cat-tile-count { margin-left: auto; flex-shrink: 0; font-size: .7rem; font-weight: 700; background: rgba(0,0,0,.06); color: var(--c); padding: .2rem .5rem; border-radius: 12px; }
.cat-tile-arrow { flex-shrink: 0; margin-left: .3rem; color: var(--muted); font-size: .75rem; opacity: 0; transform: translateX(-4px); transition: all .2s; }
.cat-tile:hover .cat-tile-arrow { opacity: 1; transform: translateX(0); }

/* Emergency tile */
.cat-tile-emergency { background: #fff5f5; border-color: #fdd; cursor: default; }
.cat-tile-emergency:hover { transform: none; box-shadow: none; border-color: #fdd; background: #fff5f5; }
.cat-tile-emergency::before { display: none; }

/* ── How it works ───────────────────────────────────────────── */
.steps-row { display: flex; gap: 0; position: relative; }
.steps-row::before {
  content: ''; position: absolute;
  top: 36px; left: calc(10% + 18px); right: calc(10% + 18px);
  height: 2px; background: var(--border);
}
.step {
  flex: 1; text-align: center; padding: 1.5rem .75rem;
  border-radius: var(--radius); transition: all .2s;
}
.step:hover { background: #fff; box-shadow: var(--shadow); transform: translateY(-3px); }
.step-circle {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin: 0 auto .9rem;
  position: relative; z-index: 1;
  background: #fff; border: 2px solid var(--c, var(--border));
  color: var(--c, var(--muted));
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.step:hover .step-circle { background: var(--c, var(--blue)); color: #fff; border-color: var(--c, var(--blue)); }
.step-num { font-size: .65rem; font-weight: 800; color: var(--muted); margin-bottom: .4rem; letter-spacing: .1em; text-transform: uppercase; }
.step-title { font-size: .88rem; font-weight: 700; margin-bottom: .3rem; }
.step-desc { font-size: .75rem; color: var(--muted); line-height: 1.5; }

/* ── Resolved feed ──────────────────────────────────────────── */
.resolved-list { display: flex; flex-direction: column; gap: .5rem; }
.resolved-row {
  display: flex; align-items: center; gap: .9rem;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem 1rem;
  transition: all .2s;
}
.resolved-row:hover { box-shadow: var(--shadow-sm); transform: translateX(3px); }
.resolved-row-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.resolved-row-body { flex: 1; min-width: 0; }
.resolved-row-title { font-weight: 600; font-size: .83rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resolved-row-meta { font-size: .7rem; color: var(--muted); margin-top: .1rem; }
.resolved-row-check { color: var(--green); font-size: 1.05rem; flex-shrink: 0; }
.badge-category { display: inline-block; font-size: .67rem; font-weight: 600; padding: .15rem .5rem; border-radius: 12px; }

/* ── Dark performance section ───────────────────────────────── */
.perf-section {
  background: var(--blue-dark);
  position: relative; overflow: hidden;
}
.perf-section::before {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0, rgba(255,255,255,.02) 1px, transparent 1px, transparent 40px),
              repeating-linear-gradient(0deg,  rgba(255,255,255,.02) 0, rgba(255,255,255,.02) 1px, transparent 1px, transparent 40px);
}
.perf-card {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius); padding: 1rem;
}
.perf-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.perf-name { font-size: .78rem; color: rgba(255,255,255,.8); font-weight: 600; }
.perf-pct { font-size: 1rem; font-weight: 800; color: #fff; }
.perf-bar { height: 6px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; margin-bottom: .4rem; }
.perf-fill { height: 100%; border-radius: 3px; }
.perf-sub { font-size: .68rem; color: rgba(255,255,255,.4); }
.perf-section .sec-tag { background: rgba(255,255,255,.1); color: rgba(255,255,255,.75); }
.perf-section .sec-title { color: #fff; }

/* ── CTA strip ──────────────────────────────────────────────── */
.cta-strip {
  background: var(--gold-light);
  border-top: 1px solid #f0d080;
  border-bottom: 1px solid #f0d080;
}

/* =============================================================
   INNER APP COMPONENTS
   ============================================================= */

/* Cards */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header-ksd { background: var(--blue); color: #fff; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0 !important; font-weight: 600; }

/* Stat cards */
.stat-card { border-radius: var(--radius); transition: transform .2s, box-shadow .2s; overflow: hidden; border: none; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon { font-size: 2.4rem; opacity: .15; position: absolute; right: 1.2rem; top: 50%; transform: translateY(-50%); }

/* Category selector (inside log form) */
.category-card { border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all .18s; text-align: center; padding: 1.1rem .75rem; background: #fff; }
.category-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow); }
.category-card.selected { border-color: var(--blue); background: var(--blue-light); }
.category-card .cat-icon { font-size: 1.75rem; margin-bottom: .4rem; }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: .6rem; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 1.4rem; }
.timeline-item::before { content: ''; position: absolute; left: -1.65rem; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--blue); }

/* Stars */
.star-rating .star { font-size: 1.8rem; cursor: pointer; color: #cbd5e1; transition: color .15s; }
.star-rating .star:hover, .star-rating .star.active { color: var(--gold); }

/* Priority */
.bg-orange { background-color: #f97316 !important; color: #fff; }

/* Table */
.table-ksd thead th { background: var(--blue); color: #fff; white-space: nowrap; font-weight: 600; font-size: .82rem; }

/* Forms */
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 .18rem rgba(13,56,117,.14); }

/* Reference badge */
.ref-badge { font-family: 'Courier New', monospace; background: var(--blue-light); border: 1px solid var(--border); border-radius: 5px; padding: .18rem .5rem; font-size: .8rem; letter-spacing: .05em; color: var(--blue); font-weight: 700; }

/* Auth */
.auth-card { max-width: 460px; margin: 3rem auto; }

/* Print */
@media print { .ksd-navbar, .ksd-footer, .no-print, .btn { display: none !important; } }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991px) { .steps-row { flex-wrap: wrap; } .steps-row::before { display: none; } .step { flex: 0 0 50%; } }
@media (max-width: 767px) {
  .hp-hero { padding: 2.5rem 0 4rem; }
  .hero-title { font-size: 1.9rem; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .stat-icon { display: none; }
}
@media (max-width: 480px) {
  .cat-grid { grid-template-columns: 1fr; }
  .btn-hero-gold, .btn-hero-outline { font-size: .88rem; padding: .75rem 1.2rem; }
  .step { flex: 0 0 100%; }
}

/* ── Mobile / Global App Responsiveness ─────────────────────── */
@media (max-width: 767px) {
  /* Reduce container padding on small screens */
  .container-fluid.px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }

  /* Page headers: stack title + action buttons vertically */
  .page-header-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: .75rem !important;
  }
  .page-header-row .d-flex.gap-2 { flex-wrap: wrap; }

  /* Stat cards: ensure readable size on mobile */
  .stat-card .card-body { padding: .75rem !important; }
  .stat-card .display-6 { font-size: 1.5rem !important; }
  .stat-card .h3 { font-size: 1.3rem !important; }

  /* Tables: smaller font on mobile so more fits */
  .table-responsive .table { font-size: .8rem; }
  .table-responsive .table th,
  .table-responsive .table td { padding: .4rem .5rem; }

  /* Ref badge smaller on mobile */
  .ref-badge { font-size: .7rem; }

  /* Action button groups in table rows */
  .table td .d-flex.gap-1 { flex-wrap: wrap; }

  /* Navbar: tighten logo area */
  .navbar-logo { width: 40px; height: 40px; }
  .brand-text .brand-name { font-size: .88rem; }

  /* Pagination: smaller on mobile */
  .pagination { flex-wrap: wrap; }

  /* Cards in report/dashboard grids */
  .card-body canvas { max-height: 220px; }

  /* Department accordion badges wrap */
  .dept-toggle .d-flex.gap-1 { gap: .25rem !important; }

  /* Auth cards: full width on very small screens */
  .auth-card { margin: 1.5rem auto; }
}

@media (max-width: 480px) {
  /* Full-width buttons in table action columns */
  .table td .btn { font-size: .75rem; padding: .25rem .4rem; }

  /* Reduce vertical padding on dashboard headers */
  .container-fluid.px-4.py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

  /* Stack d-flex justify-content-between headers */
  .d-flex.justify-content-between.align-items-center.mb-4 {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: .6rem !important;
  }
  .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex {
    width: 100%;
    flex-wrap: wrap;
  }
}
