/* FineBright design system — works with Bootstrap 5.3 (RTL + LTR, light + dark).
   All colors flow through tokens; components use logical properties so the same
   rules serve both text directions. */

:root {
  --fb-font: 'Cairo', 'Segoe UI', system-ui, sans-serif;
  --fb-radius: .75rem;
  --fb-radius-sm: .5rem;
  --fb-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --fb-shadow-lg: 0 8px 30px rgba(15, 23, 42, .12);
  --fb-speed: .18s;

  --fb-bg: #f1f5f9;
  --fb-surface: #ffffff;
  --fb-border: #dde3ec;
  --fb-text: #0a0f1a;
  --fb-muted: #3d4a5f;
  --fb-primary: #2563eb;
  --fb-primary-ink: #1d4ed8;
  --fb-sidebar-bg: #0f172a;
  --fb-sidebar-text: #cbd5e1;
  --fb-sidebar-hover: rgba(148, 163, 184, .14);
  --fb-sidebar-active: #2563eb;
  --fb-topbar-bg: rgba(255, 255, 255, .85);
  --fb-link: #1d4ed8;
  --fb-link-hover: #1e40af;
  --bs-body-bg: var(--fb-bg);
  --bs-body-color: var(--fb-text);
}

[data-bs-theme="dark"] {
  --fb-bg: #0b1220;
  --fb-surface: #101a2c;
  --fb-border: #1e2b42;
  --fb-text: #e2e8f0;
  --fb-muted: #94a3b8;
  --fb-primary: #3b82f6;
  --fb-primary-ink: #60a5fa;
  --fb-sidebar-bg: #0a101d;
  --fb-sidebar-text: #94a3b8;
  --fb-sidebar-hover: rgba(148, 163, 184, .10);
  --fb-sidebar-active: #2563eb;
  --fb-topbar-bg: rgba(11, 18, 32, .85);
  --fb-link: #60a5fa;
  --fb-link-hover: #93c5fd;
  --fb-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .30);
  --fb-shadow-lg: 0 8px 30px rgba(0, 0, 0, .5);
  --bs-body-bg: var(--fb-bg);
  --bs-body-color: var(--fb-text);
}

html { height: 100%; }
body {
  font-family: var(--fb-font);
  background: var(--fb-bg);
  color: var(--fb-text);
  min-height: 100dvh;
}

/* ---------- layout shell ---------- */
.fb-shell { display: flex; min-height: 100dvh; }
.fb-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.fb-content { padding: 1.25rem 1.5rem 2.5rem; max-width: 1500px; width: 100%; margin-inline: auto; }
@media (max-width: 575.98px) { .fb-content { padding: 1rem 1rem 2rem; } }

