/* frontend/css/style.css */
:root {
    /* Color Palette - Premium Dark Theme */
    --bg-base: #0f1115;
    --bg-panel: rgba(25, 28, 36, 0.65);
    --border-glass: rgba(255, 255, 255, 0.08);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    
    /* Primary Accents */
    --accent-primary: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --accent-gradient: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    
    /* Functional Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Light Mode Override */
[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(0, 0, 0, 0.05);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow-glass: 0 8px 32px 0 rgba(100, 116, 139, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow: hidden; /* App-like feel */
    transition: background-color 0.3s ease;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

/* Layout - Horizontal Top Nav */
.top-nav-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 10px;
    gap: 10px;
}

/* Top Navbar */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}
.brand i {
    color: var(--accent-primary);
    font-size: 24px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.nav-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 4px;
}

.nav-links li {
    position: relative;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-links li a i {
    font-size: 18px;
}

.nav-links li:hover > a {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links li.active > a {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

/* Dropdown Menu */
.has-dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 105;
    margin-top: 5px;
}
.has-dropdown:hover .dropdown-menu {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}
.dropdown-menu li a {
    padding: 10px 14px;
    width: 100%;
}

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

.user-profile-micro .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 12px;
}

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
}

/* Actions logic */
.actions {
    display: flex;
    gap: 12px;
}
.action-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}
.action-btn:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.05);
}
.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dashboard Views */
.view-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-bottom: 20px;
}
.view-content::-webkit-scrollbar { display: none; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
}
.premium-color-1::before { background: var(--accent-primary); }
.premium-color-2::before { background: var(--warning); }
.premium-color-3::before { background: var(--success); }
.premium-color-4::before { background: #8b5cf6; }

.stat-icon {
    font-size: 32px;
    color: var(--text-muted);
}
.premium-color-1 .stat-icon { color: var(--accent-primary); }
.premium-color-2 .stat-icon { color: var(--warning); }
.premium-color-3 .stat-icon { color: var(--success); }
.premium-color-4 .stat-icon { color: #8b5cf6; }

.stat-details h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}
.stat-details h2 {
    font-size: 24px;
    margin: 4px 0;
    font-weight: 700;
}
.stat-details span {
    font-size: 12px;
    color: var(--success);
}
.premium-color-2 span { color: var(--warning); }

/* AI Widget */
.ai-widget {
    padding: 24px;
}
.widget-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.text-gradient {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 24px;
}
.widget-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.alert-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 16px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-md);
    border-left: 3px solid transparent;
}
.alert-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}
.alert-dot.w-warning { background: var(--warning); box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); }
.alert-dot.w-danger { background: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }

.alert-item p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
}
.alert-item p strong { color: var(--text-main); }
.alert-item p em { color: var(--accent-primary); font-style: normal; font-weight: 500; }

/* Micro-animations */
.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.mt-20 { margin-top: 20px; }

/* -------------------------------------
   Notifications Tray & Modals
-------------------------------------- */
.notification-wrapper {
    position: relative;
}

.notification-dropdown {
    position: fixed;
    top: 75px;
    right: 30px;
    width: 320px;
    max-height: 450px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    box-shadow: var(--shadow-glass);
}

.notification-dropdown.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.tray-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tray-header h4 { font-size: 14px; font-weight: 600; }

.btn-micro {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    display: flex; gap: 4px; align-items: center;
}

