/* ============================================================
   Desert Sand Aircraft Leasing — Modern UI
   Theme: Industrial Aviation Dark
   Fonts: Barlow Condensed (headings) + DM Sans (body) + DM Mono (data)
   ============================================================ */

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

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:           #0f1117;
  --bg-panel:     #181c26;
  --bg-card:      #1e2333;
  --bg-hover:     #252b3b;
  --border:       #2a3045;
  --border-light: #333d58;

  --amber:        #f5a623;
  --amber-dim:    #a06d12;
  --amber-glow:   rgba(245,166,35,0.12);
  --red:          #e8453c;
  --red-dim:      rgba(232,69,60,0.15);
  --green:        #2ecc71;
  --green-dim:    rgba(46,204,113,0.12);
  --blue:         #4a9eff;
  --blue-dim:     rgba(74,158,255,0.12);

  --text:         #e4e8f0;
  --text-muted:   #7a8399;
  --text-dim:     #4a5268;

  --sidebar-w:    220px;
  --header-h:     56px;
  --radius:       6px;
  --radius-lg:    10px;

  --shadow:       0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.6);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
a { color: var(--amber); text-decoration: none; }
a:hover { color: #ffc84a; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Layout Shell ──────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "sidebar header" "sidebar main";
  height: 100vh;
}

/* ── Header ────────────────────────────────────────────── */
#header {
  grid-area: header;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}
#header-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
}
#header-user {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-muted);
}
#header-user strong { color: var(--text); }
#header-date {
  font-family: 'DM Mono', monospace;
  font-size: 12px; color: var(--text-dim);
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 4px 12px; border-radius: var(--radius);
  font-size: 12px; transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── Hamburger — hidden on desktop ─────────────────────── */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}
.nav-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ── Nav overlay — hidden by default ───────────────────── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 149;
}
.nav-overlay.open { display: block; }

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
#sidebar-logo {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--amber); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark svg { width: 18px; height: 18px; fill: #0f1117; }
.logo-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800; font-size: 15px;
  letter-spacing: 0.05em; text-transform: uppercase; line-height: 1.1;
}
.logo-text span { display: block; color: var(--text-muted); font-weight: 400; font-size: 10px; letter-spacing: 0.08em; }

#nav { flex: 1; padding: 8px 0; }
.nav-section-label {
  padding: 14px 16px 4px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  border-left: 2px solid transparent;
  transition: all 0.15s; cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); border-left-color: var(--border-light); }
.nav-item.active { background: var(--amber-glow); color: var(--amber); border-left-color: var(--amber); }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 99px;
  font-family: 'DM Mono', monospace;
}
.nav-badge.amber { background: var(--amber); color: #0f1117; }

/* ── Main Content ───────────────────────────────────────── */
#main { grid-area: main; overflow-y: auto; padding: 24px; background: var(--bg); }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase; line-height: 1;
}
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-family: 'DM Mono', monospace; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-light); }
.stat-card.urgent { border-color: var(--red); background: var(--red-dim); }
.stat-card.warning { border-color: var(--amber-dim); background: var(--amber-glow); }
.stat-card.good { border-color: var(--green); background: var(--green-dim); }
.stat-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.stat-value { font-family: 'Barlow Condensed', sans-serif; font-size: 36px; font-weight: 700; line-height: 1; }
.stat-card.urgent .stat-value { color: var(--red); }
.stat-card.warning .stat-value { color: var(--amber); }
.stat-card.good .stat-value { color: var(--green); }
.stat-meta { font-size: 11px; color: var(--text-muted); }

/* ── Data Tables ─────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24px;
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}
.table-toolbar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-panel); padding: 8px 12px;
  text-align: left; font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 9px 12px; font-size: 13px; white-space: nowrap; }
.mono { font-family: 'DM Mono', monospace; font-size: 12px; }
tr.overdue { background: var(--red-dim) !important; }
tr.overdue:hover { background: rgba(232,69,60,0.22) !important; }
tr.warning-row { background: var(--amber-glow) !important; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; font-family: 'DM Mono', monospace;
}
.badge-red   { background: var(--red-dim);    color: var(--red);   border: 1px solid var(--red); }
.badge-amber { background: var(--amber-glow); color: var(--amber); border: 1px solid var(--amber-dim); }
.badge-green { background: var(--green-dim);  color: var(--green); border: 1px solid var(--green); }
.badge-blue  { background: var(--blue-dim);   color: var(--blue);  border: 1px solid var(--blue); }
.badge-muted { background: var(--bg);         color: var(--text-muted); border: 1px solid var(--border); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid transparent; transition: all 0.15s;
}
.btn-primary   { background: var(--amber); color: #0f1117; border-color: var(--amber); }
.btn-primary:hover { background: #ffc84a; border-color: #ffc84a; }
.btn-secondary { background: transparent; color: var(--text-muted); border-color: var(--border-light); }
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger    { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn svg { width: 13px; height: 13px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg); border: 1px solid var(--border-light);
  color: var(--text); padding: 7px 10px;
  border-radius: var(--radius); font-size: 13px;
  transition: border-color 0.15s; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-glow);
}
.form-group select option { background: var(--bg-card); }
.form-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
}
.form-section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
.add-row td { background: var(--bg-panel); padding: 6px 12px; }
.add-row input, .add-row select {
  background: var(--bg); border: 1px solid var(--border-light);
  color: var(--text); padding: 5px 8px;
  border-radius: var(--radius); font-size: 12px; width: 100%;
}
.add-row input:focus, .add-row select:focus { outline: none; border-color: var(--amber); }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select {
  background: var(--bg); border: 1px solid var(--border-light);
  color: var(--text); padding: 6px 10px;
  border-radius: var(--radius); font-size: 12px;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--amber); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(2px); animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; line-height: 1; padding: 0; transition: color 0.15s; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ── Toasts ──────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 10px 16px; font-size: 13px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.2s ease; max-width: 320px;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.success::before { content: '✓'; color: var(--green); font-weight: 700; }
.toast.error::before   { content: '✕'; color: var(--red);   font-weight: 700; }

/* ── Pilot note ──────────────────────────────────────────── */
.pilot-note {
  background: var(--amber-glow); border: 1px solid var(--amber-dim);
  border-left: 3px solid var(--amber); border-radius: var(--radius);
  padding: 12px 16px; font-size: 13px; margin-bottom: 20px; white-space: pre-wrap;
}
.pilot-note-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); margin-bottom: 4px; }