/* ---------- sidebar ---------- */
.fb-sidebar {
  width: 248px;
  flex: 0 0 248px;
  /* !important: Bootstrap's responsive .offcanvas-md forces background transparent on desktop */
  background: var(--fb-sidebar-bg) !important;
  color: var(--fb-sidebar-text);
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) { .fb-sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; } }
.fb-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1rem 1.25rem; color: #fff; font-weight: 700; font-size: 1.05rem;
  text-decoration: none; border-bottom: 1px solid rgba(148, 163, 184, .15);
}
.fb-brand .bi { color: var(--fb-primary-ink); font-size: 1.35rem; }
.fb-brand-logo { height: 44px; width: auto; flex: 0 0 auto; }
.fb-nav { padding: .75rem .6rem 1.25rem; }
.fb-nav-group {
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  color: #64748b; padding: 1rem .75rem .35rem; font-weight: 600;
}
/* collapsible group headers: full-size rows, not tiny section labels */
.fb-nav-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: 0; cursor: pointer; text-align: start;
  font-size: .92rem; font-weight: 700; text-transform: none; letter-spacing: 0;
  color: var(--fb-sidebar-text); padding: .55rem .75rem; margin-top: .3rem;
  border-radius: var(--fb-radius-sm);
  transition: background var(--fb-speed) ease, color var(--fb-speed) ease;
}
.fb-nav-toggle:hover { background: var(--fb-sidebar-hover); color: #fff; }
.fb-nav-toggle .bi {
  font-size: .72rem; transition: transform var(--fb-speed) ease; flex: 0 0 auto;
}
/* children are indented under their group header */
.fb-nav .collapse .nav-link, .fb-nav .collapsing .nav-link { padding-inline-start: 1.35rem; }
.fb-nav-toggle.collapsed .bi { transform: rotate(-90deg); }
[dir="rtl"] .fb-nav-toggle.collapsed .bi { transform: rotate(90deg); }
.fb-nav-toggle:focus-visible { outline: 2px solid var(--fb-primary-ink); outline-offset: 2px; }
.fb-nav .nav-link {
  display: flex; align-items: center; gap: .65rem;
  color: var(--fb-sidebar-text);
  border-radius: var(--fb-radius-sm);
  padding: .5rem .75rem;
  margin-block-end: 2px;
  font-size: .92rem;
  transition: background var(--fb-speed) ease, color var(--fb-speed) ease;
}
.fb-nav .nav-link .bi { font-size: 1.05rem; width: 1.25rem; text-align: center; flex: 0 0 auto; }
.fb-nav .nav-link:hover { background: var(--fb-sidebar-hover); color: #fff; }
.fb-nav .nav-link.active { background: var(--fb-sidebar-active); color: #fff; font-weight: 600; }
.fb-nav .nav-link:focus-visible { outline: 2px solid var(--fb-primary-ink); outline-offset: 2px; }

/* offcanvas variant keeps sidebar colors on mobile */
.offcanvas.fb-sidebar { width: 264px; }
.offcanvas.fb-sidebar .btn-close { filter: invert(1) grayscale(100%); }

/* ---------- topbar ---------- */
.fb-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.5rem;
  background: var(--fb-topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fb-border);
}
@media (max-width: 575.98px) { .fb-topbar { padding-inline: 1rem; } }
.fb-topbar h1 { font-size: 1.08rem; font-weight: 700; margin: 0; }
@media (max-width: 575.98px) {
  .fb-topbar h1 { font-size: .98rem; min-width: 0; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.fb-icon-btn {
  --bs-btn-padding-x: .55rem; --bs-btn-padding-y: .4rem;
  border: 1px solid var(--fb-border); background: var(--fb-surface); color: var(--fb-muted);
  border-radius: var(--fb-radius-sm);
  transition: color var(--fb-speed) ease, border-color var(--fb-speed) ease, background var(--fb-speed) ease;
}
.fb-icon-btn:hover { color: var(--fb-primary); border-color: var(--fb-primary); background: var(--fb-surface); }
.fb-user-chip { display: inline-flex; align-items: center; gap: .45rem; color: var(--fb-muted); font-size: .9rem; }
.fb-user-chip .bi { font-size: 1.25rem; }

/* ---------- cards & tables ---------- */
.card {
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  background: var(--fb-surface);
  box-shadow: var(--fb-shadow);
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--fb-border);
  padding: .85rem 1.1rem;
  font-weight: 600;
  border-top-left-radius: var(--fb-radius) !important;
  border-top-right-radius: var(--fb-radius) !important;
}
.card .table { margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .9rem; background: transparent; }
.table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--fb-text); font-weight: 700; border-bottom-width: 1px; white-space: nowrap;
}
.table tbody td { color: var(--fb-text); }
.table-hover > tbody > tr:hover > * { background: color-mix(in srgb, var(--fb-primary) 5%, transparent); }
.table td { vertical-align: middle; }
.table .fw-bold, .table td[dir="ltr"], .fs-4.fw-bold, .fs-5.fw-bold { font-variant-numeric: tabular-nums; }

/* stat cards on dashboard */
.fb-stat { transition: transform var(--fb-speed) ease, box-shadow var(--fb-speed) ease; }
.fb-stat:hover { transform: translateY(-2px); box-shadow: var(--fb-shadow-lg); }
.fb-stat .fb-stat-icon {
  width: 40px; height: 40px; border-radius: var(--fb-radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--fb-primary) 12%, transparent);
  color: var(--fb-primary); font-size: 1.15rem; flex: 0 0 auto;
}

