/* ===================================================================
   Alsaaer — brand styles
   ===================================================================
   Brand identity ported from the Flutter app (al_saaer/app_colors.dart):
     navy + gold + cream — "parts-counter feel".

   Light mode is the default; a Dark Mode toggle can flip the body
   `data-theme="dark"` attribute later (variables flip automatically).
   =================================================================== */

:root {
    /* Brand */
    --brand-navy:        #11365F;
    --brand-gold:        #F1AC20;
    --brand-cream:       #F0F1E5;
    --navy-deep:         #0A2544;
    --navy-ink:          #061A32;
    --navy-tint:         #EAEEF4;

    /* Semantic */
    --bg:                #F4F5F7;
    --surface:           #FFFFFF;
    --surface-alt:       #F9FAFB;
    --text:              #0F172A;
    --muted:             #64748B;
    --border:            #D8DCE3;
    --danger:            #B91C1C;
    --success:           #166534;

    /* Layout */
    --header-height:     56px;
    --sidebar-width:     56px;
    --sidebar-expanded:  220px;
    --tab-height:        40px;
    --radius:            8px;
    --radius-lg:         12px;

    /* Shadows */
    --shadow-sm:         0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow:            0 2px 6px rgba(15, 23, 42, 0.06);
    --shadow-md:         0 6px 16px rgba(15, 23, 42, 0.08);
}

/* ── Base ──────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── App shell ─────────────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

.app-header {
    height: var(--header-height);
    background: var(--brand-navy);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow);
    border-bottom: 2px solid var(--brand-gold);
    flex-shrink: 0;
}
.app-header .brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 900; font-size: 18px; letter-spacing: 0.3px;
}
.app-header .brand .dot { width: 10px; height: 10px; background: var(--brand-gold); border-radius: 50%; }
.app-header .spacer { flex: 1; }
.app-header .user-chip {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 6px 12px; border-radius: 999px;
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.app-header .icon-btn {
    background: transparent; border: 0; color: #fff;
    width: 36px; height: 36px; border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.app-header .icon-btn:hover { background: rgba(255,255,255,0.08); }

.app-body { flex: 1; display: flex; min-height: 0; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-inline-start: 1px solid var(--border);  /* RTL: visual right */
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: width 0.18s ease;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar:hover { width: var(--sidebar-expanded); }
.sidebar .nav-item {
    height: 44px;
    display: flex; align-items: center; gap: 14px;
    padding: 0 16px;
    color: var(--muted);
    font-weight: 700; font-size: 14px;
    cursor: pointer;
    border-inline-start: 3px solid transparent;
    white-space: nowrap;
}
.sidebar .nav-item:hover { background: var(--navy-tint); color: var(--brand-navy); }
.sidebar .nav-item.active {
    background: var(--navy-tint);
    color: var(--brand-navy);
    border-inline-start-color: var(--brand-gold);
}
.sidebar .nav-item .icon { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
.sidebar .nav-item .label { opacity: 0; transition: opacity 0.12s ease 0.06s; }
.sidebar:hover .nav-item .label { opacity: 1; }

/* ── Workspace ─────────────────────────────────────────────────── */
.workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Tab bar */
.tab-bar {
    height: var(--tab-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: stretch;
    padding: 0 8px;
    overflow-x: auto;
    flex-shrink: 0;
}
.tab-bar::-webkit-scrollbar { height: 4px; }
.tab-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tab {
    height: 100%; min-width: 140px;
    padding: 0 12px 0 8px;
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 700;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.tab .tab-icon { font-size: 14px; }
.tab .tab-close {
    width: 18px; height: 18px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); background: transparent; border: 0;
    font-size: 12px;
}
.tab .tab-close:hover { background: var(--border); color: var(--danger); }
.tab:hover { color: var(--brand-navy); background: var(--surface-alt); }
.tab.active {
    color: var(--brand-navy);
    background: var(--surface);
    border-bottom-color: var(--brand-gold);
}
.tab-new {
    width: 32px; height: 100%; min-width: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted);
    background: transparent; border: 0;
    font-size: 18px;
}
.tab-new:hover { color: var(--brand-navy); }

/* Tab content */
.tab-content {
    flex: 1; overflow: auto;
    padding: 16px;
    background: var(--bg);
}

/* ── Cards / sections ──────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 800;
    color: var(--brand-navy);
}
.card-body { padding: 16px; }

/* ── Form controls ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
    font-size: 12px; font-weight: 800;
    color: var(--muted);
}
.input, .select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px; font-weight: 600;
    color: var(--text);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
    width: 100%;
}
.input:focus, .select:focus {
    outline: 0;
    border-color: var(--brand-navy);
    box-shadow: 0 0 0 3px rgba(17, 54, 95, 0.12);
}

/* Search input */
.search-row { display: flex; gap: 8px; align-items: center; }
.search-input {
    flex: 1; height: 44px;
    font-size: 16px; font-weight: 700;
    padding: 0 16px;
}
.btn {
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-weight: 900; font-size: 14px;
    border: 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: background 0.12s ease;
}
.btn-primary {
    background: var(--brand-navy); color: #fff;
}
.btn-primary:hover { background: var(--navy-deep); }
.btn-ghost {
    background: transparent; color: var(--brand-navy);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--navy-tint); }
.btn-gold {
    background: var(--brand-gold); color: var(--navy-ink);
}
.btn-gold:hover { filter: brightness(0.95); }

/* ── Vehicle filter grid ───────────────────────────────────────── */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* ── Results table ─────────────────────────────────────────────── */
.results-card { margin-top: 16px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 360px); }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: right;
    padding: 10px 12px;
    font-weight: 800;
    color: var(--brand-navy);
    background: var(--surface-alt);
    border-bottom: 2px solid var(--brand-gold);
    position: sticky; top: 0;
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.table tr:hover td { background: var(--navy-tint); cursor: pointer; }
.table .stock-cell { text-align: center; font-weight: 800; }
.table .stock-zero  { color: var(--muted); font-weight: 600; }
.table .stock-good  { color: var(--success); }
.table .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px; font-weight: 800;
    background: var(--navy-tint); color: var(--brand-navy);
}

/* ── Login screen ──────────────────────────────────────────────── */
.login-bg {
    height: 100vh; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--navy-ink) 100%);
}
.login-card {
    width: min(420px, 92vw);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
    border-top: 4px solid var(--brand-gold);
}
.login-title {
    margin: 0 0 4px 0;
    font-size: 24px; font-weight: 900;
    color: var(--brand-navy);
}
.login-subtitle {
    margin: 0 0 24px 0;
    font-size: 13px; color: var(--muted);
}
.login-card .field + .field { margin-top: 14px; }
.login-card .btn { width: 100%; margin-top: 20px; }
.login-error {
    background: #FEF2F2;
    color: var(--danger);
    border: 1px solid #FECACA;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px; font-weight: 700;
    margin-top: 16px;
}

/* ── Empty / loading states ────────────────────────────────────── */
.empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}
.loading { color: var(--muted); padding: 24px; text-align: center; }
