/* =============================================================================
   TeDaCo ERP — Design System v2
   Sidebar Navigation + Enhanced Tokens
   Extension over style.css
============================================================================= */

/* --- New Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Enhanced Spacing Scale */
    --space-2xs: 0.125rem;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --topbar-height: 56px;

    /* Sidebar specific */
    --sidebar-bg: #0d0d14;
    --sidebar-item-hover: rgba(99, 102, 241, 0.08);
    --sidebar-item-active: rgba(99, 102, 241, 0.15);
    --sidebar-item-active-border: #6366f1;
    --sidebar-text: #7c7c96;
    --sidebar-section: #3a3a55;

    /* Badge colors */
    --badge-danger-bg: rgba(239, 68, 68, 0.15);
    --badge-danger-text: #f87171;
    --badge-warning-bg: rgba(245, 158, 11, 0.15);
    --badge-warning-text: #fbbf24;
    --badge-success-bg: rgba(16, 185, 129, 0.15);
    --badge-success-text: #34d399;
    --badge-info-bg: rgba(59, 130, 246, 0.15);
    --badge-info-text: #60a5fa;

    /* Fonts */
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Skeleton Loading */
    --skeleton-base: rgba(255, 255, 255, 0.05);
    --skeleton-shine: rgba(255, 255, 255, 0.10);

    /* Elevation levels */
    --elevation-1: 0 1px 3px rgba(0, 0, 0, 0.3);
    --elevation-2: 0 4px 12px rgba(0, 0, 0, 0.4);
    --elevation-3: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* =============================================================================
   FULL APP SHELL LAYOUT (Sidebar + Main)
============================================================================= */

body {
    font-family: var(--font-sans);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: width var(--transition-normal);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    min-height: 80px;
    text-decoration: none;
    overflow: hidden;
}

.sidebar-brand-logo {
    width: 100%;
    height: auto;
    max-height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.2));
    transition: opacity var(--transition-normal);
}

.sidebar.collapsed .sidebar-brand-logo {
    opacity: 0;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-sm) 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar-section-label {
    padding: var(--space-sm) var(--space-md) var(--space-xs);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sidebar-section);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-section-label {
    opacity: 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    margin: 1px var(--space-xs);
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    width: calc(100% - var(--space-sm));
    text-align: left;
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    border-left: 2px solid transparent;
    text-decoration: none;
}

.sidebar-item:hover {
    color: var(--text-primary);
    background: var(--sidebar-item-hover);
}

.sidebar-item.active {
    color: #818cf8;
    background: var(--sidebar-item-active);
    border-left-color: var(--sidebar-item-active-border);
}

.sidebar-item-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-item-label {
    flex: 1;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-item-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 100px;
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-badge {
    opacity: 0;
}

/* Collapse Button */
.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: var(--space-sm);
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-collapse-btn:hover {
    color: var(--text-primary);
    background: var(--sidebar-item-hover);
}

.sidebar-collapse-icon {
    font-size: 1rem;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.sidebar.collapsed .sidebar-collapse-icon {
    transform: rotate(180deg);
}

.sidebar-collapse-label {
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-collapse-label {
    opacity: 0;
}

/* =============================================================================
   MAIN AREA (shifts right of sidebar)
============================================================================= */

.app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.sidebar.collapsed~.main-wrapper,
body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Bar (replaces old .header) */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Command Palette Trigger */
.cmd-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 180px;
}

.cmd-trigger:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.cmd-trigger kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0 4px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    margin-left: auto;
}

/* Notification Bell */
.notif-btn {
    position: relative;
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.notif-btn:hover {
    border-color: var(--accent-primary);
    background: var(--sidebar-item-hover);
}

.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    background: var(--accent-danger);
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: var(--space-xl);
    max-width: none;
    /* sidebar handles the constraint */
}

/* =============================================================================
   COMMAND PALETTE
============================================================================= */

.cmd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.cmd-overlay.open {
    display: flex;
    animation: cmdFadeIn 0.15s ease;
}

@keyframes cmdFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.cmd-palette {
    width: 560px;
    max-width: 90vw;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.2);
    overflow: hidden;
    animation: cmdSlideIn 0.15s ease;
}

@keyframes cmdSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cmd-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.cmd-search-icon {
    font-size: 1rem;
    color: var(--text-secondary);
}

.cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-sans);
}

.cmd-input::placeholder {
    color: var(--text-muted);
}

.cmd-results {
    max-height: 320px;
    overflow-y: auto;
    padding: var(--space-xs) 0;
}

.cmd-section-label {
    padding: var(--space-xs) var(--space-lg);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cmd-result-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.cmd-result-item:hover,
.cmd-result-item.selected {
    background: var(--sidebar-item-active);
}

.cmd-result-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

.cmd-result-text {
    flex: 1;
}

.cmd-result-title {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.cmd-result-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cmd-result-kbd {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
}

.cmd-footer {
    padding: var(--space-xs) var(--space-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: var(--space-md);
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* =============================================================================
   SKELETON LOADING
============================================================================= */

.skeleton {
    background: var(--skeleton-base);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            var(--skeleton-shine) 50%,
            transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 70%;
}

.skeleton-text.full {
    width: 100%;
}

.skeleton-table-row {
    height: 48px;
    margin-bottom: 4px;
}

/* =============================================================================
   MONO NUMBERS (All currency / numeric values)
============================================================================= */

.mono,
.stat-value,
.currency-value {
    font-family: var(--font-mono);
    font-feature-settings: "tnum";
}

/* =============================================================================
   STATUS BADGES (enhanced)
============================================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.badge-success {
    background: var(--badge-success-bg);
    color: var(--badge-success-text);
}

.badge-danger {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
}

.badge-warning {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-text);
}

.badge-info {
    background: var(--badge-info-bg);
    color: var(--badge-info-text);
}

.badge-neutral {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

/* =============================================================================
   MOBILE (Sidebar becomes bottom-nav on mobile)
============================================================================= */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 60px;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
    }

    .sidebar-brand,
    .sidebar-nav .sidebar-section-label,
    .sidebar-collapse-btn,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
        width: 100%;
    }

    .sidebar-item {
        flex-direction: column;
        gap: 2px;
        padding: 8px 12px;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-top: 2px solid transparent;
        min-width: 64px;
        justify-content: center;
        align-items: center;
        text-align: center;
        font-size: 0.65rem;
    }

    .sidebar-item.active {
        border-left-color: transparent;
        border-top-color: var(--sidebar-item-active-border);
    }

    .sidebar-item-label {
        opacity: 1;
        width: auto;
        font-size: 0.65rem;
    }

    .sidebar-item-icon {
        font-size: 1.2rem;
    }

    .sidebar-badge {
        display: none;
    }

    .main-wrapper {
        margin-left: 0;
        margin-bottom: 60px;
    }

    .main-content {
        padding: var(--space-md);
    }

    .topbar {
        padding: 0 var(--space-md);
    }

    .cmd-trigger {
        min-width: unset;
    }

    .cmd-trigger span:not(.cmd-search-icon) {
        display: none;
    }
}

/* =============================================================================
   SCROLLBAR STYLING
============================================================================= */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =============================================================================
   MINI-MODALS (Overlay within Fullscreen Modals)
============================================================================= */

.modal-mini-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-mini-overlay.active {
    display: flex;
    animation: fadeIn 0.15s ease-out;
}

.modal-mini-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.2s ease-out;
}

.modal-mini-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-mini-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}