@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-dark: #0b0f19;
    --bg-card: rgba(22, 30, 46, 0.78);
    --bg-card-hover: rgba(30, 41, 62, 0.9);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(59, 130, 246, 0.4);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.4);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;

    --sidebar-width: 260px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
}

/* Premium Ultra-Clean Light Theme Variables */
[data-theme="light"] {
    --bg-dark: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --border-glow: rgba(79, 70, 229, 0.25);
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-glow: rgba(79, 70, 229, 0.2);
    
    --success: #059669;
    --success-glow: rgba(5, 150, 105, 0.2);
    
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    --shadow-premium: 0 10px 30px -10px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', 'Outfit', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl;
    text-align: right;
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* LTR Layout Adjustment */
html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border-color);
}

html[dir="ltr"] .main-wrapper {
    margin-right: 0;
    margin-left: var(--sidebar-width);
}

html[dir="ltr"] .table th, 
html[dir="ltr"] .table td {
    text-align: left;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Glassmorphism Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 8px 20px var(--primary-glow);
    transition: transform 0.3s ease;
}

.sidebar-header:hover .brand-icon {
    transform: rotate(10deg) scale(1.05);
}

.brand-title {
    font-weight: 900;
    font-size: 20px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    padding: 20px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    position: relative;
}

.menu-item:hover {
    color: var(--text-main);
    background: var(--bg-card-hover);
    transform: translateX(-4px);
}

html[dir="ltr"] .menu-item:hover {
    transform: translateX(4px);
}

.menu-item.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #2563eb);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

/* Main Workspace */
.main-wrapper {
    flex: 1;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: 70px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
}

.rate-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    color: #60a5fa;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--success));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    object-fit: cover;
}

/* Content Body */
.content-body {
    padding: 30px;
    flex: 1;
}

/* Cards & Glass Panel */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-premium);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

/* Tab Navigation Buttons */
.tab-btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 13px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #2563eb);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* KPI Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.orange { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

.stat-val {
    font-size: 24px;
    font-weight: 900;
    line-height: 1.2;
    margin-top: 4px;
}

.stat-lbl {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--success-glow);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Inputs & Form Elements */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
    font-size: 13px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

[data-theme="light"] .form-control {
    background: #ffffff;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .form-control:focus {
    background: #ffffff;
}

/* Table Design */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.table th {
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-weight: 800;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
}

.badge-success { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.18); color: #f87171; }
.badge-info { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }

/* POS Terminal Layout */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    height: calc(100vh - 110px);
}

.pos-catalog {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

.pos-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
    flex: 1;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.product-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.product-card .p-name {
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .p-price {
    color: var(--success);
    font-weight: 900;
    font-size: 16px;
}

.product-card .p-stock {
    font-size: 11px;
    color: var(--text-dim);
}

/* POS Cart Drawer */
.pos-cart {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.cart-footer {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
}

.cart-total-row {
    font-size: 22px;
    font-weight: 900;
    color: var(--success);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

/* Modal Dialog */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    padding: 28px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
    .pos-container { grid-template-columns: 1fr; height: auto; }
}

/* ========================================== */
/* Enterprise Light Mode Design System        */
/* ========================================== */
[data-theme="light"] body {
    background-color: #f8fafc;
    color: #0f172a;
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
}

[data-theme="light"] .sidebar {
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    box-shadow: 0 4px 25px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .sidebar-header {
    border-bottom: 1px solid #f1f5f9;
}

[data-theme="light"] .menu-category-title {
    color: #4f46e5;
}

[data-theme="light"] .menu-item {
    color: #475569;
}

[data-theme="light"] .menu-item:hover {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.06);
}

[data-theme="light"] .menu-item.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, #4f46e5, #3b82f6);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.28);
}

[data-theme="light"] .topbar {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

[data-theme="light"] .rate-chip {
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.2);
    color: #4f46e5;
}

[data-theme="light"] .glass-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.06), 0 4px 6px -2px rgba(15, 23, 42, 0.02);
}

[data-theme="light"] .glass-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 18px 32px -10px rgba(15, 23, 42, 0.09);
}

[data-theme="light"] .table th {
    background: #f8fafc;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
}

