/* =====================================================================
   MAIN.CSS — foundation layer
   Design tokens, reset, base typography, and the app shell layout
   (sidebar / topbar / overlay). Loaded after app.css/admin.css so it
   wins the cascade as those files get drained module by module.
   See simaset-redesign-strategy.md §7 for the design direction.
===================================================================== */

/* ── DESIGN TOKENS ───────────────────────────────────────────────── */
/*
   Light is the default palette (project default as of the theme
   toggle). Dark is opt-in via [data-theme="dark"] on <html>, set by
   admin.js's toggleTheme() and persisted to localStorage — see the
   blocking inline script in templates/header.php that applies the
   stored preference before first paint, to avoid a flash of the
   wrong theme on load.
*/
:root {
    /* Surfaces (cool blue-gray undertone, matched to brand-accent's own
       slate character — was warmer/cream on the first pass, this pass
       swaps the whole light neutral family to sit in the same cool
       family as the accent instead of clashing warmer than it) */
    --surface-base:    #f3f5f7;
    --surface-raised:  #ffffff;
    --surface-sidebar: #eaedf0;
    --border-subtle:   #d5dbe0;

    /* Text */
    --text-primary:   #1e2428;
    --text-secondary: #55606a;
    --text-muted:     #838d96;

    /* Accent — slate blue-gray, deepened slightly from the first pass
       so it still reads more saturated than the now-cooler neutrals
       around it, instead of blending in */
    --brand-accent:       #56626f;
    --brand-accent-hover: #45505c;
    --brand-accent-muted: rgba(86, 98, 111, 0.12);

    /* Status (mapped to the enum values in the schema) — unchanged
       across themes, these are already mid-saturation tones that
       read fine on both a dark and a white surface */
    --status-active:  #5fb98a; /* Aktif / Approved */
    --status-danger:  #d97878; /* Rusak / Rejected */
    --status-warning: #c9a45a; /* Maintenance / Pending */
    --status-neutral: #6b7078; /* Nonaktif */

    /* Shape & motion */
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --shadow-raised: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-modal:  0 12px 40px rgba(0, 0, 0, 0.16);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout constants */
    --sidebar-width: 260px;
    --topbar-height: 60px;
}

/* ── DARK THEME (opt-in) ─────────────────────────────────────────── */
/* This is the palette the whole redesign shipped with up to this
   point — unchanged, just moved behind an attribute instead of being
   the only option. */
[data-theme="dark"] {
    --surface-base:    #1e1e1d;
    --surface-raised:  #2c2c2a;
    --surface-sidebar: #1a1a19;
    --border-subtle:   #3a3a37;

    --text-primary:   #ededea;
    --text-secondary: #a8a6a1;
    --text-muted:     #77756f;

    --brand-accent:       #7c8797;
    --brand-accent-hover: #96a1b0;
    --brand-accent-muted: rgba(124, 135, 151, 0.14);

    --shadow-raised: 0 4px 16px rgba(0, 0, 0, 0.28), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-modal:  0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ── RESET ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ── BASE TYPOGRAPHY ─────────────────────────────────────────────── */
body {
    background: var(--surface-base);
    color: var(--text-primary);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* IDs/codes: kode_asset, primary keys, QR payload text */
.font-mono,
.mono {
    font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

/* Tabular data alignment wherever numbers/dates appear */
.tabular-nums,
.data-table td {
    font-variant-numeric: tabular-nums;
}

a { color: var(--brand-accent); }
a:hover { color: var(--brand-accent-hover); }

/* Themed text selection — was falling back to the browser's default
   near-white highlight, unreadable against light --text-primary on a
   dark page. Global fix per §11 table-polish notes. */
::selection {
    background: var(--brand-accent);
    color: var(--surface-base);
}

/* ── APP SHELL ───────────────────────────────────────────────────── */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface-sidebar);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    z-index: 999;
    border-right: 1px solid var(--border-subtle);
}

.admin-main {
    flex: 1;
    min-width: 0; /* flex items default to min-width:auto, which refuses to
                     shrink below content width — a wide table would otherwise
                     force the whole page to scroll horizontally instead of
                     just .data-table-wrapper */
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--surface-base);
}

/* ── SIDEBAR LOGO / BRAND ────────────────────────────────────────── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--surface-raised);
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.sidebar-role-label {
    font-size: 11px;
    margin-top: 4px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ── SIDEBAR NAV ─────────────────────────────────────────────────── */
.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 14px 20px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 2px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.sidebar-link i { width: 18px; text-align: center; }

.sidebar-link:hover {
    background: var(--surface-raised);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--brand-accent-muted);
    color: var(--text-primary);
}

.sidebar-bottom {
    margin-top: auto;
    padding: 14px 0 20px;
    border-top: 1px solid var(--border-subtle);
}

/* ── TOPBAR ──────────────────────────────────────────────────────── */
.admin-topbar {
    height: var(--topbar-height);
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-topbar-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.admin-topbar-user {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--surface-base);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--surface-raised);
    color: var(--text-primary);
}

.admin-content { padding: 28px; }

/* ── MOBILE HAMBURGER + OFF-CANVAS ──────────────────────────────── */
.admin-hamburger {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}

.admin-hamburger:hover { background: var(--surface-raised); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 998;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 250ms ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 992px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .admin-main { margin-left: 0; }

    .admin-hamburger { display: flex; }
}

/* ── PRINT ───────────────────────────────────────────────────────── */
/*
   First page in the app with a Print button (asset QR label). Without
   this, printing dumped the whole dark admin shell — sidebar, topbar,
   action buttons and all — onto the page. Re-points the theme's own
   CSS variables to light-mode values for the print pass, so every
   component (app-card, detail-list, etc.) that already consumes those
   variables prints legibly without needing per-component overrides.
   `.print-hide` is a general-purpose utility any page can use to keep
   its own on-screen-only chrome (buttons, headers) out of the printout.
*/
@media print {

    :root {
        --surface-base:    #ffffff;
        --surface-raised:  #ffffff;
        --surface-sidebar: #ffffff;
        --text-primary:    #1a1a1a;
        --text-secondary:  #4a4a4a;
        --text-muted:      #6b6b6b;
        --border-subtle:   #dddddd;
    }

    .admin-sidebar,
    .admin-topbar,
    .print-hide {
        display: none !important;
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-content {
        padding: 0;
    }

    body {
        background: #ffffff;
    }

    .app-card {
        box-shadow: none;
        border: none;
    }

}