/* ── Empty state / Loading ───────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-dim); }
.empty-state p { font-size: 14px; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.6s linear infinite; margin: 48px auto; }
.loading-row td { text-align: center; padding: 32px; color: var(--text-dim); }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
@keyframes spin    { to { transform: rotate(360deg) } }

/* ── Login page ──────────────────────────────────────────── */
#login-page {
  height: 100vh; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
#login-page::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 50%, rgba(245,166,35,0.06) 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 39px, var(--border) 39px, var(--border) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, var(--border) 39px, var(--border) 40px);
  opacity: 0.4;
}
.login-card {
  position: relative; z-index: 1;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 40px; width: 100%; max-width: 380px;
  animation: slideUp 0.3s ease;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-logo-mark { width: 44px; height: 44px; background: var(--amber); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.login-logo-mark svg { width: 24px; height: 24px; fill: #0f1117; }
.login-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 22px; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.1; }
.login-title span { display: block; font-size: 12px; font-weight: 400; color: var(--text-muted); letter-spacing: 0.1em; }
.login-card .form-group { margin-bottom: 16px; }
.login-card label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 6px; }
.login-card input { width: 100%; background: var(--bg); border: 1px solid var(--border-light); color: var(--text); padding: 10px 14px; border-radius: var(--radius); font-size: 14px; transition: border-color 0.15s; }
.login-card input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-glow); }
.login-btn { width: 100%; padding: 11px; background: var(--amber); color: #0f1117; border: none; border-radius: var(--radius); font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; transition: background 0.15s; margin-top: 8px; }
.login-btn:hover { background: #ffc84a; }
.login-error { background: var(--red-dim); border: 1px solid var(--red); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; color: var(--red); margin-bottom: 16px; display: none; }
.login-error.show { display: block; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Date picker icon ────────────────────────────────────── */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.7;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ── Datalist typeahead ──────────────────────────────────── */
input[list] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8399' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ── Remove spinner arrows from number inputs ────────────── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* ── Hide datalist elements ──────────────────────────────── */
datalist { display: none; }

/* ============================================================
   Mobile Responsive Styles
   ============================================================ */

@media (max-width: 768px) {

  /* Body scrollable on mobile */
  body { overflow: auto; }

  /* Show hamburger */
  .nav-toggle { display: flex; align-items: center; }

  /* App layout — stack vertically */
  #app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* Sidebar slides in from left */
#sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    height: 100vh;
    z-index: 150;
    transition: left 0.25s ease;
    width: 240px !important;
    overflow-y: auto;
    background: var(--bg-panel) !important;
    box-shadow: 4px 0 20px rgba(0,0,0,0.6);
    display: flex !important;
    flex-direction: column !important;
  }

  #sidebar.open { left: 0; }

  /* Header full width */
  #header {
    padding: 0 12px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: nowrap;
  }

#sidebar #nav {
    flex: 1;
    overflow-y: auto;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #sidebar .nav-item {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #sidebar #sidebar-logo {
    display: flex !important;
  }

  #header-title {
    font-size: 14px !important;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Hide date on mobile */
  #header-date { display: none; }

  /* Shrink header user info */
  #header-user {
    gap: 6px !important;
    font-size: 11px;
  }

  /* Main content full width */
  #main {
    padding: 12px !important;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start !important;
    margin-bottom: 16px;
  }

  .page-title { font-size: 22px !important; }

  /* Form grid — single column on mobile */
  .form-grid { grid-template-columns: 1fr !important; }

  .form-group[style*="grid-column"] { grid-column: 1 !important; }

  /* Tables — horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table { min-width: 480px; }

  /* Table toolbar wrap */
  .table-toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start !important;
  }

  .table-actions { flex-wrap: wrap; gap: 6px; }

  /* Stat grid — 2 columns on mobile */
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Form actions */
  .form-actions {
    flex-direction: column;
    gap: 8px;
  }

  .form-actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    box-sizing: border-box;
  }

  /* Buttons in page header */
  .page-header > div:last-child {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .page-header > div:last-child .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* Modal */
  .modal {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 88vh;
    margin: 6vh auto 0;
    overflow-y: auto;
  }

  .modal-backdrop {
    align-items: flex-start;
    padding-top: 20px;
  }

  /* Weekly usage grid — single column */
  #wu-results > div[style*="grid"] {
    grid-template-columns: 1fr !important;
  }

  /* Reduce padding on form sections */
  .form-section { padding: 12px !important; }

  /* Toast at bottom center on mobile */
  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast { max-width: 100%; }

}