/* ==========================================================================
   Namma Vayu Vajra portal - Design tokens & base styles
   ========================================================================== */
:root {
  --primary: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --violet: #2563eb;
  --fuchsia: #06b6d4;
  --accent: #06b6d4;
  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --danger: #ef4444;
  --danger-50: #fef2f2;
  --info: #3b82f6;
  --info-50: #eff6ff;
  --secondary: #64748b;
  --secondary-50: #f1f5f9;

  --gradient-primary: linear-gradient(135deg, #06b6d4 0%, #0ea5e9 45%, #2563eb 100%);
  --gradient-ocean: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-emerald: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
  --gradient-sunset: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  --gradient-rose: linear-gradient(135deg, #f43f5e 0%, #ec4899 100%);
  --gradient-slate: linear-gradient(135deg, #475569 0%, #1e293b 100%);

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e7eaf3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .14);
  --shadow-primary: 0 10px 25px -8px rgba(14, 165, 233, .55);

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Poppins', 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --sidebar-width: 264px;
  --sidebar-collapsed: 84px;
  --topbar-height: 70px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .poppins-font {
  font-family: var(--font-heading);
  color: var(--text);
  letter-spacing: -.01em;
}

a { color: var(--primary-600); text-decoration: none; transition: color .2s; }
a:hover { color: var(--violet); }

::selection { background: var(--primary-100); color: var(--primary-700); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

.text-muted { color: var(--muted) !important; }
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }

/* ---------- Page header (list screens) ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-header-title h4 { margin: 0; font-size: 22px; font-weight: 600; }
.page-header-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-header-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Cards ---------- */
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .3s var(--ease), transform .3s var(--ease), border-color .3s;
}
.app-card.hoverable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--primary-100);
}
.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.app-card-header h6 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.app-card-body { padding: 20px; }

.icon-chip {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 8px 18px -8px currentColor;
}
.icon-chip.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
.chip-primary { background: var(--gradient-primary); }
.chip-ocean { background: var(--gradient-ocean); }
.chip-emerald { background: var(--gradient-emerald); }
.chip-sunset { background: var(--gradient-sunset); }
.chip-rose { background: var(--gradient-rose); }
.chip-slate { background: var(--gradient-slate); }