.tray-body {
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-msg {
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(0,0,0,0.15);
    border-left: 3px solid var(--text-muted);
}
[data-theme="light"] .alert-msg { background: rgba(0,0,0,0.03); }

.alert-msg h5 { margin-bottom: 4px; font-size: 13px; color: var(--text-main); display: flex; justify-content:space-between; }
.alert-msg h5 span { font-size: 10px; color: var(--text-muted); font-weight:normal; }
.alert-msg p { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.alert-msg.WARNING { border-left-color: var(--warning); }
.alert-msg.DANGER { border-left-color: var(--danger); }
.alert-msg.INFO { border-left-color: var(--accent-primary); }
.alert-msg.SUCCESS { border-left-color: var(--success); }

/* Modal genérico */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease-out;
}
.modal-content {
    background: var(--bg-base); width: 400px; padding: 24px;
    border-radius: var(--radius-lg); border: 1px solid var(--border-glass);
}
.modal-content h3 { margin-bottom: 16px; font-size: 18px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px;
    background: rgba(0,0,0,0.1); border: 1px solid var(--border-glass);
    border-radius: 8px; color: var(--text-main); font-family: inherit;
    outline: none; transition: border 0.3s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent-primary);
}
.btn-block {
    width: 100%; padding: 12px; background: var(--success);
    color: white; border: none; border-radius: 8px; font-weight: bold; cursor: pointer;
}

/* MOBILITY EXTENSION (Responsiveness for Mobile / Smartphones) */
.mobile-menu-btn { display: none; }

@media (max-width: 900px) {
    .nav-container {
        display: none; /* Hide horizontal nav links */
        position: fixed;
        top: 70px;
        left: 0;
        width: 100vw;
        height: auto;
        background: var(--bg-panel);
        backdrop-filter: blur(15px);
        flex-direction: column;
        z-index: 999;
        padding: 20px;
        border-bottom: 1px solid var(--border-glass);
    }
    
    .nav-container.mobile-open {
        display: flex;
        animation: fadeIn 0.2s ease-out;
    }

    .nav-links {
        flex-direction: column;
    }
    .has-dropdown .dropdown-menu {
        position: relative;
        display: flex;
        background: rgba(0,0,0,0.1);
        border: none;
        box-shadow: none;
    }

    .mobile-menu-btn { display: flex; }

    /* Remove brand text on very small screens */
    .brand span { display: none; }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 998;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.active { display: block; }

    /* Dashboard grid to single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* POS Terminal layout stack */
    .view-pos {
        height: auto !important;
    }
    .view-pos > div {
        flex-direction: column;
        height: auto !important;
    }
    .view-pos .glass-panel[style*="flex: 2"], 
    .view-pos .glass-panel[style*="flex: 1"] {
        flex: none !important;
        height: auto !important;
        width: 100%;
    }
    #pos-cart-list {
        max-height: 300px;
        min-height: 200px;
    }

    /* Catalogs text resizing */
    table th, table td {
        padding: 8px 5px !important;
        font-size: 11px !important;
    }
    
    /* Preventa specifics */
    #route-catalog-section {
        flex-direction: column;
    }
    
    .client-card { flex-direction: column; align-items: flex-start !important; gap: 10px; }
    .client-card button { width: 100%; }
}

/* Light Mode Overrides for hardcoded RGBA styles in JS */
[data-theme="light"] button[style*="rgba(255,255,255,0.1)"],
[data-theme="light"] .btn-micro[style*="rgba(255,255,255,0.1)"] {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: var(--text-main) !important;
}

[data-theme="light"] button.pos-qty-minus, 
[data-theme="light"] button.pos-qty-plus {
    color: var(--text-main) !important;
}

[data-theme="light"] td[style*="rgba(255,255,255,0.1)"],
[data-theme="light"] div[style*="rgba(255,255,255,0.1)"] {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: var(--text-main) !important;
}

[data-theme="light"] tr[style*="rgba(255,255,255,0.05)"],
[data-theme="light"] div[style*="rgba(255,255,255,0.05)"],
[data-theme="light"] li[style*="rgba(255,255,255,0.05)"] {
    border-color: rgba(0, 0, 0, 0.05) !important;
}

/* Fix product image placeholder icon in light mode */
[data-theme="light"] div[style*="width:45px;height:45px;background:rgba(255,255,255,0.1)"] i {
    color: var(--text-main) !important;
}
