/* ============================================================
   VELOCE DEALER PORTAL
   ============================================================ */
:root {
    --primary: #1a8fc4;
    --primary-dark: #14729e;
    --primary-light: #e8f4fa;
    --accent: #f9445a;
    --accent-hover: #e03248;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 16px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.10);
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --speed: 0.2s ease;
}
/* DARK THEME */
[data-theme="dark"] {
    --bg:           #0f172a;
    --surface:      #1e293b;
    --text:         #e2e8f0;
    --muted:        #94a3b8;
    --border:       #334155;
    --primary:      #38bdf8;
    --primary-dark: #0ea5e9;
    --primary-light:#0c2d3f;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
    --shadow:       0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:    0 10px 40px rgba(0,0,0,0.6);
}
tr.row-outdated td                  { background:#fef2f2; }
tr.row-current td                   { background:#fefce8; }
[data-theme="dark"] tr.row-outdated td { background:#2d1515; }
[data-theme="dark"] tr.row-current td  { background:#1c1a06; }
[data-theme="dark"] .alert-success { background:#052e16; color:#86efac; border-color:#166534; }
[data-theme="dark"] .alert-error   { background:#450a0a; color:#fca5a5; border-color:#991b1b; }
[data-theme="dark"] .alert-info    { background:#0c2d3f; color:#38bdf8; border-color:#0369a1; }
[data-theme="dark"] .badge-dealer   { background:#451a03; color:#fcd34d; }
[data-theme="dark"] .badge-internal { background:#431407; color:#fed7aa; }
[data-theme="dark"] .login-wrapper { background: linear-gradient(135deg,#020617 0%,#0f172a 50%,#0c2d3f 100%); }
[data-theme="dark"] tr:hover td    { background: rgba(56,189,248,.05); }
[data-theme="dark"] .upload-zone:hover,
[data-theme="dark"] .upload-zone.dragover { background: var(--primary-light); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; transition: background .2s, color .2s; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* NAV */
.main-nav { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); }
.nav-inner { width: 100%; padding: 0 2.5rem; height: 60px; display: flex; align-items: center; gap: 2rem; }
.nav-brand { display: flex; align-items: center; gap: .5rem; color: var(--primary); font-weight: 800; font-size: 1.1rem; letter-spacing: 3px; }
.nav-links { display: flex; gap: .25rem; flex: 1; }
.nav-link { padding: .45rem 1rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; color: var(--muted); transition: all var(--speed); }
.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active { color: var(--primary); background: var(--primary-light); }
.nav-user { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }
.nav-user-name { font-weight: 600; font-size: .85rem; }
.nav-badge { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .5px; }
.badge-admin    { background: var(--primary-light); color: var(--primary); }
.badge-dealer   { background: #fef3c7; color: #92400e; }
.badge-internal { background: #fff7ed; color: #c2410c; }

/* LAYOUT */
.container { width: 100%; padding: 2rem 2.5rem; flex: 1; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; }

/* CARD */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.card-header h2 { font-size: 1.1rem; font-weight: 700; }
.card-body { padding: 1.5rem; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem 1.25rem; border: none; border-radius: var(--radius-sm); font-family: var(--font); font-weight: 600; font-size: .85rem; cursor: pointer; transition: all var(--speed); text-decoration: none; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--muted); }
.btn-outline:hover { border-color: var(--muted); color: var(--text); }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }

/* FORMS */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .4rem; }
.form-control { width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); font-size: .9rem; transition: border-color var(--speed); background: var(--surface); color: var(--text); }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,143,196,.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* FILE LIST */
.file-list { list-style: none; }
.file-item { display: flex; align-items: center; gap: 1.25rem; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); transition: background var(--speed); }
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg); }
.file-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 800; font-size: .65rem; letter-spacing: .5px; text-transform: uppercase; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 700; font-size: 1rem; color: var(--primary); margin-bottom: .15rem; }
.file-meta { font-size: .8rem; color: var(--muted); display: flex; gap: 1rem; flex-wrap: wrap; }
.file-desc { margin-top: .4rem; font-size: .85rem; color: var(--muted); }
.file-actions { flex-shrink: 0; display: flex; flex-direction: column; gap: .35rem; align-items: flex-end; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
th { font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--bg); }
tr:hover td { background: rgba(26,143,196,.03); }

/* ALERTS */
.alert { padding: .9rem 1.25rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 500; margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border-color: #bae6fd; }

/* LOGIN */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1a8fc4 100%); padding: 1rem; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 2.5rem; }
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 { font-size: 1rem; letter-spacing: 5px; color: var(--primary); font-weight: 800; }
.login-brand p { color: var(--muted); font-size: .85rem; margin-top: .25rem; }

/* LICENSE DETAIL */
.license-detail-layout { grid-template-columns: 300px 340px; }
.license-grid { display: grid; grid-template-columns: repeat(2, 200px 1fr); }
.license-grid dt { padding: .6rem 1rem; font-weight: 600; font-size: .82rem; background: var(--bg); border-bottom: 1px solid var(--border); }
.license-grid dd { padding: .6rem 1rem; font-size: .85rem; border-bottom: 1px solid var(--border); }
.license-flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.license-flag-item { display: flex; justify-content: space-between; align-items: center; padding: .4rem 1rem; border-bottom: 1px solid var(--border); gap: .5rem; }
.license-flag-item span:first-child { font-size: .82rem; font-weight: 600; }
.feature-on  { color: var(--success); font-weight: 700; }
.feature-off { color: var(--danger);  font-weight: 700; }

/* MODAL */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:500; display:flex; align-items:center; justify-content:center; padding:1rem; }
.modal-box { background:var(--surface); border-radius:var(--radius); box-shadow:var(--shadow-lg); max-width:540px; width:100%; padding:2rem; position:relative; max-height:90vh; overflow-y:auto; }
.modal-box h2 { font-size:1.1rem; font-weight:800; margin-bottom:1.25rem; color:var(--text); }
.modal-close { position:absolute; top:.9rem; right:1rem; background:none; border:none; cursor:pointer; font-size:1.4rem; line-height:1; color:var(--muted); padding:0; }
.modal-close:hover { color:var(--text); }

/* NOTICE ROWS */
.notice-row { border-radius:8px; padding:.85rem 1.1rem; border:1.5px solid; font-size:.9rem; line-height:1.5; }
.notice-row[data-level="high"]   { background:#fef2f2; border-color:#fca5a5; color:#991b1b; }
.notice-row[data-level="medium"] { background:#fffbeb; border-color:#fcd34d; color:#92400e; }
.notice-row[data-level="low"]    { background:#f0fdf4; border-color:#86efac; color:#166534; }
.notice-row textarea.form-control { background:var(--surface); }
[data-theme="dark"] .notice-row[data-level="high"]   { background:#2d1515; border-color:#7f1d1d; color:#fca5a5; }
[data-theme="dark"] .notice-row[data-level="medium"] { background:#2a2010; border-color:#78350f; color:#fcd34d; }
[data-theme="dark"] .notice-row[data-level="low"]    { background:#0f2318; border-color:#14532d; color:#86efac; }

/* 2FA BANNER */
.banner-2fa { background:#fef2f2; color:#991b1b; border:1px solid #fecaca; border-radius:var(--radius-sm); padding:.75rem 1.25rem; font-size:.88rem; font-weight:500; margin-bottom:1.25rem; text-align:center; }
.banner-2fa a { color:#991b1b; font-weight:700; text-decoration:underline; }
.banner-2fa a:hover { color:#7f1d1d; }
[data-theme="dark"] .banner-2fa { background:#450a0a; color:#fca5a5; border-color:#991b1b; }
[data-theme="dark"] .banner-2fa a { color:#fca5a5; }
[data-theme="dark"] .banner-2fa a:hover { color:#fecaca; }

/* UPLOAD ZONE */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 3rem 2rem; text-align: center; cursor: pointer; transition: all var(--speed); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone p { color: var(--muted); font-size: .9rem; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* EMPTY / MISC */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.site-footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); margin-top: auto; }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

/* HAMBURGER BUTTON (hidden on desktop) */
.nav-hamburger {
    display: none;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .35rem .65rem;
    cursor: pointer;
    color: var(--text);
    font-size: 1.25rem;
    line-height: 1;
    transition: all var(--speed);
    flex-shrink: 0;
}
.nav-hamburger:hover { background: var(--bg); }

/* RESPONSIVE */
@media (max-width: 992px) {
    .col-hide-md { display: none; }
}
@media (max-width: 768px) {
    .col-hide-sm { display: none; }

    /* Prevents iOS Safari from zooming in when tapping inputs */
    .form-control { font-size: 16px; }

    /* Login */
    .login-wrapper { align-items: flex-start; padding: 2rem 1rem; }
    .login-brand img { height: 56px; }
    .login-brand { margin-bottom: 1.5rem; }

    /* Nav */
    .nav-inner { gap: .4rem; padding: 0 1rem; }
    .nav-hamburger { display: flex; align-items: center; justify-content: center; }
    .nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0; right: 0;
        flex-direction: column;
        gap: .1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
        padding: .75rem 1rem 1rem;
        z-index: 99;
    }
    .nav-links.mobile-open { display: flex; }
    .nav-links .nav-link { padding: .7rem .75rem; font-size: .95rem; }
    .nav-user { gap: .35rem; }
    .nav-user-name { display: none; }
    .nav-badge { display: none; }
    .nav-view-toggle { display: none !important; }
    .nav-dealer-name { display: none !important; }

    /* Layout */
    .container { padding: 1rem; }
    .card-header { padding: 1rem; }
    .card-body { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 1.3rem; }

    /* File list */
    .file-item { flex-wrap: wrap; gap: .75rem; padding: 1rem; }
    .file-actions {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: .4rem;
    }

    /* License */
    .license-grid { grid-template-columns: 140px 1fr; }
    .license-flag-grid { grid-template-columns: 1fr; }
    .license-detail-layout { grid-template-columns: 1fr !important; }

    /* Forms */
    .form-row { grid-template-columns: 1fr; }

    /* Upload */
    .upload-zone { padding: 2rem 1rem; }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .nav-inner { padding: 0 .75rem; }
    .container { padding: .75rem; }
    .card-header { padding: .75rem 1rem; }
    .card-body { padding: .75rem 1rem; }
    .file-item { padding: .75rem; }
    .login-card { padding: 1.5rem 1.25rem; }
    .login-brand { margin-bottom: 1rem; }
    .login-brand img { height: 48px; }
}

/* Dashboard chart split layout */
.chart-split { display: flex; align-items: flex-start; gap: 0; flex-wrap: wrap; }
.chart-split-golden {
    display: flex; flex-direction: column; gap: .75rem;
    padding-right: 2rem; margin-right: 2rem;
    border-right: 1px solid var(--border);
}
@media (max-width: 768px) {
    .chart-split { flex-direction: column; }
    .chart-split-golden {
        padding-right: 0; margin-right: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1.25rem; margin-bottom: 1.25rem;
    }
}
