/* ==========================================================================
   ChileCompra PRO - Core Stylesheet & Design System (Vanilla CSS)
   ========================================================================== */

:root {
    /* Color Palette - Dark Mode (Default) */
    --bg-main: #0a0e17;
    --bg-surface: #111827;
    --bg-surface-elevated: #1a2234;
    --bg-surface-hover: #222d42;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;
    
    /* Brand & Accent Colors */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.25);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    
    /* Status Colors */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.12);

    /* Layout & Geometry */
    --sidebar-width: 270px;
    --header-height: 72px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Shadows & Glassmorphism */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
    --backdrop-blur: blur(12px);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;
    --bg-surface-hover: #e2e8f0;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.2);
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* Global Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .brand-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    line-height: 1.25;
}

code, pre, .badge-code {
    font-family: 'JetBrains Mono', monospace;
}

/* ==========================================================================
   Layout Architecture
   ========================================================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 20px 16px;
    transition: var(--transition-normal);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 18px 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-pro {
    color: var(--primary);
    font-weight: 800;
    margin-left: 2px;
    font-size: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Company Badge */
.company-badge-container {
    padding: 14px 4px;
}

.company-badge {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.company-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.company-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.company-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-rut {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    transition: var(--transition-fast);
    position: relative;
}

.nav-item i {
    font-size: 19px;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.nav-item:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-item:hover i {
    color: var(--primary);
}

.nav-item.active {
    background-color: rgba(59, 130, 246, 0.12);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary);
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background-color: var(--bg-surface-elevated);
    color: var(--text-secondary);
    font-weight: 600;
}

.nav-badge.accent {
    background-color: rgba(139, 92, 246, 0.2);
    color: var(--accent);
}

/* Sidebar Quota Box */
.sidebar-quota-box {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 12px;
}

.quota-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.quota-title {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.quota-numbers {
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
}

.quota-bar-bg {
    width: 100%;
    height: 6px;
    background-color: var(--bg-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 8px;
}

.quota-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.quota-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    color: var(--text-muted);
}

.status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--warning);
}

.status-indicator.live {
    background-color: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Sidebar Footer */
.sidebar-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

.btn-theme-toggle {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    width: 100%;
    justify-content: center;
    transition: var(--transition-fast);
}

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

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
    backdrop-filter: var(--backdrop-blur);
}

.header-left {
    display: flex;
    flex-direction: column;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-search {
    position: relative;
    width: 280px;
}

.quick-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

.quick-search input {
    width: 100%;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 12px 8px 36px;
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition-fast);
    outline: none;
}

.quick-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* View Container */
.view-container {
    padding: 24px 28px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 380px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes toastSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
