/* ==========================================================================
   Al Yusra Transport — Shared Theme
   One stylesheet, linked from every page, so the palette/type/components
   stay identical across Staff, Admin, Agent and Driver portals.
   ========================================================================== */

:root {
    --bg: #101820;
    --surface: #1A2530;
    --surface-raised: #212E3A;
    --hairline: #2A3742;
    --text: #F1ECE0;
    --text-dim: #8B98A3;
    --text-faint: #5C6B78;
    --gold: #D4A24C;
    --gold-dim: #8A6B33;
    --teal: #4FA398;
    --teal-dim: #2E5C55;
    --rust: #C1602E;
    --rust-dim: #7A4023;
    --radius: 10px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; }
.display { font-family: 'Space Grotesk', sans-serif; }
a { color: inherit; text-decoration: none; }

/* ===== App shell: sidebar + content ===== */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: var(--surface);
    width: 248px;
    flex-shrink: 0;
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--hairline);
}

.sidebar-brand .brand-mark {
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--gold);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--gold);
    flex-shrink: 0;
}

.sidebar-brand .brand-text .display {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.sidebar-brand .brand-text .sub {
    font-size: 10.5px;
    color: var(--text-faint);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-dim);
    transition: 0.15s;
}

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

.sidebar-nav a.active {
    background: rgba(212, 162, 76, 0.12);
    color: var(--gold);
}

.sidebar-nav a .icon {
    font-size: 17px;
    flex-shrink: 0;
}

.sidebar-foot {
    padding: 14px;
    border-top: 1px solid var(--hairline);
}

.sidebar-foot button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--rust);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s;
}

.sidebar-foot button:hover {
    background: rgba(193, 96, 46, 0.12);
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Top bar (page header inside content area) ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
}

.topbar h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 19px;
    font-weight: 600;
}

.topbar p {
    color: var(--text-dim);
    font-size: 12.5px;
    margin-top: 3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 22px;
}

.clock { text-align: right; }
.clock .time { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 500; }
.clock .date { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
}

.avatar:hover { background: var(--hairline); color: var(--text); }

/* ===== Page body / shell ===== */
.shell {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px 60px;
}

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gold);
    color: #151109;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: 0.2s;
}

.btn:hover { background: #e0af58; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--hairline);
}

.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }

.btn-danger { background: var(--rust); color: var(--text); }
.btn-danger:hover { background: #d66f38; }

/* ===== KPI strip ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 30px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: var(--accent, var(--gold));
}

.kpi.gold::before { background: var(--gold); }
.kpi.teal::before { background: var(--teal); }
.kpi.rust::before { background: var(--rust); }
.kpi.neutral::before { background: var(--text-faint); }

.kpi-label {
    font-size: 11.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.kpi-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
}

.kpi-value .unit { font-size: 14px; color: var(--text-faint); font-weight: 500; margin-left: 4px; }
.kpi-note { font-size: 11.5px; color: var(--text-faint); margin-top: 8px; }

/* ===== Panels / cards ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline);
}

.panel-head h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 600;
}

.panel-head .count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--text-dim);
    background: var(--surface-raised);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--hairline);
}

.panel-foot {
    padding: 12px 20px;
    text-align: center;
    border-top: 1px solid var(--hairline);
    font-size: 12px;
    color: var(--text-dim);
}

.panel-foot a:hover { color: var(--gold); }

/* ===== Data tables ===== */
.data-table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

table.data-table thead tr {
    background: var(--surface-raised);
    color: var(--text-faint);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table.data-table th {
    padding: 12px 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--hairline);
}

table.data-table td {
    padding: 14px 20px;
    font-size: 13px;
    border-bottom: 1px solid var(--hairline);
}

table.data-table tbody tr:hover { background: var(--surface-raised); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== Status pills / badges ===== */
.status-pill {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 20px;
    font-weight: 500;
}

.status-pill.gold   { background: rgba(212,162,76,0.14); color: var(--gold); }
.status-pill.teal   { background: rgba(79,163,152,0.14); color: var(--teal); }
.status-pill.rust   { background: rgba(193,96,46,0.14);  color: var(--rust); }
.status-pill.dim    { background: var(--surface-raised); color: var(--text-dim); }

/* ===== Balance rows ===== */
.balance-list { padding: 6px 10px 10px; }

.balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 10px;
    border-radius: 8px;
}

.balance-row:hover { background: var(--surface-raised); }

.balance-name { display: flex; align-items: center; gap: 10px; min-width: 0; }

.balance-initial {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-dim);
    flex-shrink: 0;
}

.balance-name .n {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-name .t { font-size: 10.5px; color: var(--text-faint); }

.balance-amt {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
    padding-left: 10px;
}

.balance-amt.owe { color: var(--rust); }
.balance-amt.owed { color: var(--teal); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
    overflow-y: auto;
}

.modal-overlay.open { display: flex; }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--hairline);
    width: 100%;
    max-width: 560px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    margin: auto;
}

.modal-content.wide { max-width: 760px; }

.modal-head {
    padding: 20px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover { color: var(--rust); }

.modal-body { padding: 20px; }

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group { margin-bottom: 15px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--hairline);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    outline: none;
}

.form-control:focus { border-color: var(--gold); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238B98A3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

/* Financials block (used to visually separate pricing fields in forms) */
.form-financials {
    background: var(--bg);
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--hairline);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 15px;
    display: none;
}

.alert.show { display: block; }
.alert-success { background: rgba(79,163,152,0.14); color: var(--teal); border: 1px solid var(--teal); }
.alert-error { background: rgba(193,96,46,0.14); color: var(--rust); border: 1px solid var(--rust); }

/* ===== Empty / loading states ===== */
.empty-row td {
    text-align: center;
    padding: 32px 20px !important;
    color: var(--text-faint);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
}

/* Menu toggle + backdrop are always in the DOM; only shown/active below the
   mobile breakpoint. 1024px (not the more typical ~768px) is deliberate —
   phones in landscape commonly run 800-930px wide, and without headroom past
   that they'd fall back to the always-visible desktop sidebar with no way to
   dismiss it on a small screen. */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--hairline);
    color: var(--text);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    margin-right: 12px;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 899;
}

@media (max-width: 1024px) {
    .menu-toggle { display: flex; }
    .sidebar { position: fixed; z-index: 900; height: 100vh; transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .topbar { padding: 16px 18px; }
    .shell { padding: 22px 18px 40px; }
}

@media (max-width: 520px) {
    .kpi-row { grid-template-columns: 1fr; }
    .clock { display: none; }
}

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
