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

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;
  --info: #0ea5e9;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* Base layouts */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.2s ease;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  padding: 1.75rem 0;
  font-size: 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links a {
  color: var(--muted);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.container-narrow,
.container-wide {
  width: min(100% - 2.5rem, 1080px);
  margin-inline: auto;
}

.container-wide {
  width: min(100% - 2.5rem, 1280px);
}

.page-band {
  padding: 1.5rem 0;
}

.page-title {
  font-size: 2.2rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.page-copy {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-top: 0.75rem;
}

.eyebrow {
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  margin-bottom: 1rem;
  border-left: 3px solid var(--primary);
  padding-left: 0.5rem;
}

/* Surfaces */
.form-surface,
.toolbar,
.table-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.form-surface {
  padding: 2.5rem; /* Increased padding for spacious feel */
  margin-top: 1.5rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}

/* Grid & Flex */
.grid {
  display: grid;
}

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

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

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

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1.5rem; /* Increased gap for better breathing room */
}

.flex {
  display: flex;
}

.block {
  display: block;
}

.wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-5 {
  margin-top: 1.5rem;
}

.mt-6 {
  margin-top: 2rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 2rem;
}

/* Width utilities to replace inline max-widths */
.w-xs {
  max-width: 200px !important;
  width: 100%;
}
.w-sm {
  max-width: 320px !important;
  width: 100%;
}
.w-md {
  max-width: 480px !important;
  width: 100%;
}
.w-lg {
  max-width: 640px !important;
  width: 100%;
}
.w-xl {
  max-width: 800px !important;
  width: 100%;
}
.w-full {
  max-width: 100% !important;
  width: 100%;
}

/* Form Elements */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem; /* Better breathing room between form rows */
}

.field label {
  display: block;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}

.input {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 0.65rem 0.95rem;
  outline: none;
  font-size: 0.95rem;
  transition: all 0.15s ease-in-out;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.input:disabled,
.input[disabled],
.input[readonly],
select:disabled,
input:disabled {
  background-color: #f8fafc !important;
  color: var(--muted) !important;
  border-color: var(--line) !important;
  cursor: not-allowed;
}

.file-input {
  padding: 0.5rem;
  cursor: pointer;
}

.select {
  composes: input;
}

.text-uppercase {
  text-transform: uppercase;
}

.text-right {
  text-align: right;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1.25rem;
  transition: all 0.15s ease-in-out;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--surface-muted);
  border-color: var(--muted);
}

.btn-small {
  min-height: 2.25rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 6px;
}

.field-error,
.validation-summary {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.35rem;
}

/* Alerts */
.alert {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
}

.alert-danger {
  color: #7a1515;
  background: #fef2f2;
  border-color: #fca5a5;
}

.alert-success {
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.alert-info {
  color: #1e3a8a;
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* Stepper - Modernized Minimal Style */
.stepper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 2px solid var(--line);
  padding-bottom: 1.25rem;
}

.step {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 0.825rem;
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  position: relative;
  transition: all 0.2s ease;
}

.step::after {
  content: '';
  position: absolute;
  bottom: -1.35rem;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
  border-radius: 2px;
  transition: all 0.2s ease;
}

.step.is-active {
  color: var(--primary);
  font-weight: 700;
}

.step.is-active::after {
  background: var(--primary);
}

.step.is-done {
  color: var(--success);
}

.step.is-done::after {
  background: var(--success);
}

/* Tables */
.table-shell {
  overflow-x: auto;
  margin-top: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 1.25rem;
  vertical-align: middle;
  font-size: 0.925rem;
}

.data-table th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fafafb;
}

.data-table tr:hover td {
  background: var(--bg);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: #065f46;
  background: #d1fae5;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 4rem 2rem;
  font-size: 1.05rem;
}

/* Responsive Stepper and Form layout */
@media (max-width: 1024px) {
  .stepper {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
  }
  .step {
    flex: 0 0 150px;
  }
}

@media (max-width: 768px) {
  .page-band {
    padding: 1.5rem 0;
  }

  .page-title {
    font-size: 1.8rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-surface {
    padding: 1.5rem 1rem;
  }

  .nav-links {
    width: 100%;
    justify-content: center;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================================================
   APPLICATION DASHBOARD LAYOUT (CITIZEN / STAFF)
   ========================================================= */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.app-sidebar {
  width: 270px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  gap: 0.85rem;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1.1rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.sidebar-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: 70px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-profile {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.2);
}

.app-content {
  padding: 2.5rem;
  flex: 1;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  padding: 0.5rem;
}

@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: block;
  }

  .app-header {
    padding: 0 1.5rem;
  }

  .app-content {
    padding: 1.5rem 1.1rem;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 15;
    backdrop-filter: blur(4px);
  }

  .sidebar-overlay.open {
    display: block;
  }
}