:root {
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --primary-blue: #007bff;
    --primary-indigo: #505153;
    --light-grey: #f3f4f6;
    --text-main: #1f2937;
    --text-muted: #6b7280;
   /* --border-light: #e3dfdf;*/
    --border-light: #d4cdcd;
    --success-green: #28a745;
    --danger-red: #ef4444;
    --warning-orange: #f59e0b;
}

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0; 
    background: var(--bg-body); 
    color: var(--text-main);
    display: flex;
    overflow: hidden;
    height: 100vh;
}

.app-layout { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* Sidebar - Collapsible Overlay Theme */
.sidebar {
    width: 250px;
    background: #ffffff;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100; /* Higher than navbar */
    flex-shrink: 0;
    border-right: 1px solid var(--border-light);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%); /* Hidden by default */
}

.sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 25px rgba(0,0,0,0.05);
}

.sidebar-header { 
    padding: 20px; 
    font-size: 20px; 
    font-weight: bold; 
    border-bottom: 1px solid var(--border-light); 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    color: var(--primary-indigo);
}
.sidebar-nav { display: flex; flex-direction: column; padding: 10px 0; flex: 1; }
.sidebar-link {
    padding: 15px 25px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    display: flex; align-items: center; gap: 12px;
    transition: all 0.2s;
    font-weight: 500;
}
.sidebar-link:hover { background: #f8f9fa; color: var(--text-main); }
.sidebar-link.active { 
    background: var(--light-grey); 
    color: var(--text-main); 
    border-left: 4px solid var(--primary-indigo); 
    font-weight: 600; 
}
.sidebar-link.active svg { color: var(--primary-indigo); }

.sidebar-overlay { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.3); 
    z-index: 1050; 
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-body); width: 100%; }

/* Navbar */
.navbar {
    background: white;
    padding: 10px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    height: 60px;
    box-sizing: border-box;
    width: 100%;
}
.nav-left { display: flex; align-items: center; gap: 15px; }
.menu-toggle { 
    display: block; /* Always visible */
    background: none; 
    border: none; 
    font-size: 24px; 
    cursor: pointer; 
    padding: 5px; 
    margin-right: 10px; 
    color: var(--text-main); 
    border-radius: 8px;
    transition: background 0.2s;
}
.menu-toggle:hover {
    background: var(--light-grey);
}
.nav-right { display: flex; align-items: center; gap: 15px; }
.nav-title { font-size: 20px; font-weight: 500; }

.btn { 
    padding: 10px 24px; 
    border: 1px solid var(--border-light); 
    border-radius: 50px; /* Pill Shape */
    cursor: pointer; 
    font-weight: 600; 
    font-size: 14px;
    transition: all 0.2s;
    background: white;
    color: var(--text-main);
}
.btn-primary { 
    background: var(--primary-blue); 
    color: white; 
    border-color: var(--primary-blue); 
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}
.btn-primary:hover { 
    opacity: 0.9; 
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.3);
}

.btn:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
    opacity: 0.7;
}

.container { padding: 25px; flex: 1; overflow-y: auto; }

/* Search Bar Style from POS */
.search-area {
    background: var(--light-grey);
    padding: 15px 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    position: relative;
    border-bottom: 2px solid var(--primary-indigo);
}
.search-input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 16px;
    outline: none;
    color: var(--text-main);
}

.card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    padding: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Table */
table { width: 100%; border-collapse: collapse; }
.data-table { min-width: 800px; }
@media (max-width: 768px) {
    .data-table { min-width: auto; }
}
th { text-align: left; color: var(--text-muted); font-weight: normal; padding-bottom: 15px; border-bottom: 1px solid #f0f0f0; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 18px 0; border-bottom: 1px solid #f9f9f9; font-size: 15px; }
tr:hover { background: #fafafa; }

.badge { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: bold; }
.badge-stock { background: #e7f3ff; color: #007bff; }

.modern-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-edit-modern {
    background: #F3F4F6;
    color: #374151;
}
.btn-edit-modern:hover {
    background: #E5E7EB;
}

.btn-delete-modern {
    background: #FEF2F2;
    color: #DC2626;
}
.btn-delete-modern:hover {
    background: #FEE2E2;
}

tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #f3f4f6 !important; }

/* Modal - Force standardized styling */
.modal { 
    display: none; 
    position: fixed; 
    z-index: 2000 !important; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.5); 
    backdrop-filter: blur(4px); 
}

.modal-content { 
    background: white !important; 
    margin: 5% auto !important; 
    padding: 30px !important; 
    border-radius: 12px !important; 
    width: 90% !important; 
    max-width: 700px !important; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.15) !important; 
    position: relative !important; /* CRITICAL for absolute positioning of child close button */
    overflow: visible !important;   /* Ensure button sitting on edge is not clipped */
}

.modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 20px !important;
    padding-right: 40px !important; /* Space for the floating close button */
}

.modal-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
    margin: 0 !important;
}

/* THE BUTTON - Forced to top-right corner of .modal-content */
.close-modal {
    position: absolute !important;
    top: -15px !important;
    right: -15px !important;
    background: #ffffff !important;
    border: 2px solid #e5e7eb !important;
    font-size: 20px !important;
    cursor: pointer !important;
    color: #6b7280 !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: all 0.2s !important;
    line-height: 1 !important;
    z-index: 2100 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
}

.close-modal:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-color: #fecaca !important;
    transform: scale(1.1) !important;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: #555; }
.form-group input, .form-group textarea, .form-group select { 
    width: 100%; padding: 12px; border: 1px solid var(--border-light); border-radius: 8px; box-sizing: border-box; 
}

