/* =====================================================================
   AutoCare ERP — Phase 1 design system
   Identity: workshop charcoal + amber lamp accent.
   All spacing uses logical properties so RTL/LTR both work untouched.
   ===================================================================== */

:root {
    --ink: #14181d;
    --sidebar-bg: #1b222b;
    --sidebar-ink: #aeb7c2;
    --sidebar-ink-strong: #f1f4f8;
    --accent: #f2a91e;
    --accent-ink: #201503;
    --surface: #f4f5f7;
    --card: #ffffff;
    --line: #e4e7ec;
    --muted: #68717d;
    --radius: 12px;
    --sidebar-w: 256px;
    --topbar-h: 60px;
    --font-ar: "Cairo", "Segoe UI", Tahoma, sans-serif;
    --font-en: "Inter", "Segoe UI", sans-serif;
}

[data-bs-theme="dark"] {
    --surface: #101418;
    --card: #1a2027;
    --line: #2a323c;
    --muted: #8b95a1;
    --ink: #e8ecf1;
}

html { font-size: 15px; }

body {
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-en);
    min-height: 100vh;
}

html[lang="ar"] body { font-family: var(--font-ar); }

h1, h2, h3, h4, h5, .brand-text strong { font-weight: 700; }

/* ------------------------------ Shell ------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.main {
    flex: 1;
    min-width: 0;
    margin-inline-start: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.content {
    padding: 1.4rem 1.6rem 2.5rem;
    max-width: 1400px;
    width: 100%;
    margin-inline: auto;
}

/* ----------------------------- Sidebar ----------------------------- */
.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #39434f transparent;
}

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1rem 1.1rem;
    text-decoration: none;
    color: var(--sidebar-ink-strong);
    border-block-end: 1px solid rgba(255, 255, 255, .07);
}

.brand-mark {
    /* Default size — overridden by inline style from Layout when logo configured */
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    flex: 0 0 auto;
    box-shadow: 0 4px 14px rgba(242, 169, 30, .35);
}

.brand-text { line-height: 1.15; }
.brand-text strong { display: block; font-size: 1.02rem; letter-spacing: .2px; }
.brand-text small { color: var(--sidebar-ink); font-size: .68rem; letter-spacing: .8px; text-transform: uppercase; }

.side-nav { padding: .8rem .7rem 1.4rem; }

.nav-group {
    font-size: .66rem;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #6d7783;
    padding: 1.1rem .55rem .35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .52rem .65rem;
    margin-block-end: 2px;
    border-radius: 9px;
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: .92rem;
    position: relative;
    transition: background .15s, color .15s;
}

.nav-item i { font-size: 1.05rem; width: 1.3rem; text-align: center; }

a.nav-item:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-ink-strong); }

.nav-item.active {
    background: rgba(242, 169, 30, .14);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    inset-block: 6px;
    inset-inline-start: -0.7rem;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
}

/* Phase-locked items: visible roadmap, clearly inert */
.nav-item.locked { opacity: .42; cursor: default; }
.nav-item.locked em {
    margin-inline-start: auto;
    font-style: normal;
    font-size: .62rem;
    font-weight: 700;
    background: rgba(255, 255, 255, .12);
    color: var(--sidebar-ink-strong);
    border-radius: 999px;
    padding: .05rem .42rem;
}

/* ----------------------------- Topbar ------------------------------ */
.topbar {
    height: var(--topbar-h);
    background: var(--card);
    border-block-end: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding-inline: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    display: grid;
    place-items: center;
    font-size: 1.05rem;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.dropdown-toggle::after { display: none; }

.user-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: .32rem .85rem;
    font-size: .9rem;
}

.user-chip i { font-size: 1.15rem; color: var(--accent); }

/* --------------------------- Page header --------------------------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .8rem;
    margin-block-end: 1.2rem;
}

.page-head h1 { font-size: 1.35rem; margin: 0; }
.page-head .spacer { flex: 1; }

/* ------------------------------ Cards ------------------------------ */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
}

.panel + .panel { margin-block-start: 1rem; }

.panel-title {
    font-size: .95rem;
    font-weight: 700;
    margin-block-end: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.panel-title i { color: var(--accent); }

/* Signature stat cards: amber rail on the reading-start edge */
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-inline-start: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: .95rem 1.1rem;
    height: 100%;
}

.stat-card .label { color: var(--muted); font-size: .78rem; }
.stat-card .value { font-size: 1.65rem; font-weight: 800; line-height: 1.2; }
.stat-card .value small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.stat-card i.stat-ico { float: inline-end; font-size: 1.5rem; color: var(--accent); opacity: .85; }

.stat-card.locked {
    border-inline-start-color: var(--line);
    opacity: .6;
    position: relative;
}

.stat-card.locked .phase-pill {
    position: absolute;
    inset-block-start: .6rem;
    inset-inline-end: .6rem;
    font-size: .6rem;
    font-weight: 700;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .1rem .5rem;
    color: var(--muted);
}

/* ------------------------------ Tables ----------------------------- */
.table { --bs-table-bg: transparent; }
.table thead th {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    border-block-end: 2px solid var(--line) !important;
    white-space: nowrap;
}
.table td { vertical-align: middle; }

.color-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid var(--line);
    vertical-align: middle;
}

.badge-soft {
    background: rgba(242, 169, 30, .15);
    color: #9a6a08;
    font-weight: 600;
    border-radius: 999px;
    padding: .28em .7em;
    font-size: .74rem;
}

[data-bs-theme="dark"] .badge-soft { color: var(--accent); }

/* ------------------------------ Forms ------------------------------ */
.form-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.form-control, .form-select { border-color: var(--line); }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(242, 169, 30, .18);
}

.btn-accent {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}
.btn-accent:hover { background: #e09a10; border-color: #e09a10; color: var(--accent-ink); }

.phone-row { display: flex; gap: .6rem; align-items: center; margin-block-end: .55rem; }
.phone-row .form-check { margin: 0; white-space: nowrap; }

/* ------------------------------ Login ------------------------------ */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(700px 340px at 12% -8%, rgba(242, 169, 30, .18), transparent 60%),
        linear-gradient(160deg, #14181d 0%, #1b222b 55%, #232c37 100%);
    padding: 1.2rem;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--card);
    border-radius: 16px;
    padding: 2rem 1.9rem 1.7rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.login-card .brand-mark { margin-inline: auto; margin-block-end: .9rem; }
.login-card h1 { font-size: 1.25rem; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: .85rem; margin-block-end: 1.4rem; }

/* --------------------------- Responsive ---------------------------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(calc(var(--dir-sign, -1) * 100%)); transition: transform .22s ease; }
    html[dir="rtl"] .sidebar { --dir-sign: 1; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
    .main { margin-inline-start: 0; }
}

/* ------------------------- Accessibility --------------------------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ── Version Footer ─────────────────────────────────────────── */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    font-size: .72rem;
    color: var(--bs-secondary-color);
}
.footer-inner {
    display: flex;
    align-items: center;
    gap: .4rem;
    width: 100%;
    flex-wrap: nowrap;
    overflow: hidden;
}
.footer-brand { font-weight: 600; color: var(--bs-primary); white-space: nowrap; }
.footer-version { font-weight: 600; color: var(--bs-success); white-space: nowrap; }
.footer-phase  { color: var(--bs-info); white-space: nowrap; }
.footer-build  { color: var(--bs-secondary); white-space: nowrap; }
.footer-sep    { color: var(--bs-border-color); }
.footer-copy   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Push main content up so footer doesn't overlap last item */
.main-content { padding-bottom: 2.5rem !important; }
