:root {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --primary-light: #1e293b;
    --secondary: #94a3b8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #0f1117;
    --surface: #1a1d27;
    --surface-alt: #212430;
    --text-main: #e2e8f0;
    --text-muted: #8892a4;
    --border: #2a2d3a;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background-color: var(--background); color: var(--text-main); font-size: 14px; -webkit-font-smoothing: antialiased; }

/* Login */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0f1117 0%, #1a1d27 50%, #1e293b 100%); }
.login-box { background: rgba(26, 29, 39, 0.95); backdrop-filter: blur(10px); padding: 3rem 2.5rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; text-align: center; border: 1px solid var(--border); }
.login-logo { max-width: 220px; margin-bottom: 2rem; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3)); }
.login-box h2 { font-weight: 700; margin-bottom: 1.5rem; color: var(--text-main); }

/* Layout */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 280px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000; box-shadow: var(--shadow-sm); }
.sidebar-header { padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-logo { max-width: 160px; filter: brightness(1.2); }
.nav-section-title { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); margin: 1.5rem 1.5rem 0.5rem; letter-spacing: 0.05em; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.nav-link { display: flex; align-items: center; padding: 0.85rem 1.5rem; color: var(--text-muted); text-decoration: none; font-weight: 600; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-link i { width: 24px; font-size: 1.1rem; }
.nav-link:hover, .nav-link.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); }
.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; padding: 10px; background: var(--surface-alt); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.user-details { display: flex; flex-direction: column; }
.user-name { font-weight: 700; color: var(--text-main); font-size: 0.95rem; }
.user-role { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--background); }
.topbar { background: var(--surface); padding: 1.2rem 2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); z-index: 10; }
.topbar h2 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.content-wrapper { flex: 1; overflow-y: auto; padding: 2rem; }

/* Buttons */
.btn { padding: 0.6rem 1.2rem; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; border: none; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); font-family: inherit; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-main); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s; font-size: 0.9rem; }
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn-icon.danger:hover { background: #fef2f2; color: var(--danger); border-color: var(--danger); }

/* Forms */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-main); font-size: 0.85rem; }
.form-row { display: flex; gap: 15px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], select, textarea { width: 100%; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.95rem; transition: border-color 0.2s, box-shadow 0.2s; background: var(--surface-alt); color: var(--text-main); height: 42px; }
textarea { height: auto; min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
input:disabled, input[readonly] { background: var(--surface) !important; color: var(--text-muted); cursor: not-allowed; border-color: var(--border); }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); z-index: 1; pointer-events: none; }
.input-icon input { padding-left: 2.5rem; }

