/* =========================================
   1. VARIABLES & BASE STYLES
   ========================================= */
:root { 
    --bg: #F4F8FA; 
    --primary: #136996; 
    --primary-dark: #082A3C; 
    --primary-light: #DFEDF5; 
    --accent: #E16D0E; 
    --danger: #CA220C; 
    --success: #27ae60; 
    --text: #061F2D; 
    --muted-text: #2375A1; 
    --tab-bg: #E1EEF6; 
    --card-bg: #FFFFFF; 
}

body { 
    font-family: 'Roboto', sans-serif; 
    background-color: var(--bg); 
    margin: 0; 
    color: var(--text); 
    overflow-x: hidden; 
}

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
header { 
    background: #082A3C; 
    color: white; 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 0 15px; 
    font-family: 'Roboto Condensed', sans-serif; 
    height: 50px; 
    position: sticky; top: 0; z-index: 50; 
    box-shadow: 0 2px 5px rgba(4,21,30,0.2); 
}

.header-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.header-marquee { 
    flex-grow: 1; margin: 0 40px; 
    overflow: hidden; position: relative; 
    height: 100%; display: flex; align-items: center; 
    visibility: hidden; 
}

.marquee-text { 
    position: absolute; white-space: nowrap; 
    font-size: 16px; font-weight: 700; letter-spacing: 1px; 
    animation: scrollPOS 35s linear infinite; 
}

@keyframes scrollPOS { 
    0% { left: 100%; transform: translateX(0); } 
    100% { left: 0; transform: translateX(-100%); } 
}

.header-right-zone { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-time { font-weight: bold; color: var(--primary-light); font-size: 14px; }
.header-right { 
    cursor: pointer; background: rgba(255,255,255,0.1); 
    padding: 8px 12px; border-radius: 4px; font-size: 14px; 
    transition: background 0.2s;
}
.header-right:hover { background: rgba(255,255,255,0.2); }

/* Tabs Navigation */
.tabs-container { 
    display: flex; background: var(--primary-dark); 
    padding: 10px 15px 0 15px; gap: 5px; 
    overflow-x: auto; scrollbar-width: none; 
}

.tab { 
    padding: 10px 20px; background: rgba(255,255,255,0.1); 
    color: var(--primary-light); border-radius: 8px 8px 0 0; 
    cursor: pointer; font-family: 'Roboto Condensed'; font-weight: 700; 
    display: flex; align-items: center; gap: 8px; 
    transition: all 0.2s; white-space: nowrap; 
}

.tab:hover { background: rgba(255,255,255,0.2); color: white; }
.tab.active { background: var(--bg); color: var(--primary-dark); }
.add-tab { padding: 10px 15px; color: var(--primary-light); cursor: pointer; }

/* =========================================
   3. MAIN LAYOUT & DATA TABLES
   ========================================= */
.content { padding: 20px; }
.card-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 20px; }
.card { 
    background: var(--card-bg); padding: 20px; border-radius: 8px; 
    box-shadow: 0 4px 15px rgba(4,21,30,0.05); 
}
.card h3 { 
    margin-top: 0; color: var(--primary-dark); font-family: 'Roboto Condensed'; 
    font-size: 20px; border-bottom: 2px solid var(--primary-light); 
    padding-bottom: 10px; margin-bottom: 15px; 
}

/* Stock Alerts Formatting */
.stock-tabs { display: flex; gap: 5px; margin-bottom: 10px; }
.stock-tab { 
    padding: 5px 10px; font-size: 12px; cursor: pointer; 
    background: var(--tab-bg); border-radius: 4px; border: none; 
    font-weight: bold; color: var(--primary-dark); 
}
.stock-tab.active { background: var(--primary); color: white; }
.stock-tab.alert { background: var(--danger); color: white; }

