/* ============================================================
   FlightManager — Design System & Layout
   ============================================================ */

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

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Sidebar */
  --fm-sidebar-w: 260px;
  --fm-sidebar-bg: #1a2744;
  --fm-sidebar-hover: #243352;
  --fm-sidebar-active: #2d3f66;
  --fm-sidebar-text: rgba(255,255,255,.75);
  --fm-sidebar-text-active: #ffffff;

  /* Accent */
  --fm-accent: #4f6ef7;
  --fm-accent-hover: #3b5de5;
  --fm-accent-light: rgba(79,110,247,.1);

  /* Surfaces */
  --fm-body-bg: #f4f6f9;
  --fm-card-bg: #ffffff;
  --fm-border: #e2e6ea;

  /* Text */
  --fm-text: #2d3748;
  --fm-text-muted: #718096;

  /* Status */
  --fm-success: #22c55e;
  --fm-danger: #ef4444;
  --fm-warning: #f59e0b;
  --fm-info: #06b6d4;

  /* Typography */
  --fm-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --fm-body-size: 14px;
  --fm-table-size: 13px;

  /* Misc */
  --fm-radius: 8px;
  --fm-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --fm-shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --fm-transition: .2s ease;
}

/* ---------- Dark mode overrides ---------- */
[data-bs-theme="dark"] {
  --fm-body-bg: #0f1724;
  --fm-card-bg: #1a2438;
  --fm-border: #2a3654;
  --fm-text: #e2e8f0;
  --fm-text-muted: #94a3b8;
  --fm-sidebar-bg: #0c1322;
  --fm-sidebar-hover: #162033;
  --fm-sidebar-active: #1e2d4a;
  --fm-shadow: 0 1px 3px rgba(0,0,0,.3);
  --fm-shadow-md: 0 4px 6px rgba(0,0,0,.25);
}

/* ---------- Base ---------- */
html, body {
  font-family: var(--fm-font);
  font-size: var(--fm-body-size);
  color: var(--fm-text);
  background: var(--fm-body-bg);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ---------- Layout Shell ---------- */
.fm-wrapper {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.fm-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--fm-sidebar-w);
  background: var(--fm-sidebar-bg);
  color: var(--fm-sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform var(--fm-transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.fm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: .02em;
  flex-shrink: 0;
}

.fm-sidebar-brand i {
  font-size: 1.35rem;
  color: var(--fm-accent);
}

.fm-sidebar-nav {
  list-style: none;
  padding: .5rem 0;
  margin: 0;
  flex: 1;
}

.fm-sidebar-nav li {
  margin: 2px 8px;
}

.fm-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  color: var(--fm-sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--fm-transition);
  position: relative;
}

.fm-sidebar-nav a:hover {
  background: var(--fm-sidebar-hover);
  color: var(--fm-sidebar-text-active);
}

.fm-sidebar-nav a.active {
  background: var(--fm-sidebar-active);
  color: var(--fm-sidebar-text-active);
}

.fm-sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--fm-accent);
}

.fm-sidebar-nav a i {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.fm-sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.1);
  margin: .75rem 1.25rem;
}

.fm-sidebar-footer {
  padding: .75rem 8px 1rem;
  flex-shrink: 0;
}

.fm-sidebar-footer a,
.fm-sidebar-footer .dropdown-toggle {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  color: var(--fm-sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--fm-transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.fm-sidebar-footer a:hover,
.fm-sidebar-footer .dropdown-toggle:hover {
  background: var(--fm-sidebar-hover);
  color: var(--fm-sidebar-text-active);
}

/* --- Main content area --- */
.fm-main {
  margin-left: var(--fm-sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.fm-content {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
}

/* --- Footer --- */
.fm-footer {
  padding: 1rem 2rem;
  text-align: center;
  color: var(--fm-text-muted);
  font-size: .8rem;
  border-top: 1px solid var(--fm-border);
  background: var(--fm-card-bg);
}

/* --- Mobile hamburger --- */
.fm-sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1050;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--fm-border);
  background: var(--fm-card-bg);
  color: var(--fm-text);
  font-size: 1.25rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--fm-shadow);
  transition: all var(--fm-transition);
}

.fm-sidebar-toggle:hover {
  background: var(--fm-accent);
  color: #fff;
  border-color: var(--fm-accent);
}

/* --- Sidebar overlay (mobile) --- */
.fm-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.45);
  z-index: 1035;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .fm-sidebar {
    transform: translateX(-100%);
  }

  .fm-sidebar.show {
    transform: translateX(0);
  }

  .fm-sidebar-overlay.show {
    display: block;
  }

  .fm-sidebar-toggle {
    display: flex;
  }

  .fm-main {
    margin-left: 0;
  }

  .fm-content {
    padding: 1rem 1rem 1.5rem;
    padding-top: 4rem; /* room for hamburger */
  }
}

/* ---------- Page Header ---------- */
.fm-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.fm-page-header h4 {
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0;
  color: var(--fm-text);
}

.fm-breadcrumb {
  font-size: .8rem;
  color: var(--fm-text-muted);
  margin-top: .15rem;
}

.fm-breadcrumb a {
  color: var(--fm-accent);
  text-decoration: none;
}

/* ---------- Cards ---------- */
.fm-card {
  background: var(--fm-card-bg);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
}

.fm-card .card-body {
  padding: 1.25rem;
}

/* --- Stat Cards --- */
.fm-stat-card {
  background: var(--fm-card-bg);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform var(--fm-transition), box-shadow var(--fm-transition);
  text-decoration: none;
  color: inherit;
}