/* ---------- forms, buttons, badges ---------- */
.form-control, .form-select {
  border-radius: var(--fb-radius-sm); border-color: var(--fb-border);
  background-color: var(--fb-surface); color: var(--fb-text);
  transition: border-color var(--fb-speed) ease, box-shadow var(--fb-speed) ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--fb-primary);
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--fb-primary) 20%, transparent);
  background-color: var(--fb-surface); color: var(--fb-text);
}
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.btn { border-radius: var(--fb-radius-sm); transition: all var(--fb-speed) ease; }
.btn:active { transform: scale(.97); }
.btn-primary { --bs-btn-bg: var(--fb-primary); --bs-btn-border-color: var(--fb-primary);
  --bs-btn-hover-bg: var(--fb-primary-ink); --bs-btn-hover-border-color: var(--fb-primary-ink); }
.badge { font-weight: 600; border-radius: .45rem; padding: .38em .6em; }
.modal-content { border-radius: var(--fb-radius); border: 1px solid var(--fb-border); box-shadow: var(--fb-shadow-lg); }
.alert { border-radius: var(--fb-radius-sm); }
.form-text, .text-muted, .small.text-muted { color: var(--fb-muted) !important; }

/* dark-mode fixes for utility classes used across pages */
[data-bs-theme="dark"] .badge.bg-light { background: #1e293b !important; color: #cbd5e1 !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .bg-light { background-color: #16233a !important; }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #94a3b8; --bs-btn-border-color: #334155; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { background: rgba(59, 130, 246, .08); }
/* light: outline buttons stay >= 4.5:1 on the tinted modal sections too */
.btn-outline-primary { --bs-btn-color: #1d4ed8; --bs-btn-border-color: #2563eb; }
.btn-outline-secondary { --bs-btn-color: #3d4a5f; --bs-btn-border-color: #94a3b8; }
/* light: amber/cyan text utilities darkened to >= 4.5:1 on white */
.text-warning { color: #b45309 !important; }
.text-info { color: #0e7490 !important; }
/* dark: status/link hues lifted to >= 4.5:1 on dark surfaces; primary fill deepened for white text */
[data-bs-theme="dark"] .text-secondary { color: #94a3b8 !important; }
[data-bs-theme="dark"] .text-success { color: #4ade80 !important; }
[data-bs-theme="dark"] .text-danger { color: #f87171 !important; }
[data-bs-theme="dark"] .text-primary { color: #60a5fa !important; }
[data-bs-theme="dark"] .text-info { color: #67e8f9 !important; }
[data-bs-theme="dark"] .text-warning { color: #fbbf24 !important; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #2563eb; --bs-btn-border-color: #2563eb;
  --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; --bs-btn-active-bg: #1e40af; --bs-btn-active-border-color: #1e40af; }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #60a5fa; --bs-btn-border-color: #3b82f6;
  --bs-btn-hover-bg: #2563eb; --bs-btn-hover-border-color: #2563eb; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #1d4ed8; }
[data-bs-theme="dark"] .btn-outline-dark { --bs-btn-color: #cbd5e1; --bs-btn-border-color: #475569;
  --bs-btn-hover-bg: #334155; --bs-btn-hover-border-color: #475569; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-outline-success { --bs-btn-color: #4ade80; --bs-btn-border-color: #22c55e; }
[data-bs-theme="dark"] .btn-outline-danger { --bs-btn-color: #f87171; --bs-btn-border-color: #ef4444; }
[data-bs-theme="dark"] .table-light { --bs-table-color: var(--fb-text); --bs-table-bg: #16233a;
  --bs-table-border-color: var(--fb-border); --bs-table-striped-bg: #1a2942; --bs-table-hover-bg: #1a2942; color: var(--fb-text); }

/* ---------- searchable selects (Tom Select) ----------
   The bootstrap5 theme draws the box on the wrapper (which carries .form-select),
   so style the wrapper as the field and keep .ts-control transparent inside it. */
.ts-wrapper.form-select {
  padding: 0;
  border: 1px solid var(--fb-border);
  background-color: var(--fb-surface);
  border-radius: var(--fb-radius-sm);
  min-height: calc(1.5em + .75rem + 2px);
  display: flex;
  align-items: center;
  transition: border-color var(--fb-speed) ease, box-shadow var(--fb-speed) ease;
}
.ts-wrapper.form-select.focus {
  border-color: var(--fb-primary);
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--fb-primary) 20%, transparent);
}
.ts-control {
  border: 0 !important;
  background: transparent !important;
  color: var(--fb-text) !important;
  padding: .375rem 2rem .375rem .75rem !important;
  width: 100%;
}
[dir="rtl"] .ts-control { padding: .375rem .75rem .375rem 2rem !important; }
.ts-control input { color: var(--fb-text) !important; }
.ts-wrapper.single .ts-control .item { color: var(--fb-text); }
.ts-dropdown {
  background: var(--fb-surface);
  color: var(--fb-text);
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius-sm);
  box-shadow: var(--fb-shadow-lg);
  z-index: 2000;
}
.ts-dropdown .option { padding: .4rem .75rem; }
.ts-dropdown .active { background: var(--fb-primary); color: #fff; }
.ts-dropdown .dropdown-input {
  background: var(--fb-surface); color: var(--fb-text); border-color: var(--fb-border);
}

/* ---------- table filter box ---------- */
.fb-table-filter {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1.1rem; border-bottom: 1px solid var(--fb-border);
  color: var(--fb-muted);
}
.fb-table-filter input { max-width: 280px; }
.fb-filter-count { white-space: nowrap; }

/* ---------- report charts ---------- */
.fb-chart-box { position: relative; height: 300px; }

/* ---------- reports hub cards ---------- */
.fb-report-card {
  display: flex; flex-direction: column; height: 100%;
  color: inherit; text-decoration: none;
  transition: transform var(--fb-speed) ease, box-shadow var(--fb-speed) ease, border-color var(--fb-speed) ease;
}
.fb-report-card:hover { transform: translateY(-3px); box-shadow: var(--fb-shadow-lg); border-color: var(--fb-primary); color: inherit; }
.fb-report-card .fb-report-icon {
  width: 46px; height: 46px; border-radius: var(--fb-radius-sm); flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--fb-primary) 12%, transparent);
  color: var(--fb-primary); font-size: 1.35rem;
}
.fb-report-card .fb-report-open { color: var(--fb-primary); font-weight: 600; font-size: .85rem; }

/* ---------- modal form sections (larger, structured dialogs) ---------- */
.fb-modal-section {
  border: 1px solid var(--fb-border); border-radius: var(--fb-radius-sm);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
  background: color-mix(in srgb, var(--fb-bg) 55%, var(--fb-surface));
}
.fb-modal-section:last-child { margin-bottom: 0; }
.fb-modal-section-title {
  font-weight: 700; font-size: .95rem; margin-bottom: .75rem;
  display: flex; align-items: center; gap: .5rem; color: var(--fb-text);
}
.fb-modal-section-title .bi { color: var(--fb-primary); }
/* one repeatable line (hotel / service) inside a modal section */
.fb-pnr-line {
  border: 1px solid var(--fb-border); border-radius: var(--fb-radius-sm);
  background: var(--fb-surface); padding: .6rem .75rem; margin-bottom: .6rem;
}
.fb-pnr-line .form-label { font-weight: 600; color: var(--fb-muted); }
/* PNR trip facts (pax, route, arrival/departure) */
.fb-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.fb-fact { border: 1px solid var(--fb-border); border-radius: var(--fb-radius-sm); padding: .55rem .75rem; }
.fb-fact .fb-fact-label { font-size: .78rem; color: var(--fb-muted); font-weight: 600; }
.fb-fact .fb-fact-value { font-weight: 700; }

/* tax picker (includes/tax_picker.php) */
.fb-tax-list {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--fb-border); border-radius: var(--fb-radius-sm); background: var(--fb-surface);
}
.fb-tax-row {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .45rem .75rem; border-bottom: 1px solid var(--fb-border);
  transition: background-color var(--fb-speed);
}
.fb-tax-row:last-child { border-bottom: 0; }
.fb-tax-row.is-on { background: color-mix(in srgb, var(--fb-primary) 7%, var(--fb-surface)); }
.fb-tax-row .form-check-label { cursor: pointer; font-weight: 600; }
.fb-tax-row .fb-tax-mode { width: auto; min-width: 11.5rem; }
.fb-tax-row .fb-tax-mode:disabled { opacity: .45; }
.fb-tax-rate {
  background: color-mix(in srgb, var(--fb-primary) 14%, var(--fb-surface)); color: var(--fb-primary-ink);
  font-variant-numeric: tabular-nums;
}
.fb-tax-preview {
  margin-top: .6rem; border: 1px dashed var(--fb-border); border-radius: var(--fb-radius-sm);
  padding: .5rem .75rem; font-size: .88rem; font-variant-numeric: tabular-nums;
}
.fb-tax-preview > div { display: flex; justify-content: space-between; gap: 1rem; padding: .1rem 0; }
.fb-tax-preview > div > span { color: var(--fb-muted); }
.fb-tax-preview .fb-tax-grand { border-top: 1px solid var(--fb-border); margin-top: .25rem; padding-top: .35rem; font-size: 1rem; }
.fb-tax-preview .fb-tax-grand > span { color: var(--fb-text); font-weight: 700; }
@media (max-width: 575.98px) {
  .fb-tax-row .fb-tax-mode { width: 100%; }
}

/* ---------- misc ---------- */
::selection { background: color-mix(in srgb, var(--fb-primary) 25%, transparent); }
a { color: var(--fb-link); text-decoration: none; }
a:hover { color: var(--fb-link-hover); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .fb-stat:hover { transform: none; }
}

/* ---------- printed documents (PDFs) ---------- */
/* Branded header, shown only in print (every page gets it from includes/header.php). */
.fb-print-header { display: none; }
.fb-print-title { display: none; font-weight: 700; font-size: 1.15rem; margin-bottom: .75rem; }

@media print {
  .fb-sidebar, .fb-topbar, .no-print, .fb-table-filter, .btn, .modal,
  .modal-backdrop, .alert, .form-text { display: none !important; }
  .table-responsive { overflow: visible !important; }

  /* white paper, BLACK ink — no grey text anywhere */
  html, body, .card, .card-header, .card-body, .fb-shell, .fb-main { background: #fff !important; }
  .fb-content, .fb-content * { color: #000 !important; }
  .fb-content .text-muted, .fb-content .small { color: #222 !important; }
  a, a * { color: #000 !important; text-decoration: none !important; }

  .fb-content { padding: 0; max-width: none; }
  .fb-print-title { display: block !important; }

  /* branded document header */
  .fb-print-header {
    display: flex !important; align-items: center; gap: 1rem;
    border-bottom: 3px solid #b8860b; padding-bottom: .6rem; margin-bottom: 1rem;
  }
  .fb-print-header img { height: 58px; }
  .fb-print-head-text { flex: 1; }
  .fb-print-company { font-size: 1.35rem; font-weight: 700; color: #000 !important; }
  .fb-print-doc { font-size: 1.05rem; color: #222 !important; }
  .fb-print-meta { font-size: .8rem; text-align: start; color: #222 !important; }

  /* cards become plain sections; tables get real printed borders */
  .card { border: 0 !important; box-shadow: none !important; }
  .card-header {
    border: 0 !important; border-bottom: 2px solid #000 !important;
    font-weight: 700; padding-inline: 0 !important; font-size: 1.05rem;
  }
  .card-body { padding-inline: 0 !important; }
  .table { border-collapse: collapse !important; }
  .table th, .table td {
    border: 1px solid #999 !important; color: #000 !important;
    background: #fff !important; padding: .35rem .5rem !important;
  }
  .table thead th {
    background: #f0f0f0 !important; font-weight: 700 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  tr { break-inside: avoid; }

  /* badges print as bordered black-on-white labels */
  .badge {
    background: #fff !important; color: #000 !important;
    border: 1px solid #000 !important; font-weight: 600;
  }

  /* form controls print as plain values */
  .form-control, .form-select, .ts-wrapper.form-select {
    border: 0 !important; padding: 0 !important; background: #fff !important;
    color: #000 !important; min-height: 0 !important;
  }
  .form-label { font-weight: 700; margin-bottom: 0; color: #000 !important; }
}

/* login page */
.fb-login-body {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(37, 99, 235, .35), transparent 60%),
              radial-gradient(900px 500px at 10% 110%, rgba(14, 165, 233, .25), transparent 60%),
              #0f172a;
}
.fb-login-card { width: 100%; max-width: 400px; border-radius: 1rem; box-shadow: var(--fb-shadow-lg); }
