/* assets/css/style.css */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Pharmacy Theme Colors */
    --primary: #4f46e5;       /* Indigo 600 - Main Action */
    --primary-hover: #4338ca; /* Indigo 700 */
    --secondary: #64748b;     /* Slate 500 - Text */
    --success: #10b981;       /* Emerald 500 - Pay/Complete */
    --success-hover: #059669; 
    --danger: #ef4444;        /* Red 500 - Delete/Error */
    --warning: #f59e0b;       /* Amber 500 - Low Stock */
    
    /* Layout Colors */
    --bg-body: #f1f5f9;       /* Slate 100 - Main Background */
    --bg-panel: #ffffff;      /* White - Cards/Panels */
    --sidebar-bg: #1e293b;    /* Slate 800 */
    --border-color: #e2e8f0;  /* Slate 200 */
    
    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 65px;
    
    /* Shadows & Radius */
    --radius-md: 10px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    height: 100vh;
    display: flex;
    overflow: hidden; /* App-like feel, no outer scroll */
    color: #334155;
}

/* Scrollbar Styling (Cross-Browser) */
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* Chrome/Edge/Safari */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* =========================================
   2. SIDEBAR NAVIGATION
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1); /* Subtle depth */
}

.brand {
    padding: 10px 0 30px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-icon-box {
    font-size: 1.8rem;
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(79, 70, 229, 0.4));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 700; font-size: 1.5rem; letter-spacing: 0.5px; }
.brand-subtitle { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }

.menu-list { 
    flex-grow: 1; 
    overflow-y: auto;
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
}

/* Category Headers (Main Menu, Management, etc) */
.menu-category {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
    margin: 15px 0 5px 12px;
    letter-spacing: 0.5px;
}

.menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    color: #94a3b8; 
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--bg-panel);
    transform: translateX(4px);
}