/* Tables */
.table-container { overflow-x: auto; background: white; border-radius: 8px; border: 1px solid var(--primary-light); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--primary-light); }
.data-table th { background: var(--tab-bg); color: var(--primary-dark); font-family: 'Roboto Condensed'; font-weight: 700; text-transform: uppercase; font-size: 13px; }
.clickable-id { color: var(--primary); font-weight: bold; cursor: pointer; text-decoration: underline; }

/* =========================================
   4. POS ELEMENTS (TILL SCREEN)
   ========================================= */
.pos-add-buttons { display: flex; gap: 10px; margin-bottom: 15px; }
.btn-pos-add { flex: 1; padding: 10px; border: none; border-radius: 6px; color: white; font-weight: bold; cursor: pointer; }
.bg-loyalty { background: #2980b9; } 
.bg-sub { background: #8e44ad; } 
.bg-promo { background: #16a085; }

/* Filter Tabs */
.pos-filter-btn {
    flex: 1; padding: 8px 2px;
    background: var(--tab-bg); border: 1px solid var(--primary-light);
    border-radius: 4px; font-size: 11px; font-weight: bold;
    color: var(--primary-dark); cursor: pointer; transition: all 0.2s ease;
}
.pos-filter-btn:hover { background: var(--primary-light); }
.pos-filter-btn.active-filter {
    background: var(--primary); color: white; border-color: var(--primary);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Accordions */
.accordion { 
    margin-bottom: 10px; border: 1px solid var(--primary-light); 
    border-radius: 6px; overflow: hidden; background: white; 
    box-shadow: 0 2px 4px rgba(4,21,30,0.02); 
}
.accordion-header { 
    padding: 12px 15px; font-weight: bold; cursor: pointer; 
    color: var(--primary-dark); background: #F4F8FA; 
    display: flex; align-items: center; gap: 10px; 
    transition: background 0.2s; border-bottom: 1px solid #E1EEF6; 
}
.accordion-header:hover { background: #DFEDF5; }
.hdr-grocery { border-left: 5px solid var(--accent); } 
.hdr-coffee { border-left: 5px solid #8d6e63; } 
.hdr-service { border-left: 5px solid #34495e; } 
.hdr-print { border-left: 5px solid #7f8c8d; } 
.hdr-till { border-left: 5px solid var(--primary-dark); }
.accordion-body { padding: 15px; background: white; display: none; }

/* POS Products */
.pos-item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.btn-item { 
    background: var(--tab-bg); border: 1px solid var(--primary-light); 
    padding: 15px 5px; border-radius: 6px; cursor: pointer; 
    font-weight: bold; color: var(--primary-dark); font-size: 12px; 
    transition: transform 0.1s; 
}
.btn-item:active { transform: scale(0.95); }

/* =========================================
   5. TILL CART & CHECKOUT
   ========================================= */
.cart-container { flex-grow: 1; border: 1px solid var(--primary-light); border-radius: 6px; padding: 10px; background: #fafafa; overflow-y: auto; max-height: 350px; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.cart-item-name { flex-grow: 1; font-weight: bold; }
.cart-item-qty { display: flex; align-items: center; gap: 8px; margin: 0 10px; }
.qty-btn { background: var(--primary-light); border: none; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-weight: bold; }
.cart-item-price { font-weight: bold; color: var(--primary-dark); width: 50px; text-align: right; }
.cart-item-remove { color: var(--danger); cursor: pointer; margin-left: 10px; }

.cart-totals { margin-top: 15px; background: var(--tab-bg); padding: 15px; border-radius: 6px; }
.cart-math-row { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 14px; font-weight: bold; color: var(--muted-text); }
.checkout-row { display: flex; justify-content: space-between; align-items: center; font-weight: bold; margin-bottom: 10px; }

.tender-input { width: 100px; padding: 8px; font-size: 16px; border: 2px solid var(--primary-light); border-radius: 4px; text-align: right; font-weight: bold; }
.btn-action { width: 100%; padding: 15px; background: var(--accent); color: white; border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; }

/* =========================================
   6. MODALS & CALENDAR POPUP
   ========================================= */
.modal-overlay { 
    display: none; position: fixed; top:0; left:0; width:100%; height:100%; 
    background: rgba(8,42,60,0.8); z-index: 1000; justify-content: center; 
    align-items: center; backdrop-filter: blur(2px); 
}
.modal-content { 
    background: white; padding: 25px; border-radius: 8px; width: 400px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.3); border: 2px solid var(--primary); 
}
.modal-content.large { width: 800px; max-width: 90%; }
.modal-content h3 { margin-top: 0; color: var(--primary-dark); border-bottom: 2px solid var(--primary-light); padding-bottom: 10px; }
.modal-content input, .modal-content select { width: 100%; padding: 10px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }

.modal-btn-row { display: flex; justify-content: space-between; gap: 10px; }
.modal-btn { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; color: white; flex: 1; }
.btn-save { background: var(--primary); } 
.btn-cancel { background: #7f8c8d; }

/* Calendar Dashboard Popup */
#calendarPopup { 
    display: none; position: absolute; top: 60px; right: 15px; 
    background: white; width: 320px; border-radius: 8px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); padding: 15px; 
    border: 1px solid var(--primary-light); z-index: 2000; color: #333;
}
.cal-controls { display: flex; justify-content: space-between; align-items: center; font-weight: bold; margin-bottom: 10px; color: var(--primary-dark); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.cal-day-header { font-size: 11px; font-weight: bold; color: var(--muted-text); }
.cal-day { padding: 8px 0; border-radius: 4px; font-size: 13px; cursor: pointer; border: 1px solid transparent; }
.cal-day:hover { background: var(--tab-bg); }
.cal-day.today { background: var(--primary); color: white; font-weight: bold; }
.cal-day.has-note { border-color: var(--accent); font-weight: bold; }
.note-item { background: #f9f9f9; border-left: 3px solid var(--primary); padding: 8px; margin-bottom: 5px; font-size: 12px; display: flex; justify-content: space-between; align-items: center;}

/* =========================================
   9. SECURITY & LOGIN SCREEN
   ========================================= */
#loginScreen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: linear-gradient(135deg, #082A3C, #136996);
    z-index: 9999; display: flex; justify-content: center; align-items: center;
}

.login-box {
    background: white; padding: 40px; border-radius: 12px;
    width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    text-align: center;
}

.login-box h2 { margin-top: 0; color: var(--primary-dark); font-family: 'Roboto Condensed'; font-size: 28px; }
.login-box p { color: var(--text-muted); font-size: 13px; margin-bottom: 25px; }

.auth-step { display: none; }
.auth-step.active { display: block; }

.auth-input {
    width: 100%; padding: 15px; font-size: 18px; text-align: center;
    border: 2px solid var(--primary-light); border-radius: 6px;
    margin-bottom: 15px; box-sizing: border-box; font-weight: bold;
}

.auth-input:focus { outline: none; border-color: var(--primary); }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.numpad-btn {
    padding: 15px; font-size: 20px; font-weight: bold; background: var(--bg);
    border: 1px solid var(--primary-light); border-radius: 6px; cursor: pointer;
    color: var(--primary-dark); transition: background 0.1s;
}
.numpad-btn:active { background: var(--primary-light); transform: scale(0.95); }

.btn-auth {
    width: 100%; padding: 15px; background: var(--accent); color: white;
    border: none; border-radius: 6px; font-size: 16px; font-weight: bold;
    cursor: pointer; transition: background 0.2s;
}
.btn-auth:hover { background: #CA220C; }
.btn-qr {
    background: var(--primary-dark); margin-top: 10px; display: flex;
    justify-content: center; align-items: center; gap: 10px;
}

@media print {
    body * { visibility: hidden; }
    #printKeyfobArea, #printKeyfobArea * { visibility: visible; }
    #printKeyfobArea { position: absolute; left: 0; top: 0; width: 100%; border: none; }
}
