/* =====================================================================
   Vehicle Store -- application theme
   Premium automotive look, built on Bootstrap 5.3 tokens so light and
   dark mode both work from one set of variables.
   ===================================================================== */

:root {
    --vs-sidebar-width: 262px;
    --vs-topbar-height: 62px;
    --vs-radius: .65rem;
    --vs-surface: #ffffff;
    --vs-surface-2: #f6f7fb;
    --vs-border: rgba(15, 23, 42, .09);
    --vs-sidebar-bg: #0f172a;
    --vs-sidebar-fg: #cbd5e1;
    --vs-sidebar-active: #1e293b;
    --vs-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -16px rgba(15, 23, 42, .28);
}

[data-bs-theme="dark"] {
    --vs-surface: #131a27;
    --vs-surface-2: #0d131d;
    --vs-border: rgba(148, 163, 184, .16);
    --vs-sidebar-bg: #0a0f18;
    --vs-sidebar-fg: #94a3b8;
    --vs-sidebar-active: #1a2333;
    --vs-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);
}

body {
    background: var(--vs-surface-2);
    font-size: .9rem;
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- shell */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--vs-sidebar-width);
    flex: 0 0 var(--vs-sidebar-width);
    background: var(--vs-sidebar-bg);
    color: var(--vs-sidebar-fg);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    transition: transform .22s ease;
    overflow: hidden;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--vs-sidebar-width);
    display: flex;
    flex-direction: column;
}

.app-content { flex: 1 1 auto; padding: 1.25rem; }

.app-footer {
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--vs-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    color: var(--bs-secondary-color);
}

/* -------------------------------------------------------------- sidebar */
.sidebar-brand {
    height: var(--vs-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, .12);
    flex: 0 0 auto;
}