.menu-item.active {
    background: linear-gradient(90deg, var(--primary) 0%, #4338ca 100%);
    color: var(--bg-panel);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}


/* =========================================
   3. MAIN LAYOUT & HEADER
   ========================================= */
.layout-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.top-bar {
    height: var(--header-height);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    flex-shrink: 0;
    z-index: 40;
}

.page-title { font-size: 1.25rem; font-weight: 700; color: #1e293b; margin: 0; }
.branch-badge {
    font-size: 0.75rem; 
    color: var(--primary); 
    background: rgba(79, 70, 229, 0.1); 
    padding: 4px 10px; 
    border-radius: 20px; 
    font-weight: 600;
    margin-left: 10px;
}

.user-info { display: flex; align-items: center; gap: 25px; }

.date-display {
    font-size: 0.85rem; color: var(--secondary);
    display: flex; align-items: center; gap: 8px;
    background: #f8fafc; padding: 6px 14px; border-radius: 20px;
    border: 1px solid var(--border-color);
}

.profile-pill {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
}
.avatar {
    width: 38px; height: 38px;
    background: var(--primary);
    color: white; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-weight: bold; font-size: 1rem;
    box-shadow: 0 3px 6px rgba(79, 70, 229, 0.25);
}
.profile-text { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.p-name { font-size: 0.9rem; font-weight: 600; color: #1e293b; }
.p-role { font-size: 0.7rem; color: #94a3b8; font-weight: 500; text-transform: uppercase; }

.main-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    background-color: var(--bg-body);
}


/* =========================================
   4. POS INTERFACE (Robust Layout)
   ========================================= */
.pos-container {
    display: flex;
    gap: 20px;
    /* FIX: Replaced calc() with flexbox sizing */
    height: 100%; 
    overflow: hidden; 
    padding-bottom: 5px;
}

.panel {
    background: var(--bg-panel);
    border-radius: 16px; /* Softer corners */
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* LEFT PANEL (Product List) - 65% Width */
.panel-left { flex: 6.5; }

/* RIGHT PANEL (Cart) - 35% Width */
.panel-right { flex: 3.5; }

.search-wrapper, .cart-header {
    padding: 15px 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.table-wrapper, .cart-table-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    position: relative;
    background: #fff;
}

.summary-box {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.03);
    z-index: 10;
}


/* =========================================
   5. TABLES & DATA
   ========================================= */
table { width: 100%; border-collapse: separate; border-spacing: 0; }

th { 
    background: #f8fafc; 
    text-align: left; 
    padding: 14px 15px; 
    position: sticky; top: 0; z-index: 10; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    color: var(--secondary);
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
}

td { 
    padding: 12px 15px; 
    border-bottom: 1px solid #f1f5f9; 
    vertical-align: middle;
    font-size: 0.9rem;
    color: #334155;
}

/* Zebra Striping for better readability */
tbody tr:nth-child(even) { background-color: #fafafa; }
tbody tr:hover { background-color: #f1f5f9; cursor: pointer; }

/* Empty State */
.empty-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; color: #94a3b8; text-align: center;
    padding: 40px;
}
.empty-state i { font-size: 3rem; margin-bottom: 15px; opacity: 0.3; }


/* =========================================
   6. FORMS & BUTTONS
   ========================================= */
.search-input {
    width: 100%; padding: 12px 18px; 
    border: 1px solid var(--border-color); 
    border-radius: 10px;
    font-size: 0.95rem; outline: none; transition: 0.2s;
    background: #f8fafc;
    color: #1e293b;
}
.search-input:focus { 
    border-color: var(--primary); 
    background: var(--bg-panel);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.input-disc {
    width: 80px;
    padding: 8px 12px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    text-align: right;
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
}
.input-disc:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Remove Arrows */
.input-disc::-webkit-inner-spin-button, 
.input-disc::-webkit-outer-spin-button { 
    -webkit-appearance: none; margin: 0; 
}

/* Big Pay Button */
.btn-pay {
    width: 100%; padding: 16px; 
    background: var(--success); color: white; 
    border: none; border-radius: 12px;
    font-size: 1.2rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    cursor: pointer; transition: 0.2s;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    margin-top: 15px;
    display: flex; justify-content: center; align-items: center; gap: 10px;
}
.btn-pay:hover { 
    background: var(--success-hover); 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}
.btn-pay:active { transform: translateY(0); }

.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--secondary); font-size: 0.9rem;}
.grand-total-row { 
    margin-top: 15px; padding-top: 15px; 
    border-top: 2px dashed var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.total-label { font-size: 1.1rem; font-weight: 600; color: #1e293b; }
.total { font-size: 1.8rem; font-weight: 800; color: var(--primary); }


/* =========================================
   7. MODALS & TOASTS
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white; padding: 40px; border-radius: 16px;
    width: 90%; max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; translateY(20px); }
    to { transform: scale(1); opacity: 1; translateY(0); }
}

/* Toast */
#toast-container {
    position: fixed; bottom: 30px; right: 30px; z-index: 9999;
    display: flex; flex-direction: column; gap: 15px;
}
.toast {
    min-width: 320px; background: white; padding: 16px 20px;
    border-radius: 10px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex; align-items: center; gap: 15px;
    border-left: 5px solid var(--secondary);
    animation: slideIn 0.3s ease-out forwards;
}
.toast-icon { font-size: 1.2rem; }
.toast.success { border-left-color: var(--success); } .toast.success .toast-icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); } .toast.error .toast-icon { color: var(--danger); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }
.toast.fade-out { animation: fadeOut 0.3s forwards; }

/* ADD THIS TO YOUR CSS FILE */

/* --- COMPLETE MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {

    /* ============================
       1. SIDEBAR & MENU LOGIC
       ============================ */
    
    /* Show the Hamburger Button */
    #mobileMenuBtn {
        display: block !important; 
    }

    /* Hide the sidebar initially */
    .sidebar {
        position: fixed;
        left: -280px; 
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    }

    /* Slide it back in when active */
    .sidebar.active {
        left: 0;
    }

    /* ============================
       2. POS LAYOUT FIXES (STACKING)
       ============================ */

    /* Force the main container to stack vertically instead of side-by-side */
    .pos-container {
        flex-direction: column !important;
        height: auto !important;      /* Let page grow tall */
        overflow-y: auto !important;  /* Allow window scrolling */
        padding-bottom: 50px;         /* Space at bottom */
    }

    /* Make both panels full width (100%) */
    .panel-left, .panel-right {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        flex: none !important;        /* Disable flex sharing */
        height: auto !important;
        margin-bottom: 20px;          /* Add space between them */
    }

    /* CONTROL ORDER: Products on Top (1), Cart on Bottom (2) */
    .panel-left  { order: 1; }
    .panel-right { order: 2; }

    /* ============================
       3. HEADER CLEANUP
       ============================ */

    /* Hide the Branch Name and User Role text to save space for the Menu Button */
    .branch-badge, 
    .user-info .profile-text {
        display: none !important; 
    }

    /* Adjust the top bar to fit the Menu Button */
    .top-bar {
        padding-right: 60px !important;
        padding-left: 10px !important;
    }
    
    /* Simplify Profile Pill */
    .profile-pill {
        padding: 5px !important;
        background: transparent !important;
        border: none !important;
    }

    /* ============================
       4. INVENTORY PAGE FIXES ("CARD VIEW")
       ============================ */

    /* Fix Header Stacking (Search bar & Add Button) */
    .inventory-header, 
    .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    /* Make inputs and buttons full width */
    .inventory-search, input[type="search"], .btn-add {
        width: 100% !important;
        margin: 5px 0;
    }

    /* Transform Table into Cards */
    .inventory-table thead { display: none; } /* Hide Table Headers */
    
    .inventory-table, .inventory-table tbody, .inventory-table tr, .inventory-table td {
        display: block;
        width: 100%;
    }

    /* Card Style */
    .inventory-table tbody tr {
        margin-bottom: 15px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        padding: 15px;
    }

    /* Cell Style */
    .inventory-table tbody td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px dashed #edf2f7;
        padding-top: 8px;
        padding-bottom: 8px;
        font-size: 0.95rem;
    }
    
    .inventory-table tbody td:last-child { border-bottom: none; }

    /* Add Labels (Based on your screenshot columns) */
    /* Adjust the text inside "content" if your columns are different! */
    .inventory-table td:nth-of-type(1)::before { content: "Branch:"; position: absolute; left: 10px; font-weight: bold; color: #64748b; }
    .inventory-table td:nth-of-type(2)::before { content: "Barcode:"; position: absolute; left: 10px; font-weight: bold; color: #64748b; }
    .inventory-table td:nth-of-type(3)::before { content: "Product:"; position: absolute; left: 10px; font-weight: bold; color: #2563eb; }
    .inventory-table td:nth-of-type(4)::before { content: "Brand:"; position: absolute; left: 10px; font-weight: bold; color: #64748b; }
    .inventory-table td:nth-of-type(5)::before { content: "Price:"; position: absolute; left: 10px; font-weight: bold; color: #64748b; }
    .inventory-table td:nth-of-type(6)::before { content: "Stock:"; position: absolute; left: 10px; font-weight: bold; color: #64748b; }
    .inventory-table td:nth-of-type(7)::before { content: "Action:"; position: absolute; left: 10px; font-weight: bold; color: #64748b; }

    /* Highlight Product Name */
    .inventory-table td:nth-of-type(3) {
        font-weight: bold;
        color: #2563eb;
        font-size: 1.1rem;
    }
}