/* ==========================================================================
   Car Interior MS - Premium Automotive Dark Theme
   ========================================================================== */
:root {
    --bg: #0a0a0c;
    --bg-2: #111114;
    --surface: #16161a;
    --surface-2: #1d1d22;
    --border: #2a2a31;
    --accent: #e10600;
    --accent-2: #ff2b22;
    --accent-glow: rgba(225, 6, 0, 0.45);
    --text: #f4f4f6;
    --muted: #9a9aa6;
    --success: #1fc16b;
    --warning: #f5a623;
    --info: #3aa0ff;
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 264px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --trans: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 80% -10%, rgba(225, 6, 0, 0.10), transparent 60%),
                radial-gradient(900px 500px at -10% 10%, rgba(58, 160, 255, 0.06), transparent 55%),
                var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: #33333c; border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

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

.sidebar {
    width: var(--sidebar-w);
    position: fixed;
    inset: 0 auto 0 0;
    background: linear-gradient(180deg, #121216, #0c0c0f);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--trans);
}
.sidebar__brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.sidebar__brand .logo-badge {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), #7a0300);
    box-shadow: 0 6px 18px var(--accent-glow);
    color: #fff; font-size: 20px;
}
.sidebar__brand b { font-size: 17px; letter-spacing: 0.3px; }
.sidebar__brand span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-label { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; padding: 16px 12px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 13px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 500;
    transition: var(--trans); position: relative; margin-bottom: 2px;
}
.nav-item i { width: 20px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(3px); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(225, 6, 0, 0.18), rgba(225, 6, 0, 0.04));
    color: #fff;
}
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 18%; bottom: 18%;
    width: 3px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.sidebar__footer { padding: 14px; border-top: 1px solid var(--border); }

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

/* ===== Topbar ===== */
.topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 16px;
    padding: 14px 24px;
    background: rgba(14, 14, 17, 0.75);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.topbar__title h5 { margin: 0; font-weight: 700; }
.topbar__title small { color: var(--muted); }
.topbar .btn-burger { display: none; }
.topbar .search-box { margin-left: auto; position: relative; max-width: 320px; width: 100%; }
.topbar .search-box input { padding-left: 38px; }
.topbar .search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.content { padding: 24px; flex: 1; }
@media (min-width: 1500px) { .content { padding: 28px 40px; } }

/* ===== Cards / surfaces ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    box-shadow: var(--shadow);
}
.card .card-header {
    background: transparent; border-bottom: 1px solid var(--border);
    padding: 16px 20px; font-weight: 600; display: flex; align-items: center; gap: 10px;
}
.card .card-body { padding: 20px; }
.glass {
    background: rgba(28, 28, 34, 0.55);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== Stat cards ===== */
