﻿/* ============================================================
   VARIABLES & RESET
   ============================================================ */
:root {
    --bg-base: #0b0b0e;
    --bg-surface: #151519;
    --bg-surface-2: #1c1c22;
    --border-line: #27272f;
    --text-slate-200: #e2e8f0;
    --text-slate-300: #cbd5e1;
    --text-slate-400: #94a3b8;
    --text-slate-500: #64748b;
    --text-slate-600: #475569;
    --color-crank-400: #d85862;
    --color-crank-500: #c9333f;
    --color-crank-600: #9b1c1f;
    --color-violet-400: #a78bfa;
    --color-violet-500: #8b5cf6;
    --color-amber-400: #fbbf24;
    --color-amber-500: #f59e0b;
    --color-emerald-400: #34d399;
    --color-emerald-500: #10b981;
    --shadow-glow: 0 0 0 1px rgba(201,51,63,.25), 0 8px 24px -8px rgba(201,51,63,.35);
}

/* Light mode variables */
body.light-mode {
    --bg-base: #e8e0d8;
    --bg-surface: #f0eae3;
    --bg-surface-2: #f5f0eb;
    --border-line: #d5ccc2;
    --text-slate-200: #2d2822;
    --text-slate-300: #3d3730;
    --text-slate-400: #5a5248;
    --text-slate-500: #756b5f;
    --text-slate-600: #9a8e80;
}

/* ============================================================
   BASE
   ============================================================ */
html, body {
    height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-base);
    color: var(--text-slate-200);
}

.font-display {
    font-family: 'Big Shoulders Display', sans-serif;
}

.bg-base {
    background: var(--bg-base);
}

.bg-surface {
    background: var(--bg-surface);
}

.border-line {
    border-color: var(--border-line);
}

.text-slate-200 {
    color: var(--text-slate-200);
}

.text-slate-300 {
    color: var(--text-slate-300);
}

.text-slate-400 {
    color: var(--text-slate-400);
}

.text-slate-500 {
    color: var(--text-slate-500);
}

.text-slate-600 {
    color: var(--text-slate-600);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sub-nav {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s ease;
}

    .sub-nav.open {
        max-height: 800px;
    }

.group-header {
    cursor: pointer;
    user-select: none;
}

    .group-header .chev {
        transition: transform .25s ease;
    }

    .group-header.open .chev {
        transform: rotate(90deg);
    }

.nav-link.active {
    background: rgba(245,158,11,.18);
    color: #fbbf24;
    font-weight: 600;
}

.nav-link.active-vi {
    background: rgba(139,92,246,.18);
    color: #a78bfa;
    font-weight: 600;
}

.sidebar-toggle-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    left: 256px;
    z-index: 999;
    width: 22px;
    height: 52px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-line);
    border-left: none;
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-slate-400);
}

    .sidebar-toggle-btn:hover {
        background: var(--bg-surface);
        color: #fff;
        border-color: var(--color-amber-400);
        width: 26px;
    }

    .sidebar-toggle-btn.closed {
        left: 0;
        background: var(--color-amber-500);
        color: #fff;
        border-color: var(--color-amber-500);
    }

        .sidebar-toggle-btn.closed i {
            transform: rotate(180deg);
        }

@media (max-width: 767px) {
    .sidebar-toggle-btn {
        display: none !important;
    }
}

/* Mobile off-canvas */
@media (max-width: 767px) {
    #store-sidebar, #crm-sidebar, #erp-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        z-index: 1200;
        transform: translateX(-100%);
        transition: transform .3s ease;
        display: flex !important;
    }

        #store-sidebar.mobile-open, #crm-sidebar.mobile-open, #erp-sidebar.mobile-open {
            transform: translateX(0);
        }

    #mobileSidebarOverlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.6);
        z-index: 1190;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }

        #mobileSidebarOverlay.open {
            opacity: 1;
            pointer-events: auto;
        }
}

#store-nav, #crm-nav, #erp-nav {
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-amber-500) transparent;
}

    #store-nav::-webkit-scrollbar, #crm-nav::-webkit-scrollbar, #erp-nav::-webkit-scrollbar {
        width: 4px;
    }

    #store-nav::-webkit-scrollbar-thumb, #crm-nav::-webkit-scrollbar-thumb, #erp-nav::-webkit-scrollbar-thumb {
        background: var(--color-amber-500);
        border-radius: 4px;
    }

/* ============================================================
   TOPBAR
   ============================================================ */
.bell-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: .15s;
    max-width: 90vw;
}

    .bell-panel.open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

.user-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: .15s;
    max-width: 90vw;
}

    .user-panel.open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    animation: toastIn .2s ease, toastOut .25s ease 2.6s forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* ============================================================
   MODAL
   ============================================================ */
#modalRoot {
    position: fixed;
    inset: 0;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
}

    #modalRoot.open {
        opacity: 1;
        pointer-events: auto;
    }

#modalOverlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(2px);
}

#modalBox {
    animation: modalIn .16s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.96) translateY(6px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#modalBody::-webkit-scrollbar {
    width: 6px;
}

#modalBody::-webkit-scrollbar-thumb {
    background: var(--color-crank-400);
    border-radius: 4px;
}

/* ============================================================
   RESPONSIVE TABLE / CARD TOGGLE (shared)
   ============================================================ */
.rtable-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px 0;
}

.rtable-wrap {
    padding-bottom: 12px;
}

.rtable-toolbar .rtable-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-line);
    background: var(--bg-surface-2);
    color: var(--text-slate-400);
    cursor: pointer;
    font-size: 13px;
    transition: .15s;
}

    .rtable-toolbar .rtable-btn:hover {
        color: #e2e8f0;
        border-color: #3a3a45;
    }

    .rtable-toolbar .rtable-btn.active {
        background: var(--color-amber-500);
        border-color: var(--color-amber-500);
        color: #0b0b0e;
    }

.rtable-scroll {
    overflow-x: auto;
}

.rtable-cards table {
    display: block;
    width: 100%;
}

.rtable-cards thead {
    display: none;
}

.rtable-cards tbody {
    display: block;
    padding: 0 14px;
}

.rtable-cards tr {
    display: block;
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--border-line);
    border-radius: 12px;
    background: var(--bg-surface);
}

.rtable-cards td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    border: 0 !important;
    text-align: right;
    white-space: normal;
}

    .rtable-cards td:not(:last-child) {
        border-bottom: 1px dashed #1f1f26 !important;
    }

    .rtable-cards td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--text-slate-500);
        text-align: left;
        flex-shrink: 0;
    }

/* ============================================================
   SWITCH
   ============================================================ */
.switch {
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #2a2a32;
    position: relative;
    transition: .15s;
    cursor: pointer;
    flex-shrink: 0;
}

    .switch.on {
        background: var(--color-amber-500);
    }

    .switch .dot {
        position: absolute;
        top: 2px;
        left: 2px;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #fff;
        transition: .15s;
    }

    .switch.on .dot {
        transform: translateX(16px);
    }
