/* ==========================================================================
   AI SMART LOCAL AGENT — Citizen Dashboard Styles
   Midnight Navy · Electric Blue & Cyan · Glassmorphic Cards & Charts
   ========================================================================== */

.dash-main {
  margin-top: calc(var(--nav-height) + 24px);
  margin-bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.is-hidden {
  display: none !important;
}

/* ==========================================================================
   WELCOME HERO & QUICK ACTIONS
   ========================================================================== */

.dash-hero {
  padding: 26px;
  background: linear-gradient(135deg, rgba(12, 20, 39, 0.84), rgba(15, 23, 42, 0.72));
  border-color: rgba(56, 189, 248, 0.24);
}

.dash-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-title {
  margin: 12px 0 8px;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.dash-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.96rem;
  max-width: 640px;
}

.backend-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--glass-border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.backend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.backend-status-pill.is-online {
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.backend-status-pill.is-online .backend-dot {
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}

.backend-status-pill.is-offline {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.backend-status-pill.is-offline .backend-dot {
  background: #f59e0b;
}

.dash-demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(124, 58, 237, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.22);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.dash-demo-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: var(--accent-cyan-bright);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.dash-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */

.dash-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-pill);
  background: rgba(10, 17, 34, 0.72);
  border: 1px solid var(--glass-border);
  width: fit-content;
  max-width: 100%;
}

.dash-tab {
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-tab:hover {
  color: var(--text-primary);
}

.dash-tab.is-active {
  background: var(--grad-primary);
  color: #ffffff;
  box-shadow: 0 6px 18px -6px rgba(6, 182, 212, 0.55);
}

.dash-panel {
  display: none;
  animation: panelFade 220ms var(--ease-out);
}

.dash-panel.is-active {
  display: block;
}

@keyframes panelFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   OVERVIEW STATS & CHARTS
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 20px;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--glass-border-hover);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.stat-icon--blue { background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
.stat-icon--amber { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.stat-icon--cyan { background: rgba(34, 211, 238, 0.16); color: #22d3ee; }
.stat-icon--emerald { background: rgba(16, 185, 129, 0.16); color: #34d399; }

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chart-card {
  padding: 22px;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.chart-title {
  margin: 0 0 4px;
  font-size: 1.08rem;
  font-weight: 700;
}

.chart-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Horizontal Bar Chart */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 650ms var(--ease-out);
}

/* SVG Donut Chart */
.donut-wrap {
  position: relative;
  width: 156px;
  height: 156px;
  margin: 8px auto 16px;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-track {
  fill: none;
  stroke: rgba(30, 41, 59, 0.9);
  stroke-width: 12;
}

.donut-ring {
  fill: none;
  stroke: url(#donutGrad);
  stroke: #22d3ee;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 800ms var(--ease-out);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-percent {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

.donut-label {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.donut-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ==========================================================================
   COMPLAINTS TABLE & FILTERS
   ========================================================================== */

.complaints-card {
  padding: 22px;
}

.section-heading {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.complaints-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.complaints-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dash-input,
.dash-select {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.dash-input:focus,
.dash-select:focus {
  border-color: var(--accent-cyan-bright);
}

.dash-input:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.table-scroll {
  overflow-x: auto;
}

.complaints-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.complaints-table th,
.complaints-table td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 0.88rem;
}

.complaints-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.complaints-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.complaints-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.06);
}

.id-mono {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan-bright);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-pill--submitted { background: rgba(148, 163, 184, 0.16); color: #e2e8f0; }
.status-pill--verified { background: rgba(167, 139, 250, 0.18); color: #ddd6fe; }
.status-pill--in_progress { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.status-pill--resolved { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
}

/* ==========================================================================
   COMPLAINT TRACKING TIMELINE
   ========================================================================== */

.tracking-card {
  padding: 24px;
}

.tracking-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.tracking-meta {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.tracking-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.timeline-progress-wrap {
  position: relative;
  margin-bottom: 28px;
}

.timeline-bar-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  overflow: hidden;
  margin-bottom: 18px;
}

.timeline-bar-fill {
  height: 100%;
  width: 25%;
  border-radius: 999px;
  background: var(--grad-primary);
  transition: width 450ms var(--ease-out);
}

.timeline-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.timeline-step {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.55);
}

.timeline-step.is-done {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.08);
}

.timeline-step-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.timeline-step-date {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.updates-heading {
  margin: 0 0 12px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.updates-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.update-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.65);
  border-left: 3px solid var(--accent-cyan-bright);
  font-size: 0.88rem;
}

.update-item-time {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

/* ==========================================================================
   PROFILE & SETTINGS
   ========================================================================== */

.profile-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
}

.profile-card,
.settings-card {
  padding: 24px;
}

.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.profile-sub {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.profile-form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.profile-toast {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  font-size: 0.82rem;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.setting-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  font-size: 0.88rem;
  cursor: pointer;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.9);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform var(--transition-fast);
}

.toggle-input:checked + .toggle-track {
  background: var(--accent-cyan);
}

.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* ==========================================================================
   MODAL
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 5, 10, 0.78);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(520px, 100%);
  padding: 22px;
  background: rgba(10, 17, 34, 0.96);
  border-color: rgba(56, 189, 248, 0.32);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 6px 0 0;
  font-size: 1.25rem;
}

.modal-close {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .timeline-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .dash-hero {
    padding: 18px;
  }

  .stats-grid,
  .profile-form,
  .timeline-steps {
    grid-template-columns: 1fr;
  }

  .dash-tabs {
    width: 100%;
    border-radius: var(--radius-md);
  }

  .dash-tab {
    flex: 1 1 auto;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dash-panel,
  .bar-fill,
  .donut-ring,
  .timeline-bar-fill {
    animation: none;
    transition: none;
  }
}