/* Glass Panel */
.glass-panel { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.brand-text { color: var(--primary-dark); }

/* Dashboard Metrics */
.dashboard-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.metric-card { background: var(--surface); border-radius: var(--radius-md); padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-md); border: 1px solid var(--border); transition: transform 0.2s; }
.metric-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.metric-info h4 { color: var(--text-muted); font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.metric-value { font-size: 2rem; font-weight: 800; color: var(--text-main); }
.metric-icon { width: 56px; height: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.m-blue { background: #1e3a5f; color: #60a5fa; }
.m-green { background: #14332a; color: #22c55e; }
.m-orange { background: #3d2800; color: #fb923c; }

/* Tables Container */
.table-container { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-md); overflow: hidden; border: 1px solid var(--border); margin-bottom: 2rem; }
.table-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--surface-alt); }
.table-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.table-responsive { overflow-x: auto; padding: 1rem; }

/* Compact DataTables Overrides */
table.dataTable { border-collapse: collapse !important; width: 100% !important; font-size: 0.85rem; }
table.dataTable thead th { border-bottom: 2px solid var(--border) !important; color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; padding: 10px 8px !important; background: var(--surface-alt); }
table.dataTable tbody td { border-bottom: 1px solid var(--border); padding: 8px !important; vertical-align: middle; }
table.dataTable tbody tr:hover { background-color: var(--primary-light) !important; }
.dataTables_wrapper .dataTables_filter input { border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; outline: none; transition: 0.2s; }
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.dataTables_wrapper .dataTables_paginate .paginate_button { padding: 4px 10px; margin: 0 2px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--text-main) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--primary) !important; color: white !important; border: 1px solid var(--primary); }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) { background: var(--border) !important; color: var(--text-main) !important; border: 1px solid var(--border); }
.dataTables_wrapper .dataTables_info { font-size: 0.8rem; color: var(--text-muted); padding-top: 10px; }
.dataTables_wrapper .dataTables_length select { height: 32px; padding: 2px 8px; font-size: 0.85rem; border-radius: 4px; }
.dataTables_wrapper .dataTables_filter { margin-bottom: 5px; }
.td-bold { font-weight: 700; color: var(--text-main); display: block; }
.td-sub { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 2px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 0; visibility: hidden; transition: all 0.3s ease; padding: 20px; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 600px; max-height: 90vh; display: flex; flex-direction: column; transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); border: 1px solid rgba(255,255,255,0.2); }
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--surface-alt); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-header h3 { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1.25rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-alt); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Badges */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.badge-done { background: #14332a; color: #4ade80; border: 1px solid #166534; }
.badge-pending { background: #3b1515; color: #f87171; border: 1px solid #7f1d1d; }

/* Select2 Fixes */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 42px; display: flex; align-items: center; padding: 2px 5px; background: var(--surface-alt); color: var(--text-main);
}
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--text-main); }
.select2-container--default .select2-container--focus .select2-selection--multiple { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.select2-container--open { z-index: 999999 !important; }
.select2-dropdown { background: var(--surface); border-color: var(--border); }
.select2-results__option { color: var(--text-main); }
.select2-results__option--highlighted { background: var(--primary) !important; color: white !important; }
.select2-search__field { background: var(--surface-alt) !important; color: var(--text-main) !important; border-color: var(--border) !important; }

/* Toggle Switch */
.toggle-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.toggle-slider { flex-shrink: 0; width: 48px; height: 26px; background-color: #3a3d4a; border-radius: 26px; position: relative; transition: background-color 0.3s ease; }
.toggle-slider::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: white; border-radius: 50%; transition: transform 0.3s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle-switch input:checked + .toggle-slider { background-color: var(--success); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(22px); }
.toggle-label { font-weight: 600; font-size: 0.9rem; color: var(--text-main); line-height: 1.3; }

/* Mobile Adaptations */
.sidebar-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,0.5); z-index: 999; display: none; opacity: 0; visibility: hidden; transition: opacity 0.3s ease; }
.sidebar-overlay.active { display: block; opacity: 1; visibility: visible; }
.mobile-close-btn { display: none; background: none; border: none; font-size: 1.3rem; color: var(--text-muted); cursor: pointer; padding: 5px; }
.mobile-menu-btn { display: none; }
.actions-cell { display: flex; gap: 6px; flex-wrap: nowrap; white-space: nowrap; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -280px; height: 100vh; }
    .sidebar.active { left: 0; }
    .mobile-close-btn { display: block; }
    .mobile-menu-btn { display: inline-flex; }
    .topbar { padding: 1rem; }
    .content-wrapper { padding: 1rem; }
    .form-row { flex-direction: column; gap: 0; }
    table.dataTable tbody td { padding: 10px !important; }
    .pos-layout { flex-direction: column; height: auto; min-height: calc(100vh - 120px); }
    .pos-products { min-height: 300px; }
    .pos-cart { min-width: unset; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* POS Layout */
.pos-layout { display: flex; height: calc(100vh - 120px); gap: 20px; }
.pos-products { flex: 2; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.pos-search { padding: 15px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.pos-grid { flex: 1; overflow-y: auto; padding: 15px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; align-content: start; }
.pos-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 15px; cursor: pointer; transition: all 0.2s; text-align: center; }
.pos-item:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.pos-item h5 { font-size: 0.95rem; margin-bottom: 5px; color: var(--text-main); }
.pos-item span { font-weight: 800; color: var(--primary-dark); font-size: 1.1rem; }
.pos-cart { flex: 1; min-width: 350px; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.cart-header { padding: 15px; background: var(--surface-alt); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; color: var(--primary-dark); }
.cart-items { flex: 1; overflow-y: auto; padding: 15px; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; }
.cart-item-title { font-weight: 600; color: var(--text-main); margin-bottom: 5px; }
.cart-totals { padding: 20px; background: var(--surface-alt); border-top: 1px solid var(--border); }
.cart-total-row { display: flex; justify-content: space-between; font-size: 1.5rem; font-weight: 800; margin-bottom: 15px; }

/* Finance Header */
.finance-header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white; padding: 2rem; border-radius: var(--radius-md); display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.finance-balance-label { font-size: 0.9rem; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.5px; }
.finance-balance { font-size: 2.5rem; font-weight: 800; }

/* Charts */
.dashboard-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.chart-container { background: var(--surface); border-radius: var(--radius-md); padding: 1.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.chart-container h4 { margin-bottom: 1rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 8px; }

/* Printing Styles */
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area { position: absolute; left: 0; top: 0; width: 100%; }
    .ticket { width: 300px; margin: 0 auto; font-family: monospace; }
    .ticket-logo { width: 150px; display: block; margin: 0 auto; filter: grayscale(100%); }
}

/* Utilities */
.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