.fm-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--fm-shadow-md);
  color: inherit;
  text-decoration: none;
}

.fm-stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.fm-stat-icon.indigo  { background: rgba(79,110,247,.12); color: #4f6ef7; }
.fm-stat-icon.blue    { background: rgba(59,130,246,.12); color: #3b82f6; }
.fm-stat-icon.teal    { background: rgba(6,182,212,.12);  color: #06b6d4; }
.fm-stat-icon.amber   { background: rgba(245,158,11,.12); color: #f59e0b; }
.fm-stat-icon.green   { background: rgba(34,197,94,.12);  color: #22c55e; }

.fm-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--fm-text);
}

.fm-stat-label {
  font-size: .8rem;
  color: var(--fm-text-muted);
  margin-top: .2rem;
}

/* ---------- DataTable Overrides ---------- */
.fm-table-card {
  background: var(--fm-card-bg);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  overflow: hidden;
}

.fm-table-card .card-body {
  padding: 0;
}

.fm-table-card table.dataTable {
  margin: 0 !important;
  font-size: var(--fm-table-size);
}

.fm-table-card table.dataTable thead th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--fm-text-muted);
  border-bottom: 2px solid var(--fm-border);
  padding: .75rem 1rem;
  white-space: nowrap;
}

[data-bs-theme="dark"] .fm-table-card table.dataTable thead th {
  background: #1e2d45;
  color: #94a3b8;
  border-bottom-color: #2a3654;
}

.fm-table-card table.dataTable tbody td {
  padding: .65rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--fm-border);
}

.fm-table-card table.dataTable tbody tr:hover {
  background: var(--fm-accent-light) !important;
}

.fm-table-card .dataTables_wrapper {
  padding: 0;
}

.fm-table-card .dataTables_wrapper .row:first-child,
.fm-table-card .dataTables_wrapper .row:last-child {
  padding: .75rem 1rem;
}

.fm-table-card .dataTables_wrapper .dataTables_processing {
  background: rgba(255,255,255,.85);
  z-index: 10;
}

[data-bs-theme="dark"] .fm-table-card .dataTables_wrapper .dataTables_processing {
  background: rgba(15,23,36,.85);
}

/* DataTable empty state */
.dataTables_empty {
  padding: 3rem 1rem !important;
  color: var(--fm-text-muted);
  font-size: .95rem;
}

/* Action buttons in table */
.fm-actions {
  white-space: nowrap;
  display: flex;
  gap: .35rem;
}

.fm-actions .btn {
  padding: .25rem .5rem;
  font-size: .8rem;
  line-height: 1;
  border-radius: 5px;
}

/* ---------- Modals ---------- */
.modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0,0,0,.15);
}

.modal-header {
  border-bottom: 1px solid var(--fm-border);
  padding: 1rem 1.5rem;
}

.modal-header .modal-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--fm-border);
  padding: .75rem 1.5rem;
}

/* ---------- Toast Container ---------- */
.fm-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 380px;
}

.fm-toast-container .toast {
  border: none;
  border-radius: 8px;
  box-shadow: var(--fm-shadow-md);
  font-size: .875rem;
}

/* ---------- Forms ---------- */
.form-label {
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .35rem;
  color: var(--fm-text);
}

.form-control,
.form-select {
  font-size: .875rem;
  border-radius: 6px;
  border-color: var(--fm-border);
  padding: .5rem 1.50rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--fm-accent);
  box-shadow: 0 0 0 3px var(--fm-accent-light);
}

.form-text {
  font-size: .78rem;
}

/* ---------- Badges ---------- */
.badge {
  font-weight: 600;
  font-size: .72rem;
  padding: .35em .65em;
  border-radius: 5px;
  letter-spacing: .02em;
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--fm-accent);
  border-color: var(--fm-accent);
}

.btn-primary:hover {
  background: var(--fm-accent-hover);
  border-color: var(--fm-accent-hover);
}

/* ---------- Delete Confirm Modal ---------- */
#deleteConfirmModal .modal-body {
  text-align: center;
  padding: 2rem 1.5rem;
}

#deleteConfirmModal .bi-exclamation-triangle-fill {
  font-size: 2.5rem;
  color: var(--fm-danger);
}

/* ---------- Spinner overlay for tables ---------- */
.fm-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  border-radius: var(--fm-radius);
}

[data-bs-theme="dark"] .fm-loading-overlay {
  background: rgba(15,23,36,.7);
}

/* ---------- Scrollbar (sidebar) ---------- */
.fm-sidebar::-webkit-scrollbar {
  width: 4px;
}

.fm-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.fm-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.15);
  border-radius: 4px;
}

/* ---------- Quick Action Buttons ---------- */
.fm-quick-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.fm-quick-actions .btn {
  font-size: .875rem;
  font-weight: 500;
  padding: .5rem 1.25rem;
  border-radius: 6px;
}

/* ---------- Auth pages (centered layout) ---------- */
.fm-auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fm-body-bg);
  padding: 2rem 1rem;
}

.fm-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--fm-card-bg);
  border: 1px solid var(--fm-border);
  border-radius: 12px;
  box-shadow: var(--fm-shadow-md);
  padding: 2.5rem 2rem;
}

.fm-auth-card .fm-auth-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.fm-auth-card .fm-auth-brand i {
  font-size: 2rem;
  color: var(--fm-accent);
}

.fm-auth-card .fm-auth-brand h4 {
  font-weight: 700;
  margin-top: .5rem;
}