.stat-card {
    position: relative; overflow: hidden;
    border-radius: var(--radius); padding: 20px;
    background: linear-gradient(145deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    transition: var(--trans);
}
.stat-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.stat-card .stat-icon {
    width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
    font-size: 22px; color: #fff; margin-bottom: 14px;
}
.stat-card .stat-value { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; margin-top: 6px; }
.stat-card::after {
    content: ''; position: absolute; right: -30px; bottom: -30px; width: 120px; height: 120px;
    border-radius: 50%; background: radial-gradient(circle, var(--accent-glow), transparent 70%); opacity: .25;
}
.bg-grad-red { background: linear-gradient(135deg, #e10600, #7a0300); }
.bg-grad-blue { background: linear-gradient(135deg, #3aa0ff, #1d4ed8); }
.bg-grad-green { background: linear-gradient(135deg, #1fc16b, #0b7a44); }
.bg-grad-amber { background: linear-gradient(135deg, #f5a623, #b9650a); }
.bg-grad-purple { background: linear-gradient(135deg, #9b5cff, #5b21b6); }
.bg-grad-cyan { background: linear-gradient(135deg, #22d3ee, #0e7490); }

/* ===== Buttons ===== */
.btn { border-radius: var(--radius-sm); font-weight: 600; transition: var(--trans); border: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #a30400); color: #fff; box-shadow: 0 8px 22px var(--accent-glow); }
.btn-primary:hover { background: linear-gradient(135deg, #ff140d, var(--accent)); transform: translateY(-2px); color: #fff; }
.btn-outline-light { border: 1px solid var(--border); color: var(--text); }
.btn-outline-light:hover { background: var(--surface-2); color: #fff; border-color: var(--accent); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: #2a2a31; color: #fff; }
.btn-whatsapp { background: #25d366; color: #07321b; font-weight: 700; }
.btn-whatsapp:hover { background: #1fbe5a; color: #052b16; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; }

/* ===== Forms ===== */
.form-control, .form-select {
    background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
    background: var(--bg-2); color: var(--text);
    border-color: var(--accent); box-shadow: 0 0 0 .2rem var(--accent-glow);
}
.form-control::placeholder { color: #5f5f6b; }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #d6d6dd; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.input-group-text { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* ===== Tables ===== */
.table { color: var(--text); border-color: var(--border); margin: 0; }
.table > :not(caption) > * > * { background: transparent; border-bottom-color: var(--border); padding: 13px 14px; }
.table thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; border-bottom: 1px solid var(--border); font-weight: 700; }
.table tbody tr { transition: var(--trans); }
.table tbody tr:hover { background: var(--surface-2); }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* ===== Badges / pills ===== */
.badge { font-weight: 600; padding: 6px 11px; border-radius: 30px; font-size: 11.5px; }
.badge-soft-success { background: rgba(31,193,107,.16); color: #4ade80; }
.badge-soft-danger { background: rgba(225,6,0,.16); color: #ff6b6b; }
.badge-soft-warning { background: rgba(245,166,35,.16); color: #fbbf24; }
.badge-soft-info { background: rgba(58,160,255,.16); color: #60a5fa; }
.badge-soft-primary { background: rgba(155,92,255,.16); color: #c4b5fd; }
.badge-soft-secondary { background: rgba(154,154,166,.16); color: #cbd5e1; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ===== Gallery / masonry ===== */
.gallery-grid {
    columns: 5 240px; column-gap: 16px;
}
@media (max-width: 1200px){ .gallery-grid { columns: 3 200px; } }
@media (max-width: 576px){ .gallery-grid { columns: 2 140px; column-gap: 10px; } }

.gallery-card {
    break-inside: avoid; margin-bottom: 16px; position: relative;
    border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border);
    background: var(--surface); transition: var(--trans); cursor: pointer;
}
.gallery-card img { width: 100%; display: block; transition: transform .4s ease; background: var(--surface-2); min-height: 80px; }
.gallery-card:hover { border-color: var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.5); transform: translateY(-3px); }
.gallery-card:hover img { transform: scale(1.06); }
.gallery-card .gc-overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
    padding: 10px; background: linear-gradient(180deg, rgba(0,0,0,.4) 0%, transparent 30%, transparent 60%, rgba(0,0,0,.78) 100%);
    opacity: 0; transition: var(--trans);
}
.gallery-card:hover .gc-overlay, .gallery-card.selected .gc-overlay { opacity: 1; }
.gallery-card .gc-title { font-size: 12.5px; font-weight: 600; }
.gallery-card .gc-sub { font-size: 11px; color: #cfcfd6; }
.gallery-card .gc-check {
    align-self: flex-end; width: 28px; height: 28px; border-radius: 50%;
    background: rgba(0,0,0,.5); border: 2px solid #fff; display: grid; place-items: center; color: transparent;
}
.gallery-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 10px 30px rgba(0,0,0,.5); }
.gallery-card.selected .gc-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.gallery-card.selected .gc-overlay { opacity: 1; background: linear-gradient(180deg, rgba(225,6,0,.25), transparent 40%, rgba(0,0,0,.78)); }

/* group header in gallery */
.design-group-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.design-group-head h6 { margin: 0; font-weight: 700; }
.design-group-head .line { flex: 1; height: 1px; background: var(--border); }

/* Selection bar */
.selection-bar {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%);
    z-index: 1050; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 50px; padding: 10px 12px 10px 22px; display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow); transition: transform .35s cubic-bezier(.34,1.56,.64,1); max-width: calc(100% - 24px);
}
.selection-bar.show { transform: translateX(-50%) translateY(0); }
.selection-bar .count { font-weight: 700; }
.selection-bar .count b { color: var(--accent-2); }
@media (max-width: 576px){ .selection-bar { left: 12px; right: 12px; transform: translateY(140%); border-radius: 18px; flex-wrap: wrap; justify-content: center; } .selection-bar.show { transform: translateY(0);} }

/* Image upload dropzone */
.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px 20px; text-align: center;
    color: var(--muted); transition: var(--trans); cursor: pointer; background: var(--bg-2);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(225,6,0,.05); color: var(--text); }
.dropzone i { font-size: 38px; color: var(--accent); margin-bottom: 10px; }
.preview-grid, .image-manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.preview-tile, .manage-tile { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); aspect-ratio: 1; background: var(--surface-2); cursor: grab; }
.preview-tile img, .manage-tile img { width: 100%; height: 100%; object-fit: cover; }
.preview-tile .rm, .manage-tile .rm {
    position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
    background: rgba(0,0,0,.65); color: #fff; border: none; display: grid; place-items: center; font-size: 12px;
}
.manage-tile .drag-handle { position:absolute; left:6px; bottom:6px; background:rgba(0,0,0,.6); color:#fff; padding:2px 7px; border-radius:20px; font-size:10px; }
.manage-tile.sortable-ghost { opacity: .35; }

/* ===== Login ===== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; }
.auth-card { width: 100%; max-width: 420px; padding: 38px 34px; border-radius: 22px; }
.auth-logo { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 18px;
    background: linear-gradient(135deg, var(--accent), #7a0300); box-shadow: 0 10px 30px var(--accent-glow); font-size: 28px; }
.auth-bg-stripe { position: absolute; inset: 0; overflow: hidden; z-index: -1; }
.auth-bg-stripe::before, .auth-bg-stripe::after { content:''; position:absolute; width: 600px; height: 600px; border-radius: 50%; filter: blur(120px); }
.auth-bg-stripe::before { background: rgba(225,6,0,.25); top: -200px; right: -150px; }
.auth-bg-stripe::after { background: rgba(58,160,255,.12); bottom: -200px; left: -150px; }

/* ===== Bottom nav (mobile) ===== */
.bottom-nav { display: none; }
@media (max-width: 991px) {
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1045;
        background: rgba(16,16,20,.92); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        justify-content: space-around;
    }
    .bottom-nav a {
        flex: 1; text-align: center; color: var(--muted); font-size: 10px; padding: 6px 2px; border-radius: 12px;
        display: flex; flex-direction: column; align-items: center; gap: 3px; transition: var(--trans);
    }
    .bottom-nav a i { font-size: 18px; }
    .bottom-nav a.active { color: var(--accent-2); }
    .bottom-nav a.fab {
        margin-top: -26px; background: linear-gradient(135deg, var(--accent), #a30400); color: #fff;
        width: 54px; height: 54px; border-radius: 50%; flex: none; justify-content: center;
        box-shadow: 0 8px 22px var(--accent-glow); align-self: center;
    }
    .bottom-nav a.fab span { display: none; }
}

/* ===== Responsive sidebar ===== */
.sidebar-backdrop { display: none; }
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar .btn-burger { display: inline-grid; }
    .content { padding: 16px 14px 90px; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1035; }
}

/* ===== Misc helpers ===== */
.text-muted-2 { color: var(--muted) !important; }
.text-accent { color: var(--accent-2) !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state i { font-size: 52px; opacity: .35; margin-bottom: 14px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, #25252c 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0%{ background-position: 100% 0;} 100%{ background-position: -100% 0; } }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* dropdown menu dark */
.dropdown-menu { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.dropdown-item { color: var(--text); border-radius: 8px; padding: 8px 12px; }
.dropdown-item:hover { background: var(--surface); color: #fff; }
.dropdown-divider { border-color: var(--border); }

/* modal dark */
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); }
.btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* select2 dark theming */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    background: var(--bg-2) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; min-height: 42px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--text); line-height: 40px; padding-left: 12px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; }
.select2-dropdown { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--accent); }
.select2-search--dropdown .select2-search__field { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); }
.select2-container--default .select2-selection--multiple .select2-selection__choice { background: var(--accent); border: none; color: #fff; }

/* DataTables dark */
.dataTables_wrapper { color: var(--muted); }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--accent) !important; border: none !important; border-radius: 8px; color: #fff !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--surface-2) !important; border: none !important; color: #fff !important; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; }
table.dataTable tbody tr { background: transparent; }