@media (max-width: 768px) {
    .container { padding: 12px; }
    .card { padding: 15px; }
    body { font-size: 14px; }

    .navbar { 
        flex-direction: row; 
        height: 60px; 
        padding: 0 15px; 
        gap: 0; 
    }
    .nav-right { width: auto; }
    .nav-right .btn { padding: 8px 16px; font-size: 12px; }
    .nav-title { font-size: 16px; }

    /* Touch target improvements */
    .btn, .form-input, select, .search-input {
        min-height: 44px;
    }

    /* Card-based table layout for mobile */
    .table-responsive-cards table, 
    .table-responsive-cards thead, 
    .table-responsive-cards tbody, 
    .table-responsive-cards th, 
    .table-responsive-cards td, 
    .table-responsive-cards tr { 
        display: block; 
    }

    .table-responsive-cards .data-table {
        min-width: auto !important;
    }

    .table-responsive-cards thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive-cards tr {
        border: 1px solid var(--border-light);
        border-radius: 8px;
        margin-bottom: 15px;
        background: white;
        padding: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    .table-responsive-cards td { 
        border: none;
        border-bottom: 1px solid #f0f0f0; 
        position: relative;
        padding-left: 50%; 
        padding-top: 12px;
        padding-bottom: 12px;
        text-align: right;
        min-height: 20px;
    }

    .table-responsive-cards td:last-child {
        border-bottom: none;
        padding-left: 10px;
        text-align: center;
        display: flex;
        justify-content: center;
        gap: 10px;
    }

    .table-responsive-cards td:before { 
        position: absolute;
        top: 12px;
        left: 10px;
        width: 40%; 
        padding-right: 10px; 
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
        content: attr(data-label);
        font-size: 11px;
        text-transform: uppercase;
    }

    .table-responsive-cards td:last-child:before {
        content: none;
    }

    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .sidebar {
        width: 280px; /* Slightly wider for easier tapping */
    }
}

/* Common Responsive Grids */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: flex-end;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}


.table-responsive { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
}

@media (max-width: 768px) {
    .form-grid { 
        grid-template-columns: 1fr; 
        gap: 12px; 
    }
    .modal-content { 
        width: 96% !important; 
        margin: 5% auto !important; 
        padding: 20px !important; 
        max-height: 90vh;
        overflow-y: auto !important;
    }
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.status-active { background: #ECFDF5; color: #059669; }
.status-inactive { background: #FEF2F2; color: #DC2626; }
.status-pill svg { width: 8px; height: 8px; }

/* Profile & Dropdown */
.profile-icon {
    width: 35px; height: 35px; background: #E5E7EB; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    cursor: pointer; position: relative; transition: all 0.2s;
    user-select: none;
}
.profile-icon:hover { background: #D1D5DB; }

.profile-dropdown {
    position: absolute; top: 45px; right: 0;
    background: white; border: 1px solid var(--border-light);
    border-radius: 10px; shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 220px; display: none; z-index: 2000;
    padding: 8px 0; box-shadow: 0 10px 15px -33px rgba(0, 0, 0, 0.1);
}
.profile-dropdown.active { display: block; }

.dropdown-item {
    padding: 10px 20px; font-size: 14px; cursor: pointer;
    transition: background 0.2s; display: flex; align-items: center; gap: 10px;
    color: #374151;
}
.dropdown-item:hover { background: #F3F4F6; }
.dropdown-item.logout { color: #DC2626; border-top: 1px solid #F3F4F6; margin-top: 5px; }

#toast { position: fixed; bottom: 30px; right: 30px; padding: 15px 30px; border-radius: 8px; color: white; display: none; z-index: 3000; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }

/* --- Extracted POS Styles --- */

/* Header Navigation */
.pos-header {
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Container Cards */
.content-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Search Bar (The light grey input area) */
.search-section {
    background: var(--light-grey);
    border-bottom: 2px solid var(--primary-indigo);
    border-radius: 8px 8px 0 0;
    padding: 1.25rem;
}

.pos-search-input {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: var(--text-main);
    width: 100%;
    outline: none;
}

/* Table / List Headers */
.bill-table-header {
    border-bottom: 1px solid #f1f3f5;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: capitalize;
}

/* Sidebar Summary Styling */
.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.total-row {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    font-size: 1.25rem;
    font-weight: 700;
}

.total-amount {
    color: var(--success-green);
}

/* Customer Details Sub-Card */
.customer-info-box {
    background: #f1f3f5;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Buttons */
.btn-finalize {
    background-color: var(--primary-blue);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 0.8rem 2rem;
    font-weight: 600;
    width: 100%;
    transition: background 0.2s;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.2);
}
.btn-finalize:hover {
    opacity: 0.9;
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.3);
}

.btn-edit-outline {
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    color: #495057;
    cursor: pointer;
}
.btn-edit-outline:hover {
    background: #f8f9fa;
}

/* User Profile Badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: right;
}

.user-badge .shop-name {
    font-weight: bold;
    font-size: 0.9rem;
}

/* --- Extracted POS Side Panel (Right Sidebar) --- */

.pos-side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1rem;
    background: #ffffff;
    border-left: 1px solid #dee2e6;
    height: 100%;
}

.pos-summary-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.summary-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1.25rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    color: #4b5563;
    font-size: 1rem;
}

.summary-total-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-total-label {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111827;
}

.summary-total-amount {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--success-green);
}

/* Sub-card for Customer Details */
.pos-customer-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
}

.customer-name {
    font-weight: 600;
    color: #374151;
}

/* Action Button at the bottom of sidebar */
.btn-pos-finalize {
    margin-top: auto;
    background: var(--primary-blue);
    color: white;
    padding: 1.25rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(0, 123, 255, 0.39);
    transition: all 0.2s;
}

.btn-pos-finalize:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.23);
    opacity: 0.95;
}
