/* ==========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --bg-color: #f4f7f6;
    --sidebar-bg: #ffffff;
    --text-main: #222222;
    --text-muted: #777777;
    --neon-blue: #00e1ff;
    --neon-glow: 0 0 15px rgba(0, 225, 255, 0.4);
    --card-shadow: 0 8px 20px rgba(0,0,0,0.05);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
}

/* ==========================================
   2. CORE STRUCTURAL GRID (STRICT LOCK)
   ========================================= */
body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* Prevents whole-page scrolling */
    margin: 0;
    padding: 0;
}

/* The app-wrapper handles the flex layout once logged in */
#app-wrapper {
    /* display: flex is applied via JS upon login */
    width: 100vw;
    height: 100vh;
}

.sidebar-left { 
    width: 250px; 
    background: var(--sidebar-bg); 
    box-shadow: 2px 0 15px rgba(0,0,0,0.03); 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0; /* Absolutely prevents crushing */
    z-index: 10; 
}

.main-content { 
    flex: 1; /* Consumes all middle space */
    padding: 20px; 
    overflow-y: auto; 
    position: relative; 
}

.sidebar-right { 
    width: 320px; 
    background: var(--sidebar-bg); 
    box-shadow: -2px 0 15px rgba(0,0,0,0.03); 
    display: flex; 
    flex-direction: column; 
    padding: 20px; 
    flex-shrink: 0; /* Absolutely prevents crushing */
    z-index: 10;
}

.tab-content { display: none; }
.tab-content.active-tab { display: block; }

/* ==========================================
   3. TYPOGRAPHY & ANIMATIONS
   ========================================= */
.neon-text { color: var(--neon-blue); text-shadow: 0 0 8px rgba(0, 225, 255, 0.5); font-weight: bold;}
.fade-in { animation: fadeIn 0.4s ease-in-out; }

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

@keyframes popIn { 
    0% { transform: scale(0.9); opacity: 0; } 
    100% { transform: scale(1); opacity: 1; } 
}

/* ==========================================
   4. LEFT SIDEBAR (NAVIGATION)
   ========================================= */
.logo-area { padding: 30px 20px; text-align: center; border-bottom: 1px solid #eee; }
.logo-area i { font-size: 2rem; margin-bottom: 10px; }
.nav-links { list-style: none; margin-top: 20px; }
.nav-links li { padding: 15px 25px; margin: 5px 15px; border-radius: 10px; cursor: pointer; transition: var(--transition); font-weight: 500; color: var(--text-muted); }
.nav-links li i { margin-right: 10px; width: 20px; }
.nav-links li:hover, .nav-links li.active { background: var(--neon-blue); color: white; box-shadow: var(--neon-glow); transform: translateX(5px); }

/* ==========================================
   5. MAIN CONTENT (HOME TAB & PRODUCTS)
   ========================================= */
.categories-wrapper { margin-bottom: 20px; overflow-x: auto; padding-bottom: 10px; }
.categories { display: flex; gap: 15px; }
.category-btn { background: white; border: none; padding: 10px 20px; border-radius: 20px; cursor: pointer; font-weight: 600; box-shadow: var(--card-shadow); transition: var(--transition); }
.category-btn.active, .category-btn:hover { background: var(--neon-blue); color: white; box-shadow: var(--neon-glow); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
.product-card { background: white; border-radius: 15px; padding: 15px; text-align: center; cursor: pointer; box-shadow: var(--card-shadow); transition: var(--transition); animation: popIn 0.3s ease-out; }
.product-card:hover { transform: translateY(-8px); box-shadow: 0 15px 25px rgba(0, 225, 255, 0.2); border: 1px solid rgba(0, 225, 255, 0.3); }
.product-img { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background-color: #e2e8f0; }
.product-name { font-weight: 600; margin-bottom: 5px; }
.product-price { color: var(--neon-blue); font-weight: bold; }

/* ==========================================
   6. RIGHT SIDEBAR (CART & CHECKOUT)
   ========================================= */
.sidebar-right h2 { margin-bottom: 20px; font-size: 1.2rem; }
.cart-items { flex: 1; overflow-y: auto; margin-bottom: 20px; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--bg-color); border-radius: 10px; margin-bottom: 10px; animation: fadeIn 0.3s; }
.cart-item-details h4 { font-size: 0.9rem; }
.cart-item-details p { font-size: 0.8rem; color: var(--neon-blue); font-weight: bold;}
.remove-btn { color: #ff4d4d; cursor: pointer; border: none; background: none; font-size: 1.1rem; padding: 5px;}

.cart-summary { background: var(--bg-color); padding: 15px; border-radius: 15px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; align-items: center; }
.input-row input { width: 60px; padding: 5px; border: 1px solid #ddd; border-radius: 5px; text-align: right; }
.total-row { font-size: 1.3rem; font-weight: bold; margin-top: 10px; }

/* Buttons */
.print-btn, .neon-btn { 
    background: var(--neon-blue); 
    color: white; 
    border: none; 
    border-radius: 10px; 
    font-size: 1rem; 
    font-weight: bold; 
    cursor: pointer; 
    transition: var(--transition); 
    box-shadow: var(--neon-glow); 
}
.print-btn { width: 100%; padding: 15px; margin-top: 15px; }
.neon-btn { padding: 10px 20px; border-radius: 5px; }
.print-btn:hover, .neon-btn:hover { background: #00c3dd; transform: scale(1.02); }

/* ==========================================
   7. FORMS, SETTINGS & HISTORY TAB
   ========================================= */
.form-card, .stat-card { background: white; padding: 20px; border-radius: 15px; box-shadow: var(--card-shadow); margin-bottom: 20px; }
.form-card input[type="text"], .form-card input[type="password"], .form-card input[type="number"], .form-card select, .form-card input[type="file"] { display: block; width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 5px; }
.input-row { display: flex; align-items: center; }
.settings-category-list { margin-top: 15px; display: flex; flex-wrap: wrap; gap: 10px; }
.cat-tag { background: var(--bg-color); padding: 8px 15px; border-radius: 20px; display: flex; align-items: center; gap: 10px; border: 1px solid #ddd; }

.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.history-filters { display: flex; gap: 10px; align-items: center; }
.history-filters input[type="date"] { padding: 8px; border: 1px solid #ddd; border-radius: 5px; font-family: inherit; }
.history-item { background: white; padding: 15px; border-radius: 10px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--card-shadow); }
.history-item.voided { opacity: 0.6; text-decoration: line-through; }

/* ==========================================
   8. PRINT STYLES (PAPER CHECKOUT)
   ========================================= */
.print-area { display: none; }
@media print {
    body * { visibility: hidden; }
    .print-area:not(:empty), .print-area:not(:empty) * { visibility: visible; }
    .print-area { 
        display: block; 
        position: absolute; 
        left: 0; 
        top: 0; 
        width: 100%; 
        padding: 20px; 
        background: white; 
        z-index: 100000;
    }
    #app-wrapper, #auth-screen, #danger-modal { display: none !important; }
    .history-print-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
    .history-print-table th, .history-print-table td { border: 1px solid #000; padding: 8px; text-align: left; }
}