[data-theme="light"] .table td {
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

[data-theme="light"] .table tbody tr:hover {
    background: #f8fafc;
}

[data-theme="light"] .form-control {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .form-control:focus {
    background: #ffffff;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

[data-theme="light"] .btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

[data-theme="light"] .btn-secondary:hover {
    background: #e2e8f0;
    color: #0f172a;
}

[data-theme="light"] .badge-success { background: rgba(5, 150, 105, 0.12); color: #047857; }
[data-theme="light"] .badge-warning { background: rgba(217, 119, 6, 0.12); color: #b45309; }
[data-theme="light"] .badge-danger { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }
[data-theme="light"] .badge-secondary { background: #f1f5f9; color: #475569; }
[data-theme="light"] .badge-info { background: rgba(2, 132, 199, 0.12); color: #0369a1; }

[data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.35);
}

[data-theme="light"] .modal-content {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.22);
}

[data-theme="light"] .suggest-box {
    background: #ffffff !important;
    border: 2px solid #4f46e5 !important;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15) !important;
}

[data-theme="light"] .suggest-item {
    border-bottom: 1px solid #f1f5f9;
}

[data-theme="light"] .suggest-item:hover {
    background: #f8fafc;
}

/* ==========================================================================
   Mobile & Responsive Navigation, Drawer & UI Controls
   ========================================================================== */

/* Global Viewport & Container Scroll Protection */
html, body {
    max-width: 100vw;
    overflow-x: hidden !important;
}

.app-container {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* Topbar Flex Sections */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 900;
    transition: all 0.2s ease;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mobile-brand-title {
    display: none;
    font-weight: 900;
    font-size: 15px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="light"] .mobile-brand-title {
    color: #0f172a;
}

/* Flash Alerts */
.flash-alert {
    margin: 14px 20px 0 20px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.flash-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
    color: #34d399;
}

.flash-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #f87171;
}

/* Mobile Hamburger Button */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary);
}

/* Sidebar Close Button */
.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
    background: #ef4444;
    color: #ffffff;
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Refresh Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spin-anim {
    display: inline-block;
    animation: spin 0.75s linear infinite;
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Bottom App Navigation */
.mobile-bottom-nav {
    display: none;
}

/* ==========================================================================
   Breakpoints: Tablets & Laptops (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
}

/* ==========================================================================
   Breakpoints: Mobile & Small Tablets (<= 992px)
   ========================================================================== */
@media (max-width: 992px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }

    .mobile-brand-title {
        display: block;
        max-width: 140px;
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    /* Off-canvas Mobile Drawer */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 1000;
        transform: translateX(105%);
        box-shadow: none;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    }

    html[dir="ltr"] .sidebar {
        right: auto;
        left: 0;
        transform: translateX(-105%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.75);
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main Workspace expands to 100% */
    .main-wrapper,
    html[dir="ltr"] .main-wrapper {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Hide desktop rate chip in small topbar */
    .topbar .rate-chip {
        display: none;
    }

    /* Auto-collapse ANY inline multi-column grids across all views */
    div[style*="grid-template-columns: 2fr"],
    div[style*="grid-template-columns: 3fr"],
    div[style*="grid-template-columns: 1.1fr"],
    div[style*="grid-template-columns: 2.5fr"],
    div[style*="grid-template-columns: 280px"],
    div[style*="grid-template-columns: 320px"],
    div[style*="grid-template-columns: 340px"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 340px"],
    div[style*="grid-template-columns: 1fr 320px"],
    div[style*="grid-template-columns: 2fr 1.5fr"] {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    /* POS Wrapper Stacking on Mobile */
    .pos-wrapper {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .pos-sidebar-section {
        width: 100% !important;
        position: static !important;
        max-height: none !important;
    }

    .pos-main-section {
        width: 100% !important;
    }
}

/* ==========================================================================
   Breakpoints: Mobile Phones (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .topbar {
        padding: 8px 12px;
        height: 56px;
    }

    .content-body {
        padding: 12px 10px 80px 10px !important;
    }

    .flash-alert {
        margin: 10px 10px 0 10px;
        font-size: 12px;
        padding: 10px 12px;
    }

    .nav-btn-text {
        display: none !important;
    }

    .user-info-text {
        display: none !important;
    }

    .user-profile {
        gap: 4px;
        padding: 2px 4px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .stat-card {
        padding: 12px 10px !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stat-val {
        font-size: 16px !important;
    }

    .stat-lbl {
        font-size: 11px !important;
    }

    .stat-icon {
        width: 34px !important;
        height: 34px !important;
        font-size: 16px !important;
    }

    .glass-card {
        padding: 14px 12px !important;
        border-radius: 12px !important;
        margin-bottom: 14px !important;
    }

    .table-responsive {
        border-radius: 10px;
        border: 1px solid var(--border-color);
    }

    .table th, .table td {
        padding: 10px 8px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Mobile Bottom App Navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(15, 23, 42, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border-color);
        z-index: 990;
        justify-content: space-around;
        align-items: center;
        padding: 0 4px;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    }

    [data-theme="light"] .mobile-bottom-nav {
        background: rgba(255, 255, 255, 0.96);
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        color: var(--text-muted);
        text-decoration: none;
        background: transparent;
        border: none;
        padding: 6px 0;
        font-size: 10px;
        font-weight: 800;
        gap: 3px;
        cursor: pointer;
        transition: color 0.15s ease;
    }

    .bottom-nav-item.active, .bottom-nav-item:hover {
        color: var(--primary);
    }

    .bottom-nav-icon {
        font-size: 18px;
        line-height: 1;
    }
}

/* ==========================================================================
   Breakpoints: Extra Small Phones (<= 480px)
   ========================================================================== */
@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr !important;
    }

    .mobile-brand-title {
        max-width: 105px;
        font-size: 13px;
    }
}

/* Enhanced Mobile Bottom-Sheet & Touch UX (<= 640px) */
@media (max-width: 640px) {
    .btn {
        min-height: 38px;
    }
    .form-control {
        font-size: 14px;
        min-height: 40px;
    }
    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        margin: 0 !important;
        padding: 20px 16px 30px 16px !important;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.85) !important;
        animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }
    @keyframes slideUpSheet {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        scrollbar-width: thin;
    }
}