.brand-mark {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: .6rem;
    background: linear-gradient(135deg, var(--bs-primary), #0ea5e9);
    color: #fff; font-size: 1.05rem;
    flex: 0 0 auto;
}
.brand-mark-lg { width: 60px; height: 60px; font-size: 1.7rem; border-radius: .9rem; }
.brand-logo { max-height: 34px; max-width: 130px; object-fit: contain; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; color: #f8fafc; }
.brand-text small { font-size: .68rem; color: #94a3b8; letter-spacing: .04em; text-transform: uppercase; }

.sidebar-close { color: #94a3b8; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: .75rem 0 1.5rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .28); border-radius: 3px; }

.nav-group + .nav-group { margin-top: .35rem; }
.nav-group-title {
    padding: .6rem 1.15rem .3rem;
    font-size: .66rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
}

.app-sidebar .nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem 1.15rem;
    color: var(--vs-sidebar-fg);
    font-size: .855rem;
    border-left: 3px solid transparent;
    transition: background .12s ease, color .12s ease;
}
.app-sidebar .nav-link i:first-child { width: 1.05rem; text-align: center; opacity: .85; }
.app-sidebar .nav-link:hover { background: var(--vs-sidebar-active); color: #f1f5f9; }
.app-sidebar .nav-link.active {
    background: var(--vs-sidebar-active);
    color: #fff;
    border-left-color: var(--bs-primary);
    font-weight: 500;
}
.app-sidebar .nav-link.disabled { opacity: .42; cursor: not-allowed; }

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(2, 6, 23, .5);
    z-index: 1040; display: none;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* --------------------------------------------------------------- topbar */
.app-topbar {
    height: var(--vs-topbar-height);
    background: var(--vs-surface);
    border-bottom: 1px solid var(--vs-border);
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 1030;
}

.topbar-title {
    font-size: 1rem; font-weight: 600; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.btn-icon {
    width: 36px; height: 36px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: .5rem; border: 1px solid transparent;
    color: var(--bs-body-color);
}
.btn-icon:hover { background: var(--vs-surface-2); }

.branch-switcher { min-width: 190px; }

.user-chip {
    display: inline-flex; align-items: center; gap: .55rem;
    padding: .25rem .5rem; border: 1px solid var(--vs-border);
    border-radius: 2rem; background: transparent;
}
.user-chip::after { margin-left: .15rem; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
}
.avatar-initials { background: var(--bs-primary); color: #fff; font-size: .74rem; font-weight: 600; }

.theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: inline; }

/* ---------------------------------------------------------------- cards */
.card {
    background: var(--vs-surface);
    border: 1px solid var(--vs-border);
    border-radius: var(--vs-radius);
    box-shadow: var(--vs-shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--vs-border);
    padding: .8rem 1rem;
}
.card-body { padding: 1rem; }
.card-footer { border-top: 1px solid var(--vs-border); padding: .6rem 1rem; }

/* ------------------------------------------------------------ stat card */
.stat-card {
    background: var(--vs-surface);
    border: 1px solid var(--vs-border);
    border-radius: var(--vs-radius);
    box-shadow: var(--vs-shadow);
    padding: 1rem;
    display: flex; align-items: flex-start; gap: .85rem;
    height: 100%;
}
.stat-icon {
    width: 44px; height: 44px; border-radius: .6rem;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex: 0 0 auto;
}
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.stat-meta { font-size: .74rem; display: flex; gap: .3rem; align-items: center; }

.mini-tile {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem; border: 1px solid var(--vs-border); border-radius: .5rem;
    height: 100%;
}
.mini-icon { font-size: 1.15rem; }

/* --------------------------------------------------------------- tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 600; color: var(--bs-secondary-color);
    border-bottom: 1px solid var(--vs-border);
    white-space: nowrap;
}
.table > tbody td { vertical-align: middle; }

.table-avatar {
    width: 34px; height: 34px; border-radius: .5rem; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .74rem; font-weight: 600; flex: 0 0 auto;
}

/* ---------------------------------------------------------- empty state */
.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-state > i { font-size: 2.4rem; color: var(--bs-secondary-color); opacity: .55; display: block; margin-bottom: .6rem; }

/* --------------------------------------------------------------- forms */
.form-label { font-size: .8rem; font-weight: 500; margin-bottom: .3rem; }
.form-label.required::after { content: " *"; color: var(--bs-danger); }
.form-text { font-size: .74rem; }
.form-control, .form-select { font-size: .875rem; }

/* --------------------------------------------- permission matrix (RBAC) */
.perm-group + .perm-group { border-top: 1px solid var(--vs-border); }
.perm-group-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .5rem 1rem; background: var(--vs-surface-2);
    font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.perm-table td, .perm-table th { padding: .4rem .5rem; }
.perm-table .form-check-input { margin: 0; cursor: pointer; }

.settings-nav .list-group-item { border-radius: 0; font-size: .875rem; }
.settings-nav .list-group-item:first-child { border-top-left-radius: var(--vs-radius); border-top-right-radius: var(--vs-radius); }
.settings-nav .list-group-item:last-child { border-bottom-left-radius: var(--vs-radius); border-bottom-right-radius: var(--vs-radius); }

.log-diff {
    background: var(--vs-surface-2);
    border: 1px solid var(--vs-border);
    border-radius: .4rem;
    padding: .6rem;
    font-size: .72rem;
    max-height: 220px; overflow: auto;
    white-space: pre-wrap; word-break: break-word;
}

.profile-avatar {
    width: 64px; height: 64px; border-radius: .8rem; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.profile-avatar-initials { background: var(--bs-primary); color: #fff; font-size: 1.4rem; font-weight: 600; }

/* ----------------------------------------------------------- auth pages */
.auth-body { background: var(--vs-surface-2); }
.auth-wrap { display: flex; min-height: 100vh; }

.auth-visual {
    flex: 1 1 50%;
    background: linear-gradient(140deg, #0f172a 0%, #1e293b 45%, #0c4a6e 100%);
    color: #e2e8f0;
    align-items: center; justify-content: center;
    padding: 3rem;
}
.auth-visual-inner { max-width: 420px; }
.auth-visual h2 { font-weight: 700; margin: 1.25rem 0 .75rem; color: #fff; }
.auth-visual p { color: #94a3b8; }
.auth-points { list-style: none; padding: 0; margin: 1.75rem 0 0; }
.auth-points li { padding: .35rem 0; color: #cbd5e1; font-size: .9rem; }
.auth-points i { color: #38bdf8; margin-right: .5rem; }

.auth-panel {
    flex: 1 1 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem 1.25rem;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--vs-surface);
    border: 1px solid var(--vs-border);
    border-radius: var(--vs-radius);
    box-shadow: var(--vs-shadow);
    padding: 2rem;
}
.auth-card .brand-mark { margin: 0 auto; }

/* -------------------------------------------------------------- mobile */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem .75rem; }
    .topbar-title { font-size: .95rem; }
    .branch-switcher { min-width: 140px; }
}

@media print {
    .app-sidebar, .app-topbar, .app-footer, .btn, .toast-container { display: none !important; }
    .app-main { margin-left: 0; }
    .card { box-shadow: none; border: none; }
}