/* ---------- Buttons ---------- */
.btn {
  font-weight: 500;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .2s var(--ease), box-shadow .25s var(--ease), background .25s, color .2s, border-color .2s;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(.97); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-gradient {
  background: var(--gradient-primary);
  background-size: 160% 160%;
  color: #fff;
  border: 0;
  box-shadow: var(--shadow-primary);
}
.btn-gradient:hover {
  color: #fff;
  background-position: 100% 50%;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -10px rgba(37, 99, 235, .7);
}
.btn-gradient:focus-visible { color: #fff; }
.btn-light-soft {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-light-soft:hover { border-color: var(--primary-100); color: var(--primary-600); background: var(--primary-50); }
.btn-soft-primary { background: var(--primary-50); color: var(--primary-600); border: 0; }
.btn-soft-primary:hover { background: var(--primary); color: #fff; }
.btn-soft-success { background: var(--success-50); color: #059669; border: 0; }
.btn-soft-success:hover { background: var(--success); color: #fff; }
.btn-soft-warning { background: var(--warning-50); color: #b45309; border: 0; }
.btn-soft-warning:hover { background: var(--warning); color: #fff; }
.btn-soft-danger { background: var(--danger-50); color: #dc2626; border: 0; }
.btn-soft-danger:hover { background: var(--danger); color: #fff; }
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s var(--ease);
}
.btn-icon:hover { background: var(--primary-50); color: var(--primary-600); transform: translateY(-1px); }
.btn-icon.danger:hover { background: var(--danger-50); color: var(--danger); }
.btn-icon.success:hover { background: var(--success-50); color: var(--success); }
.btn-icon.warning:hover { background: var(--warning-50); color: #b45309; }

.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  transform: scale(0);
  animation: ripple .6s linear;
  pointer-events: none;
}

.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-light-soft.is-loading::after,
.btn-soft-primary.is-loading::after { border-color: var(--primary-100); border-top-color: var(--primary); }

/* ---------- Forms ---------- */
.form-label { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control,
.form-select {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  color: var(--text);
  background-color: var(--surface);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.form-control::placeholder { color: var(--muted-2); }
.form-control:hover,
.form-select:hover { border-color: #cfd5e6; }
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, .14);
}
.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(239, 68, 68, .1); }
.invalid-feedback { font-size: 12px; animation: fadeDown .25s var(--ease); }
.input-icon { position: relative; }
.input-icon > i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
  transition: color .2s;
}
.input-icon > .form-control,
.input-icon > .form-select { padding-left: 38px; }
.input-icon:focus-within > i { color: var(--primary); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(14, 165, 233, .14); border-color: var(--primary); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; cursor: pointer; }

/* ---------- Filter bar ---------- */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}
.filter-bar .row { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }

.segmented {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 2px;
  position: relative;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .25s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.segmented button:hover { color: var(--primary-600); }
.segmented button.active { background: var(--gradient-primary); color: #fff; box-shadow: var(--shadow-primary); }
.segmented .count {
  font-size: 11px;
  background: rgba(100, 116, 139, .15);
  padding: 1px 7px;
  border-radius: 20px;
}
.segmented button.active .count { background: rgba(255, 255, 255, .25); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.app-table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.app-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.app-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.app-table tbody tr { transition: background .2s; animation: rowIn .45s var(--ease) both; }
.app-table tbody tr:hover { background: #f5fbff; }
.app-table tbody tr:last-child td { border-bottom: 0; }
.app-table tbody tr.clickable { cursor: pointer; }
.app-table .cell-title { font-weight: 600; color: var(--text); }
.app-table .cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.app-table .actions { white-space: nowrap; text-align: right; }
.app-table tr.row-danger { background: #fff7f7; }

.code-pill {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-600);
  background: var(--primary-50);
  padding: 3px 9px;
  border-radius: 7px;
  letter-spacing: .02em;
}

/* ---------- Status badges (with pulse dot) ---------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 30px;
  white-space: nowrap;
}
.badge-status .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
}
.badge-status .pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  animation: pulseRing 1.8s ease-out infinite;
}
.badge-success { background: var(--success-50); color: #059669; }
.badge-primary { background: var(--primary-50); color: var(--primary-600); }
.badge-warning { background: var(--warning-50); color: #b45309; }
.badge-danger { background: var(--danger-50); color: #dc2626; }
.badge-info { background: var(--info-50); color: #2563eb; }
.badge-secondary { background: var(--secondary-50); color: #475569; }
.badge-secondary .pulse::after { animation: none; }

/* ---------- Avatar ---------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  font-family: var(--font-heading);
}
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-0 { background: var(--gradient-primary); }
.avatar-1 { background: var(--gradient-ocean); }
.avatar-2 { background: var(--gradient-emerald); }
.avatar-3 { background: var(--gradient-sunset); }
.avatar-4 { background: var(--gradient-rose); }
.avatar-5 { background: var(--gradient-slate); }
.person { display: flex; align-items: center; gap: 10px; }

/* ---------- Detail list ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.detail-item label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.detail-item div { font-weight: 500; color: var(--text); word-break: break-word; }

/* ---------- Progress bar ---------- */
.progress-thin { height: 8px; background: var(--secondary-50); border-radius: 8px; overflow: hidden; }
.progress-thin > span {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: var(--gradient-primary);
  width: 0;
  transition: width 1.1s var(--ease);
}

/* ---------- Dropdowns ---------- */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: scaleIn .18s var(--ease);
  transform-origin: top right;
}
.dropdown-item { border-radius: 8px; padding: 8px 12px; font-size: 13.5px; display: flex; align-items: center; gap: 10px; }
.dropdown-item:hover { background: var(--primary-50); color: var(--primary-600); }
.dropdown-item.text-danger:hover { background: var(--danger-50); }

/* ---------- Utilities ---------- */
.stagger > * { animation: fadeUp .6s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .13s; }
.stagger > *:nth-child(4) { animation-delay: .18s; }
.stagger > *:nth-child(5) { animation-delay: .23s; }
.stagger > *:nth-child(6) { animation-delay: .28s; }
.stagger > *:nth-child(7) { animation-delay: .33s; }
.stagger > *:nth-child(8) { animation-delay: .38s; }
.stagger > *:nth-child(n+9) { animation-delay: .42s; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.empty-dash { color: var(--muted-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .app-sidebar-nav, .app-topbar, .no-print, .page-header-actions { display: none !important; }
  .app-main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; }
}
