/* ============================================
   LIGHT THEME (Default)
   ============================================ */
:root {
    /* Primary Colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    
    /* Secondary Colors */
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    
    /* Status Colors */
    --success-color: #10b981;
    --success-light: #d1fae5;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --info-color: #06b6d4;
    --info-light: #cffafe;
    
    /* Background Colors - Softer whites */
    --bg-primary: #fafbfc;
    --bg-secondary: #f5f7fa;
    --bg-tertiary: #f0f2f5;
    --bg-hover: #f5f7fa;
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-inverse: #ffffff;
    
    /* Border Colors */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    /* Card Colors - Softer whites */
    --card-bg: #fafbfc;
    --card-border: #e2e8f0;
    --card-shadow: rgba(0, 0, 0, 0.05);
    
    /* Input Colors - Softer whites */
    --input-bg: #fafbfc;
    --input-border: #cbd5e1;
    --input-focus: #2563eb;
    
    /* Table Colors - Softer whites */
    --table-bg: #fafbfc;
    --table-header-bg: #f5f7fa;
    --table-hover: #f0f2f5;
    
    /* Topbar / Sidebar */
    --topbar-bg: #2563eb;
    --topbar-text: #ffffff;
    --topbar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-bg: #ffffff;
    --sidebar-text: #111827;
    --sidebar-hover-bg: rgba(15, 23, 42, 0.08);
    --sidebar-active-bg: rgba(15, 23, 42, 0.12);

    /* App Background */
    --app-bg-image: none;
    --app-bg-overlay: transparent;
    
    /* Login Screen */
    --login-bg-color: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --login-bg-image: none;
    --login-card-bg: #fafbfc;
    
    /* Scrollbar */
    --scrollbar-track: #e2e8f0;
    --scrollbar-thumb: #94a3b8;
    --scrollbar-thumb-hover: #64748b;
    --scrollbar-thumb-active: #475569;
}

/* ============================================
   DARK THEME
   ============================================ */
[data-theme="dark"] {
    /* Primary Colors */
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a8a;
    
    /* Secondary Colors */
    --secondary-color: #94a3b8;
    --secondary-hover: #cbd5e1;
    
    /* Status Colors */
    --success-color: #22c55e;
    --success-light: #14532d;
    --danger-color: #f87171;
    --danger-light: #7f1d1d;
    --warning-color: #fbbf24;
    --warning-light: #78350f;
    --info-color: #38bdf8;
    --info-light: #0c4a6e;
    
    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #1e293b;
    
    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-inverse: #0f172a;
    
    /* Border Colors */
    --border-color: #334155;
    --border-hover: #475569;
    
    /* Card Colors */
    --card-bg: #1e293b;
    --card-border: #334155;
    --card-shadow: rgba(0, 0, 0, 0.3);
    
    /* Input Colors */
    --input-bg: #1e293b;
    --input-border: #475569;
    --input-focus: #3b82f6;
    
    /* Table Colors */
    --table-bg: #1e293b;
    --table-header-bg: #0f172a;
    --table-hover: #334155;
    
    /* Topbar / Sidebar */
    --topbar-bg: #1e293b;
    --topbar-text: #f1f5f9;
    --topbar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-bg: #1e293b;
    --sidebar-text: #f1f5f9;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.12);
    --sidebar-active-bg: rgba(255, 255, 255, 0.18);

    /* App Background */
    --app-bg-image: none;
    --app-bg-overlay: transparent;
    
    /* Login Screen */
    --login-bg-color: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --login-bg-image: none;
    --login-card-bg: #1e293b;
    
    /* Scrollbar */
    --scrollbar-track: #1e293b;
    --scrollbar-thumb: #64748b;
    --scrollbar-thumb-hover: #94a3b8;
    --scrollbar-thumb-active: #cbd5e1;
}

/* ============================================
   BASE STYLES
   ============================================ */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* App background image applied to full app */
body.app-bg-enabled::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: var(--app-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(0);
    opacity: 1;
    z-index: 0;
    pointer-events: none;
}

body.app-bg-enabled::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--app-bg-overlay);
    backdrop-filter: blur(0);
    z-index: 0;
    pointer-events: none;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--login-bg-color);
    background-image: var(--login-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.login-card {
    background: var(--login-card-bg);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 450px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .login-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-logo {
    margin-bottom: 1rem;
    animation: fadeInDown 0.6s ease;
}

.login-logo i {
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 8px rgba(37, 99, 235, 0.3));
}

.login-title {
    font-weight: 700;
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    animation: fadeInUp 0.6s ease 0.2s both;
}

.login-subtitle {
    font-size: 0.9rem;
    animation: fadeInUp 0.6s ease 0.3s both;
}

.login-card .form-label {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.login-card .form-label i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

.login-card .form-control,
.login-card .form-control-lg {
    background-color: var(--input-bg);
    border: 2px solid var(--input-border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.login-card .form-control:focus,
.login-card .form-control-lg:focus {
    background-color: var(--input-bg);
    border-color: var(--input-focus);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
    transform: translateY(-2px);
}

.login-btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

#forgotPasswordLink,
#helpLink {
    color: var(--primary-color);
    transition: all 0.3s ease;
    font-weight: 500;
}

#forgotPasswordLink:hover,
#helpLink:hover {
    color: var(--primary-hover);
    text-decoration: underline !important;
    transform: translateX(2px);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   TOP BAR
   ============================================ */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    align-items: center;
    transition: left 0.3s ease;
}

.topbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 1rem;
    height: 100%;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--topbar-text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle i {
    transition: transform 0.3s ease, filter 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: var(--topbar-hover-bg);
    transform: scale(1.1);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--topbar-text);
    text-decoration: none;
    font-weight: bold;
    font-size: 1.25rem;
    transition: opacity 0.3s ease;
}

.topbar-brand:hover {
    opacity: 0.8;
}

.topbar-brand i {
    font-size: 1.5rem;
}

.brand-text {
    transition: opacity 0.3s ease;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-branch {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.topbar-branch .form-select {
    min-width: 150px;
    max-width: 220px;
}

.topbar-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--topbar-text);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.topbar-btn:hover {
    background-color: var(--topbar-hover-bg);
    transform: translateY(-2px);
}

.topbar-btn-text {
    transition: opacity 0.3s ease;
}

.topbar-user .dropdown-menu {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: 0 4px 6px var(--card-shadow);
    margin-top: 0.5rem;
}

.topbar-user .dropdown-item {
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.topbar-user .dropdown-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 260px;
    height: calc(100vh - 60px);
    overflow: hidden;
    background-color: var(--sidebar-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.35s ease, width 0.35s ease, opacity 0.35s ease;
    z-index: 999;
}

.sidebar.collapsed {
    width: 260px;
    transform: translateX(calc(-100% - 1px));
    opacity: 0;
    pointer-events: none;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-content {
    padding: 1rem 0;
    position: relative;
    z-index: 1;
}

.sidebar-nav {
    padding: 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text);
    border-left-color: var(--sidebar-text);
}

.nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text);
    border-left-color: var(--sidebar-text);
    font-weight: 600;
}

.nav-link i {
    font-size: 1.25rem;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-text);
}

.nav-text {
    transition: opacity 0.3s ease;
    white-space: nowrap;
    color: var(--sidebar-text);
}

/* Navigation Sections */
.nav-section {
    margin: 1.5rem 0;
    padding: 0 1.25rem;
}

.nav-section-header {
    margin-bottom: 0.5rem;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.7);
    transition: opacity 0.3s ease;
}

/* White navbar theme tweaks for sidebar readability */
:root.sidebar-theme-white .sidebar {
    border-right: 1px solid rgba(15, 23, 42, 0.12);
}

:root.sidebar-theme-white .nav-section-title {
    color: rgba(15, 23, 42, 0.65);
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* never block clicks */
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: none; /* keep non-blocking even when active */
}

/* Ensure receipt switches are always clickable */
#receiptForm .form-check-input {
    pointer-events: auto !important;
}

/* Light theme: ensure checked switches are visible with blue fill */
:root:not([data-theme="dark"]) .form-check-input:checked {
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

/* ✅ ON state: pure green track, white thumb clearly visible */
#receiptForm .form-check-input:checked {
    background-color: #198754 !important; /* Bootstrap success green */
    border-color: #198754 !important;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

/* ✅ OFF state: pure grey track */
#receiptForm .form-check-input:not(:checked) {
    background-color: #6c757d !important; /* Bootstrap secondary grey */
    border-color: #6c757d !important;
}

/* Sound toggle uses the same receipt switch styling */
#soundEnabledToggle.form-check-input {
    pointer-events: auto !important;
}

#soundEnabledToggle.form-check-input:checked {
    background-color: #198754 !important; /* Bootstrap success green */
    border-color: #198754 !important;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

#soundEnabledToggle.form-check-input:not(:checked) {
    background-color: #6c757d !important; /* Bootstrap secondary grey */
    border-color: #6c757d !important;
}

/* Payment method switches: visible in both light and dark themes */
#paymentMethodsList .form-check-input {
    border-color: #6c757d !important;
}

#paymentMethodsList .form-check-input:not(:checked) {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

#paymentMethodsList .form-check-input:checked {
    background-color: #198754 !important;
    border-color: #198754 !important;
}

:root:not([data-theme="dark"]) #paymentMethodsList .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%230f172a'/%3e%3c/svg%3e") !important;
}

[data-theme="dark"] #paymentMethodsList .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}

/* Store Management sellable switch: visible in both light and dark themes */
.store-sellable-toggle.form-check-input {
    border-color: #6c757d !important;
}

.store-sellable-toggle.form-check-input:not(:checked) {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

.store-sellable-toggle.form-check-input:checked {
    background-color: #198754 !important;
    border-color: #198754 !important;
}

:root:not([data-theme="dark"]) .store-sellable-toggle.form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%230f172a'/%3e%3c/svg%3e") !important;
}

[data-theme="dark"] .store-sellable-toggle.form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}
/* ===== PERMISSION SWITCHES – Same Green/Grey as Receipt Switches ===== */
.permission-switch.form-check-input:checked {
    background-color: #198754 !important; /* Bootstrap success green */
    border-color: #198754 !important;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

.permission-switch.form-check-input:not(:checked) {
    background-color: #6c757d !important; /* Bootstrap secondary grey */
    border-color: #6c757d !important;
}

/* Ensure the thumb (white circle) is visible on green */
.permission-switch.form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}

/* Store Management row checkboxes: explicit checkmark colors for light/dark themes */
#storeSelectAllCheckbox.form-check-input,
.store-row-select.form-check-input,
.store-select-checkbox.form-check-input {
    background-color: var(--input-bg) !important;
    border-color: var(--border-hover) !important;
}

#storeSelectAllCheckbox.form-check-input:focus,
.store-row-select.form-check-input:focus,
.store-select-checkbox.form-check-input:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25) !important;
}

:root:not([data-theme="dark"]) #storeSelectAllCheckbox.form-check-input:checked,
:root:not([data-theme="dark"]) .store-row-select.form-check-input:checked,
:root:not([data-theme="dark"]) .store-select-checkbox.form-check-input:checked {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%230f172a' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M5 10.5l3 3 7-7'/%3E%3C/svg%3E") !important;
}

[data-theme="dark"] #storeSelectAllCheckbox.form-check-input:checked,
[data-theme="dark"] .store-row-select.form-check-input:checked,
[data-theme="dark"] .store-select-checkbox.form-check-input:checked {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M5 10.5l3 3 7-7'/%3E%3C/svg%3E") !important;
}
/* Make sure stale backdrops never block inputs */
.modal-backdrop {
    pointer-events: none !important;
}
/* Main Content */
.main-content {
    margin-left: 260px;
    margin-top: 60px;
    padding: 1.5rem;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 0;
}

body.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(90deg);
}

body.sidebar-collapsed .sidebar-toggle {
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.6), 0 0 16px rgba(13, 110, 253, 0.35);
    animation: sidebarToggleGlowDark 1.4s ease-in-out infinite alternate;
}

@keyframes sidebarToggleGlowDark {
    from {
        box-shadow: 0 0 6px rgba(13, 110, 253, 0.45), 0 0 10px rgba(13, 110, 253, 0.25);
    }
    to {
        box-shadow: 0 0 12px rgba(13, 110, 253, 0.75), 0 0 20px rgba(13, 110, 253, 0.45);
    }
}

/* Light theme: black toggle with white icon lines and white glow when sidebar is collapsed */
:root[data-theme="light"] body.sidebar-collapsed #sidebarToggle.sidebar-toggle {
    color: #ffffff !important;
    background-color: #0b3d91;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.95), 0 0 16px rgba(255, 255, 255, 0.75);
    animation: sidebarToggleGlowLight 1.4s ease-in-out infinite alternate;
}

:root[data-theme="light"] body.sidebar-collapsed #sidebarToggle.sidebar-toggle i {
    color: #ffffff !important;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.95));
}

@keyframes sidebarToggleGlowLight {
    from {
        box-shadow: 0 0 6px rgba(255, 255, 255, 0.75), 0 0 12px rgba(255, 255, 255, 0.55);
    }
    to {
        box-shadow: 0 0 12px rgba(255, 255, 255, 1), 0 0 24px rgba(255, 255, 255, 0.8);
    }
}

/* Dark theme keeps blue glow */
:root[data-theme="dark"] body.sidebar-collapsed .sidebar-toggle {
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.6), 0 0 16px rgba(13, 110, 253, 0.35);
    animation: sidebarToggleGlowDark 1.4s ease-in-out infinite alternate;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: 260px;
        transform: translateX(-100%);
        opacity: 1;
        pointer-events: auto;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .brand-text {
        display: none;
    }
    
    .topbar-btn-text {
        display: none;
    }
    
    .nav-section-title {
        display: none;
    }
}

/* Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 10px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 5px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
    border: 2px solid var(--scrollbar-track);
    min-height: 30px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    border-color: var(--scrollbar-thumb);
}

.sidebar::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
}

/* Page Content */
.page-content {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: 0 2px 10px var(--card-shadow);
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-header {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

/* Override Bootstrap's bg-white class for dark theme */
.bg-white {
    background-color: var(--card-bg) !important;
}

[data-theme="dark"] .bg-white {
    background-color: var(--card-bg) !important;
}

.card-body {
    color: var(--text-primary);
}

.card-title {
    color: var(--text-primary);
}

.card-subtitle {
    color: var(--text-secondary);
}

/* Product Grid */
#productGrid {
    max-height: 600px;
    overflow-y: auto;
}

.product-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s;
    cursor: pointer;
    height: 100%;
    position: relative;
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px var(--card-shadow);
    border-color: var(--primary-color);
    background-color: var(--bg-hover);
}

.product-card[data-in-stock="true"]:active {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.product-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 0.5rem;
}

.product-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.product-price {
    color: var(--success-color);
    font-weight: bold;
    font-size: 1.1rem;
}

.product-stock {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.product-stock.low {
    color: var(--danger-color);
    font-weight: 600;
}

/* Shopping Cart */
.cart-items {
    max-height: 400px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.cart-item-price {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-quantity input {
    width: 60px;
    text-align: center;
}

.cart-item-total {
    font-weight: 600;
    min-width: 80px;
    text-align: right;
}

.cart-summary {
    border-top: 2px solid var(--border-color);
    padding-top: 1rem;
    color: var(--text-primary);
}

/* ============================================
   TABLES
   ============================================ */
.table {
    background-color: var(--table-bg);
    color: var(--text-primary);
}

.table thead {
    background-color: var(--table-header-bg);
    color: var(--text-primary);
}

.table th {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table td {
    color: var(--text-primary);
    border-color: var(--border-color);
    background-color: var(--table-bg) !important;
}

.table tbody {
    background-color: var(--table-bg) !important;
}

.table tbody tr {
    background-color: var(--table-bg) !important;
    color: var(--text-primary) !important;
}

.table tbody td {
    background-color: var(--table-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table-hover tbody tr:hover {
    background-color: var(--table-hover) !important;
    color: var(--text-primary) !important;
}

.table-hover tbody tr:hover td {
    background-color: var(--table-hover) !important;
    color: var(--text-primary) !important;
}

/* Override Bootstrap's table-light class for dark theme */
.table-light {
    background-color: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .table-light {
    background-color: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .table-light th {
    background-color: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Ensure all table headers use theme colors */
.table thead th {
    background-color: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Override Bootstrap table-striped for dark theme */
.table-striped > tbody > tr:nth-of-type(odd) > td,
.table-striped > tbody > tr:nth-of-type(odd) > th {
    background-color: var(--table-bg) !important;
    color: var(--text-primary) !important;
}

.table-striped > tbody > tr:nth-of-type(even) > td,
.table-striped > tbody > tr:nth-of-type(even) > th {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td,
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > th {
    background-color: var(--table-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > td,
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > th {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Buttons */
.btn {
    border-radius: 5px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Badges */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
}

/* Alerts */
.alert {
    border-radius: 5px;
    border: none;
}

/* ============================================
   LOW STOCK ALERTS
   ============================================ */
.low-stock-item {
    padding: 0.75rem;
    border-left: 4px solid var(--danger-color);
    background-color: var(--warning-light);
    margin-bottom: 0.5rem;
    border-radius: 4px;
    color: var(--text-primary);
}

.low-stock-item .product-name {
    font-weight: 600;
    color: var(--danger-color);
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* POS Product Grid - Responsive Image-based Layout */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0.5rem 0.25rem 0.5rem;
    min-height: calc(100% - 1rem);
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
}

@media (min-width: 1200px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Print Styles for Reports */
@media print {
    .navbar, .sidebar, .btn, .card-header button, #reportContent .btn {
        display: none !important;
    }
    
    .page-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .table {
        font-size: 11px;
    }
    
    canvas {
        max-height: 300px !important;
    }
    
    @page {
        margin: 1cm;
    }
}

.product-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    color: var(--text-primary);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--card-shadow);
    border-color: var(--primary-color);
}

.product-card.out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--border-color);
}

.product-card.out-of-stock:hover {
    transform: none;
    box-shadow: none;
}

.product-card.low-stock {
    border-color: var(--warning-color);
}

.product-card-image {
    width: 100%;
    height: 160px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card-placeholder {
    font-size: 3.5rem;
    color: var(--text-tertiary);
}

.product-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.product-card-body {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
}

.product-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--text-primary);
    line-height: 1.3;
    min-height: 2.6em;
}

.product-card-category {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-card-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--success-color);
    margin-top: auto;
    margin-bottom: 0.25rem;
}

.product-card-stock {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.product-card-stock.low-stock {
    color: var(--warning-color);
    font-weight: 600;
}

.product-card-stock.out-of-stock {
    color: var(--danger-color);
    font-weight: 600;
}

/* Add to cart animation */
@keyframes addToCartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.product-card.adding {
    animation: addToCartPulse 0.3s ease;
    border-color: var(--success-color);
}

/* ============================================
   RECEIPT STYLES
   ============================================ */
.receipt {
    background: var(--card-bg);
    padding: 2rem;
    max-width: 400px;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.receipt-footer {
    white-space: pre-wrap; /* Preserves spaces and line breaks */
}

/* Receipt sizes */
.receipt.size-80mm {
    max-width: 300px;
    font-size: 12px;
    padding: 1rem;
}

.receipt.size-a4 {
    max-width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    font-size: 14px;
    font-family: 'Segoe UI', Arial, sans-serif;
}

/* Print styles */
@media print {
    .receipt.size-80mm {
        width: 80mm;
        max-width: 80mm;
    }
    
    .receipt.size-a4 {
        width: 210mm;
        height: 297mm;
    }
    
    /* Hide everything except receipt when printing */
    body * {
        visibility: hidden;
    }
    
    .receipt, .receipt * {
        visibility: visible;
    }
    
    .receipt {
        position: absolute;
        left: 0;
        top: 0;
    }
}

.receipt-header {
    text-align: center;
    border-bottom: 2px dashed var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.receipt-items {
    margin-bottom: 1rem;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.receipt-total {
    border-top: 2px dashed var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
    font-weight: bold;
    color: var(--text-primary);
}

/* ============================================
   MODALS
   ============================================ */
.modal-content {
    background-color: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px var(--card-shadow);
    color: var(--text-primary);
}

.modal-header {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.modal-title {
    color: var(--text-primary);
}

.modal-body {
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.modal-footer {
    background-color: var(--bg-secondary);
    border-top: 2px solid var(--border-color);
}

/* ============================================
   FORMS
   ============================================ */
.form-control,
.form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--input-focus);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

.form-label {
    color: var(--text-primary);
}

.form-text {
    color: var(--text-secondary);
}

.input-group-text {
    background-color: var(--bg-secondary);
    border-color: var(--input-border);
    color: var(--text-primary);
}

/* ============================================
   SCROLLBAR - Enhanced Visibility
   ============================================ */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-track);
    min-height: 30px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    border-color: var(--scrollbar-thumb);
}

::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
}

/* Firefox scrollbar support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Make scrollbars always visible on scrollable containers */
.page-content,
.main-content,
.modal-body,
.card-body,
.table-responsive {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.page-content::-webkit-scrollbar,
.main-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.card-body::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.page-content::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.card-body::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 6px;
}

.page-content::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.card-body::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-track);
    min-height: 30px;
}

.page-content::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.card-body::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    border-color: var(--scrollbar-thumb);
}

.page-content::-webkit-scrollbar-thumb:active,
.main-content::-webkit-scrollbar-thumb:active,
.modal-body::-webkit-scrollbar-thumb:active,
.card-body::-webkit-scrollbar-thumb:active,
.table-responsive::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
}

/* Responsive */
@media (max-width: 768px) {
    .login-card {
        margin: 1rem;
    }

    .product-card {
        margin-bottom: 1rem;
    }
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    border-radius: 5px;
    border: none;
    color: var(--text-primary);
}

.alert-success {
    background-color: var(--success-light);
    color: var(--text-primary);
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background-color: var(--danger-light);
    color: var(--text-primary);
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background-color: var(--warning-light);
    color: var(--text-primary);
    border-left: 4px solid var(--warning-color);
}

/* POS: slightly larger buttons for faster touch/click use */
#posPage .btn {
    padding: 0.48rem 0.9rem;
    font-size: 0.98rem;
}

#posPage .btn.btn-sm {
    padding: 0.38rem 0.7rem;
    font-size: 0.9rem;
}

.alert-info {
    background-color: var(--info-light);
    color: var(--text-primary);
    border-left: 4px solid var(--info-color);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
}

/* ============================================
   TEXT UTILITIES
   ============================================ */
.text-muted {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.text-info {
    color: var(--info-color) !important;
}

/* ============================================
   THEME TOGGLE BUTTON (Now in topbar)
   ============================================ */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--topbar-text);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* ============================================
   DASHBOARD CARDS - Consistent Styling
   ============================================ */
/* All dashboard cards use consistent theme colors */
.dashboard-card-clock,
.dashboard-card-primary,
.dashboard-card-info,
.dashboard-card-success,
.dashboard-card-warning {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--card-border) !important;
}

/* Metric Cards with Custom Colors */
/* Base metric card styles - shared by all metric cards */
.metric-card-blue,
.metric-card-light-blue,
.metric-card-light-red,
.metric-card-light-green,
.metric-card-green,
.metric-card-yellow {
    color: var(--text-inverse) !important;
    border: none !important;
    margin-bottom: 1.5rem !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, color 0.3s ease;
    min-height: 140px;
}

/* Light theme - Beautiful color palette (5 colors) */
/* 1. Deep Blue */
.metric-card-blue {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
}

/* 2. Purple/Violet */
.metric-card-light-blue {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
}

/* 3. Teal/Cyan */
.metric-card-light-red {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%) !important;
}

/* 4. Emerald Green */
.metric-card-light-green {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}

/* 5. Orange/Amber */
.metric-card-green {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
}

.metric-card-yellow {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

/* Dark theme - Rich, deep colors optimized for dark backgrounds */
/* 1. Deep Blue */
[data-theme="dark"] .metric-card-blue {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important;
}

/* 2. Deep Purple */
[data-theme="dark"] .metric-card-light-blue {
    background: linear-gradient(135deg, #5b21b6 0%, #6d28d9 100%) !important;
}

/* 3. Deep Teal */
[data-theme="dark"] .metric-card-light-red {
    background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%) !important;
}

/* 4. Deep Emerald */
[data-theme="dark"] .metric-card-light-green {
    background: linear-gradient(135deg, #047857 0%, #059669 100%) !important;
}

/* 5. Deep Orange */
[data-theme="dark"] .metric-card-green {
    background: linear-gradient(135deg, #c2410c 0%, #ea580c 100%) !important;
}

[data-theme="dark"] .metric-card-yellow {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%) !important;
}

/* Metric card text colors - theme-aware */
.metric-card-text {
    color: var(--text-inverse) !important;
    font-weight: 600;
    font-family: inherit;
    transition: color 0.3s ease, font-weight 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.metric-card-text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
    font-family: inherit;
    transition: color 0.3s ease;
}

/* Keep metric values on a single line; JS auto-fit handles long values */
.metric-card-text,
#accountingDashboard .card-title,
#reportContent .card.text-white .card-title,
#accountingReportContent .card.text-white .card-title,
#totalAccountsBalance {
    display: block;
    max-width: 100%;
    line-height: 1.2;
    font-size: clamp(0.95rem, 1.8vw, 1.75rem);
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    letter-spacing: -0.01em;
}

/* Allow text column to shrink in metric flex rows so values can shrink without overflow */
#dashboardPage .card .d-flex.justify-content-between.align-items-start > div,
#accountingPage .card .d-flex.justify-content-between.align-items-start > div,
#reportContent .card .d-flex.justify-content-between.align-items-start > div,
#accountingReportContent .card .d-flex.justify-content-between.align-items-start > div {
    min-width: 0;
    flex: 1 1 auto;
}

/* Keep icons readable without stealing width from long values */
#dashboardPage .card .d-flex.justify-content-between.align-items-start > i,
#accountingPage .card .d-flex.justify-content-between.align-items-start > i,
#reportContent .card .d-flex.justify-content-between.align-items-start > i,
#accountingReportContent .card .d-flex.justify-content-between.align-items-start > i {
    flex-shrink: 0;
    margin-left: 0.75rem;
}

/* Dark theme adjustments for metric cards */
[data-theme="dark"] .metric-card-blue,
[data-theme="dark"] .metric-card-light-blue,
[data-theme="dark"] .metric-card-light-red,
[data-theme="dark"] .metric-card-light-green,
[data-theme="dark"] .metric-card-green,
[data-theme="dark"] .metric-card-yellow {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

/* Dark theme - slightly brighter text for better visibility */
[data-theme="dark"] .metric-card-text {
    color: var(--text-inverse) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .metric-card-text-muted {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Light theme - ensure text is visible */
[data-theme="light"] .metric-card-text {
    color: var(--text-inverse) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .metric-card-text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Hover effects for all metric cards */
.metric-card-blue:hover,
.metric-card-light-blue:hover,
.metric-card-light-red:hover,
.metric-card-light-green:hover,
.metric-card-green:hover,
.metric-card-yellow:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Dark theme hover effects */
[data-theme="dark"] .metric-card-blue:hover,
[data-theme="dark"] .metric-card-light-blue:hover,
[data-theme="dark"] .metric-card-light-red:hover,
[data-theme="dark"] .metric-card-light-green:hover,
[data-theme="dark"] .metric-card-green:hover,
[data-theme="dark"] .metric-card-yellow:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
}

/* Ensure good spacing in metric card rows */
.row.mb-4 .col-md-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Dashboard clock card styling */
.dashboard-clock-card {
    background: #000000 !important;
}

.dashboard-clock-time {
    font-size: 2rem;
    letter-spacing: 2px;
}

.dashboard-clock-date {
    font-size: 1rem;
}

.row.mb-4 .col-sm-6 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Dashboard card headers */
.dashboard-card-clock .card-header,
.dashboard-card-primary .card-header,
.dashboard-card-info .card-header,
.dashboard-card-success .card-header,
.dashboard-card-warning .card-header {
    background-color: var(--bg-secondary) !important;
    border-bottom-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Dashboard card body */
.dashboard-card-clock .card-body,
.dashboard-card-primary .card-body,
.dashboard-card-info .card-body,
.dashboard-card-success .card-body,
.dashboard-card-warning .card-body {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

/* ============================================
   ACCOUNTING PAGE CARDS
   ============================================ */
/* Accounting dashboard cards with theme-aware colors */
.accounting-card-primary {
    background-color: var(--primary-color) !important;
    color: var(--text-inverse) !important;
    border-color: var(--primary-color) !important;
}

.accounting-card-info {
    background-color: var(--info-color) !important;
    color: var(--text-inverse) !important;
    border-color: var(--info-color) !important;
}

.accounting-card-danger {
    background-color: var(--danger-color) !important;
    color: var(--text-inverse) !important;
    border-color: var(--danger-color) !important;
}

.accounting-card-success {
    background-color: var(--success-color) !important;
    color: var(--text-inverse) !important;
    border-color: var(--success-color) !important;
}

/* Accounting card subtitles - use semi-transparent inverse text */
.accounting-card-subtitle {
    color: rgba(255, 255, 255, 0.8) !important;
    opacity: 0.9;
}

/* Ensure card titles are visible */
.accounting-card-primary .card-title,
.accounting-card-info .card-title,
.accounting-card-danger .card-title,
.accounting-card-success .card-title {
    color: var(--text-inverse) !important;
}

/* Dark theme adjustments - ensure text is visible */
[data-theme="dark"] .accounting-card-subtitle {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Light theme - ensure text is visible on colored backgrounds */
:root .accounting-card-subtitle {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* ============================================
   ACCOUNTING REPORT METRICS CARDS
   ============================================ */
/* Ensure accounting report metrics cards display correctly */
#accountingReportContent .card.text-white.bg-primary,
#accountingReportContent .card.text-white.bg-success,
#accountingReportContent .card.text-white.bg-info,
#accountingReportContent .card.text-white.bg-warning {
    background-color: inherit !important;
    color: inherit !important;
    border: none !important;
}

/* Override any print styles that might affect these cards */
@media not print {
    #accountingReportContent .card.text-white.bg-primary {
        background-color: var(--primary-color) !important;
        color: var(--text-inverse) !important;
    }
    
    #accountingReportContent .card.text-white.bg-success {
        background-color: var(--success-color) !important;
        color: var(--text-inverse) !important;
    }
    
    #accountingReportContent .card.text-white.bg-info {
        background-color: var(--info-color) !important;
        color: var(--text-inverse) !important;
    }
    
    #accountingReportContent .card.text-white.bg-warning {
        background-color: var(--warning-color) !important;
        color: var(--text-inverse) !important;
    }
}

/* Ensure text is visible on colored backgrounds */
#accountingReportContent .card.text-white .card-subtitle,
#accountingReportContent .card.text-white .card-title,
#accountingReportContent .card.text-white .small,
#accountingReportContent .card.text-white .text-white-50 {
    color: var(--text-inverse) !important;
}

/* Ensure proper spacing and layout for metrics cards */
#accountingReportContent .row.mb-4 {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

#accountingReportContent .col-md-3.col-sm-6.mb-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Hover effects for metrics cards */
#accountingReportContent .card.text-white:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

/* ============================================
   ACCOUNTING PAGE TABS
   ============================================ */
/* Accounting tabs - theme-aware text colors */
#accountingTabs.nav-tabs .nav-link,
#accountingTabs .nav-item .nav-link {
    color: var(--text-primary) !important;
    background-color: transparent !important;
    border-color: var(--border-color) !important;
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease !important;
}

/* Hover state */
#accountingTabs.nav-tabs .nav-link:hover,
#accountingTabs .nav-item .nav-link:hover {
    color: var(--primary-color) !important;
    background-color: var(--bg-hover) !important;
    border-color: var(--primary-color) !important;
}

/* Active tab styling - visible in both themes */
#accountingTabs.nav-tabs .nav-link.active,
#accountingTabs .nav-item .nav-link.active,
#accountingTabs .nav-link[aria-selected="true"] {
    color: #ffffff !important;
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    font-weight: 600 !important;
}

/* Light theme - ensure black text on inactive tabs */
:root #accountingTabs.nav-tabs .nav-link:not(.active),
:root #accountingTabs .nav-item .nav-link:not(.active) {
    color: #0f172a !important;
}

:root #accountingTabs.nav-tabs .nav-link.active,
:root #accountingTabs .nav-item .nav-link.active {
    color: #ffffff !important;
    background-color: var(--primary-color) !important;
}

/* Dark theme - ensure light text on inactive tabs */
[data-theme="dark"] #accountingTabs.nav-tabs .nav-link:not(.active),
[data-theme="dark"] #accountingTabs .nav-item .nav-link:not(.active) {
    color: var(--text-primary) !important;
}

[data-theme="dark"] #accountingTabs.nav-tabs .nav-link.active,
[data-theme="dark"] #accountingTabs .nav-item .nav-link.active {
    color: #ffffff !important;
    background-color: var(--primary-color) !important;
}

/* Dashboard card text - use theme colors */
.dashboard-card-text {
    color: var(--text-primary) !important;
}

.dashboard-card-text-muted {
    color: var(--text-secondary) !important;
}

/* Dashboard card tables */
.dashboard-card-clock .table,
.dashboard-card-primary .table,
.dashboard-card-info .table,
.dashboard-card-success .table {
    background-color: var(--table-bg) !important;
    color: var(--text-primary) !important;
}

.dashboard-card-clock .table thead th,
.dashboard-card-primary .table thead th,
.dashboard-card-info .table thead th,
.dashboard-card-success .table thead th {
    background-color: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.dashboard-card-clock .table tbody td,
.dashboard-card-primary .table tbody td,
.dashboard-card-info .table tbody td,
.dashboard-card-success .table tbody td {
    background-color: var(--table-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.dashboard-card-clock .table-hover tbody tr:hover,
.dashboard-card-primary .table-hover tbody tr:hover,
.dashboard-card-info .table-hover tbody tr:hover,
.dashboard-card-success .table-hover tbody tr:hover {
    background-color: var(--table-hover) !important;
}

/* ============================================
   CUSTOMER SEARCH DROPDOWN
   ============================================ */
#customerSearchResults {
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: #fff;
}

.customer-search-item {
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.customer-search-item:hover {
    background-color: #f8f9fa !important;
}

.customer-search-item:last-child {
    border-bottom: none !important;
}

.customer-search-item:first-child {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

.customer-search-item:last-child {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        background: white;
    }

    .navbar,
    .btn,
    .modal-footer,
    .theme-toggle-btn {
        display: none !important;
    }

    .receipt {
        max-width: 100%;
        padding: 1rem;
        background: white;
        color: black;
    }
}
/* QUOTATION SPECIFIC STYLES */

/* Product Grid for Quotations */
.quotation-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.quotation-product-card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 220px; /* Increased height for more space */
    background: white;
}

.quotation-product-card:hover:not(.quotation-product-out-of-stock) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #0d6efd;
}

.quotation-product-card.quotation-product-out-of-stock {
    opacity: 0.6;
    cursor: not-allowed;
}

.quotation-product-card.quotation-product-low-stock {
    border-color: #ffc107;
}

/* Product Image */
.quotation-product-image-container {
    width: 100%;
    height: 110px; /* Increased image area */
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #e9ecef;
    position: relative;
}

.quotation-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.quotation-product-image.d-none {
    display: none;
}

.quotation-product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    background: #f8f9fa;
}

.quotation-product-image-placeholder i {
    font-size: 2rem;
}

/* Product Info */
.quotation-product-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.quotation-product-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 6px;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    min-height: 2.2em;
}

.quotation-product-price {
    font-size: 0.95rem;
    font-weight: bold;
    color: #198754;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quotation-product-category {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quotation-product-stock {
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.quotation-product-stock.quotation-product-low-stock {
    color: #fd7e14;
}

.quotation-product-stock.quotation-product-out-of-stock {
    color: #dc3545;
}

/* Type Badges - FIXED POSITION */
.quotation-product-type-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.7rem;
    padding: 3px 7px;
    border-radius: 4px;
    z-index: 2;
}

/* Stock Badge - FIXED POSITION */
.quotation-product-stock-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.7rem;
    padding: 3px 7px;
    border-radius: 4px;
    z-index: 2;
}

/* Add Button */
.quotation-product-add-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0;
    border: none;
    background-color: #198754;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.quotation-product-add-btn:hover {
    background-color: #157347;
}

/* Stock Indicator Dot */
.quotation-stock-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.quotation-stock-indicator.quotation-in-stock {
    background-color: #198754;
}

.quotation-stock-indicator.quotation-low-stock {
    background-color: #ffc107;
}

.quotation-stock-indicator.quotation-out-of-stock {
    background-color: #dc3545;
}

/* Quotation Items List */
.quotation-items-container {
    max-height: 300px;
    overflow-y: auto;
}

.quotation-item {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.3s ease;
}

.quotation-item:hover {
    background-color: #f8f9fa;
}

.quotation-item.highlight {
    background-color: rgba(25, 135, 84, 0.1);
    animation: quotation-highlight-fade 1s ease-out;
}

@keyframes quotation-highlight-fade {
    0% { background-color: rgba(25, 135, 84, 0.3); }
    100% { background-color: rgba(25, 135, 84, 0.1); }
}

.quotation-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #212529;
    margin-bottom: 4px;
}

.quotation-item-details {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.quotation-item-quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quotation-item-quantity-input {
    width: 60px;
    text-align: center;
    font-size: 0.9rem;
}

.quotation-item-price-input {
    width: 100%;
    font-size: 0.9rem;
}

.quotation-item-discount-input {
    width: 100%;
    font-size: 0.9rem;
}

.quotation-item-total {
    font-weight: 600;
    color: #212529;
    font-size: 0.95rem;
}

/* Quotation Totals */
.quotation-totals {
    border-top: 2px solid #dee2e6;
    padding-top: 12px;
}

.quotation-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.quotation-total-row.quotation-grand-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: #212529;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #dee2e6;
}

/* Scrollbar Styling */
.quotation-product-grid::-webkit-scrollbar,
.quotation-items-container::-webkit-scrollbar {
    width: 8px;
}

.quotation-product-grid::-webkit-scrollbar-track,
.quotation-items-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.quotation-product-grid::-webkit-scrollbar-thumb,
.quotation-items-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.quotation-product-grid::-webkit-scrollbar-thumb:hover,
.quotation-items-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Grid */
@media (min-width: 1200px) {
    .quotation-product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .quotation-product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    .quotation-product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575px) {
    .quotation-product-grid {
        grid-template-columns: 1fr;
    }
    
    .quotation-product-card {
        height: auto;
        flex-direction: row;
    }
    
    .quotation-product-image-container {
        width: 110px;
        height: 110px;
        border-bottom: none;
        border-right: 1px solid #e9ecef;
    }
    
    .quotation-product-info {
        flex: 1;
        padding: 12px;
    }
}

/* Empty State */
.quotation-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.quotation-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.quotation-empty-state p {
    margin: 0;
    font-size: 1rem;
}

/* Loading State */
.quotation-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #6c757d;
}

.quotation-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Compact Button */
.quotation-btn-compact {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1.3;
}

/* Search Bar */
.quotation-search-container {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
}

.quotation-search-input {
    flex: 1;
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

.quotation-search-btn {
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

/* Fix for badge colors */
.badge.bg-primary { background-color: #0d6efd !important; }
.badge.bg-secondary { background-color: #6c757d !important; }
.badge.bg-info { background-color: #0dcaf0 !important; }
.badge.bg-warning { background-color: #ffc107 !important; color: #000 !important; }
.badge.bg-danger { background-color: #dc3545 !important; }
.badge.bg-success { background-color: #198754 !important; }

/* Ensure text is visible */
.quotation-product-info * {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Additional spacing improvements */
.quotation-product-info > div {
    margin-bottom: 5px;
}

.quotation-product-info > div:last-child {
    margin-bottom: 0;
}
/* INVOICE SPECIFIC STYLES */

/* Product Grid for Invoices */
.invoice-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.invoice-product-card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 220px; /* Increased height for more space */
    background: white;
}

.invoice-product-card:hover:not(.invoice-product-out-of-stock) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #0d6efd;
}

.invoice-product-card.invoice-product-out-of-stock {
    opacity: 0.6;
    cursor: not-allowed;
}

.invoice-product-card.invoice-product-low-stock {
    border-color: #ffc107;
}

/* Product Image */
.invoice-product-image-container {
    width: 100%;
    height: 110px; /* Increased image area */
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #e9ecef;
    position: relative;
}

.invoice-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.invoice-product-image.d-none {
    display: none;
}

.invoice-product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    background: #f8f9fa;
}

.invoice-product-image-placeholder i {
    font-size: 2rem;
}

/* Product Info */
.invoice-product-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.invoice-product-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 6px;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    min-height: 2.2em;
}

.invoice-product-price {
    font-size: 0.95rem;
    font-weight: bold;
    color: #198754;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invoice-product-category {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invoice-product-stock {
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.invoice-product-stock.invoice-product-low-stock {
    color: #fd7e14;
}

.invoice-product-stock.invoice-product-out-of-stock {
    color: #dc3545;
}

/* Type Badges - FIXED POSITION */
.invoice-product-type-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.7rem;
    padding: 3px 7px;
    border-radius: 4px;
    z-index: 2;
}

/* Stock Badge - FIXED POSITION */
.invoice-product-stock-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.7rem;
    padding: 3px 7px;
    border-radius: 4px;
    z-index: 2;
}

/* Add Button */
.invoice-product-add-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0;
    border: none;
    background-color: #198754;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.invoice-product-add-btn:hover {
    background-color: #157347;
}

/* Stock Indicator Dot */
.invoice-stock-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.invoice-stock-indicator.invoice-in-stock {
    background-color: #198754;
}

.invoice-stock-indicator.invoice-low-stock {
    background-color: #ffc107;
}

.invoice-stock-indicator.invoice-out-of-stock {
    background-color: #dc3545;
}

/* Invoice Items List */
.invoice-items-container {
    max-height: 300px;
    overflow-y: auto;
}

.invoice-item {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.3s ease;
}

.invoice-item:hover {
    background-color: #f8f9fa;
}

.invoice-item.highlight {
    background-color: rgba(25, 135, 84, 0.1);
    animation: invoice-highlight-fade 1s ease-out;
}

@keyframes invoice-highlight-fade {
    0% { background-color: rgba(25, 135, 84, 0.3); }
    100% { background-color: rgba(25, 135, 84, 0.1); }
}

.invoice-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #212529;
    margin-bottom: 4px;
}

.invoice-item-details {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.invoice-item-quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.invoice-item-quantity-input {
    width: 60px;
    text-align: center;
    font-size: 0.9rem;
}

.invoice-item-price-input {
    width: 100%;
    font-size: 0.9rem;
}

.invoice-item-discount-input {
    width: 100%;
    font-size: 0.9rem;
}

.invoice-item-total {
    font-weight: 600;
    color: #212529;
    font-size: 0.95rem;
}

/* Invoice Totals */
.invoice-totals {
    border-top: 2px solid #dee2e6;
    padding-top: 12px;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.invoice-total-row.invoice-grand-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: #212529;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #dee2e6;
}

/* Scrollbar Styling */
.invoice-product-grid::-webkit-scrollbar,
.invoice-items-container::-webkit-scrollbar {
    width: 8px;
}

.invoice-product-grid::-webkit-scrollbar-track,
.invoice-items-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.invoice-product-grid::-webkit-scrollbar-thumb,
.invoice-items-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.invoice-product-grid::-webkit-scrollbar-thumb:hover,
.invoice-items-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Grid */
@media (min-width: 1200px) {
    .invoice-product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .invoice-product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    .invoice-product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575px) {
    .invoice-product-grid {
        grid-template-columns: 1fr;
    }
    
    .invoice-product-card {
        height: auto;
        flex-direction: row;
    }
    
    .invoice-product-image-container {
        width: 110px;
        height: 110px;
        border-bottom: none;
        border-right: 1px solid #e9ecef;
    }
    
    .invoice-product-info {
        flex: 1;
        padding: 12px;
    }
}

/* Empty State */
.invoice-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.invoice-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.invoice-empty-state p {
    margin: 0;
    font-size: 1rem;
}

/* Loading State */
.invoice-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #6c757d;
}

.invoice-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Compact Button */
.invoice-btn-compact {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1.3;
}

/* Search Bar */
.invoice-search-container {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
}

.invoice-search-input {
    flex: 1;
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

.invoice-search-btn {
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

/* Fix for badge colors */
.badge.bg-primary { background-color: #0d6efd !important; }
.badge.bg-secondary { background-color: #6c757d !important; }
.badge.bg-info { background-color: #0dcaf0 !important; }
.badge.bg-warning { background-color: #ffc107 !important; color: #000 !important; }
.badge.bg-danger { background-color: #dc3545 !important; }
.badge.bg-success { background-color: #198754 !important; }

/* Ensure text is visible */
.invoice-product-info * {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Additional spacing improvements */
.invoice-product-info > div {
    margin-bottom: 5px;
}

.invoice-product-info > div:last-child {
    margin-bottom: 0;
}
/* ============================================
   PURCHASE ORDER GRID VIEW SPECIFIC STYLES
   ============================================ */

/* Product Grid for Purchase Orders - reusing invoice styles */
#poProductGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

/* Purchase Order Items List */
#poItemsList .invoice-item {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.3s ease;
}

#poItemsList .invoice-item:hover {
    background-color: #f8f9fa;
}

#poItemsList .invoice-item.highlight {
    background-color: rgba(13, 110, 253, 0.1);
    animation: invoice-highlight-fade 1s ease-out;
}

/* Search Container for PO - matches invoice style */
.po-search-container {
    display: flex;
    gap: 6px;
    margin-bottom: 0;
}

.po-search-input {
    flex: 1;
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

.po-search-btn {
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

/* Ensure PO-specific overrides */
#poModal .invoice-product-card {
    cursor: pointer;
}

#poModal .invoice-product-add-btn {
    background-color: #0d6efd; /* Blue for PO instead of green */
}

#poModal .invoice-product-add-btn:hover {
    background-color: #0b5ed7;
}
/* Purchase Order Grid */
.po-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

/* Items Container */
.po-items-container {
    min-height: 350px;
    max-height: 350px;
    overflow-y: auto;
    background: #f8f9fa;
}

/* Items List */
.po-items-list {
    padding: 15px;
}

/* Individual Item */
.po-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.po-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.po-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #212529;
}

.po-item-details {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 3px;
}

/* Quantity Controls */
.po-quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.po-quantity-input {
    width: 60px;
    text-align: center;
    font-size: 0.9rem;
}

/* Price Input */
.po-price-input {
    width: 100%;
    text-align: right;
    font-size: 0.9rem;
}

/* Empty State */
.po-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.po-empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.3;
}

/* Search Container */
.po-search-container {
    display: flex;
    gap: 8px;
}
/* ============================================
   ELECTRON-SPECIFIC FIXES (CRITICAL)
   ============================================ */

/* Force ALL inputs to be interactive in Electron */
input, textarea, select {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-user-modify: read-write !important;
    pointer-events: auto !important;
}

/* Prevent Bootstrap from blocking modal inputs */
.modal {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* Fix for modal backdrop stacking issues */
.modal-backdrop {
    opacity: 0.5 !important;
}

.modal-backdrop.show {
    opacity: 0.5 !important;
}

/* Ensure modals don't block clicks */
.modal-content {
    pointer-events: auto !important;
}

/* Fix for dropdown menus in modals */
.modal .dropdown-menu {
    z-index: 1060 !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* Special fixes for number/date inputs in Electron */
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    min-height: 38px !important;
}

/* Fix for disabled states that shouldn't be disabled */
input:not([disabled]):not(.disabled),
textarea:not([disabled]):not(.disabled),
select:not([disabled]):not(.disabled) {
    background-color: var(--input-bg, #fff) !important;
    border-color: var(--input-border, #ced4da) !important;
    color: var(--text-primary, #212529) !important;
    cursor: text !important;
}

/* Remove focus rings that might block input */
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25) !important;
    z-index: 1;
}

/* Fix for tab navigation in Electron */
[tabindex="-1"]:not([data-bs-toggle="dropdown"]) {
    tab-index: 0 !important;
}

/* Emergency input fix visual indicator */
input.fixed-by-electron,
textarea.fixed-by-electron,
select.fixed-by-electron {
    border-left: 3px solid #28a745 !important;
}

/* Loading indicator for modal fixes */
.modal-fixing {
    position: relative;
}

.modal-fixing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #007bff;
    font-weight: bold;
}

/* ============================================
   ENHANCED MODAL STYLES
   ============================================ */

/* Better modal animations for Electron */
.modal.fade .modal-dialog {
    transition: transform 0.15s ease-out;
}

/* Prevent modal content from being too tall */
.modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Fix for form validation states */
.form-control.is-invalid {
    background-image: none !important;
    padding-right: 0.75rem !important;
}

/* Better input group styling */
.input-group .form-control:focus {
    z-index: 3;
}

/* Fix for select dropdowns in Electron */
select.form-select {
    background-image: none !important;
    padding-right: 2.25rem !important;
}

/* Ensure buttons in modals are clickable */
.modal .btn {
    pointer-events: auto !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* ============================================
   RESPONSIVE FIXES FOR ELECTRON
   ============================================ */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 0.5rem !important;
    }
    
    /* Ensure mobile inputs are touch-friendly */
    input, textarea, select {
        min-height: 44px !important; /* Apple's recommended minimum touch target */
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
}
/* ===== FIX PRINT RECEIPT ===== */
@media print {
  /* Force the entire modal and its contents to be visible */
  #receiptModal,
  #receiptModal .modal-dialog,
  #receiptModal .modal-content,
  #receiptModal .modal-body,
  #receiptModal .receipt,
  #receiptModal .receipt * {
    visibility: visible !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    opacity: 1 !important;
    color: #000000 !important;
    background-color: #ffffff !important;
  }

  /* Hide the modal backdrop */
  .modal-backdrop {
    display: none !important;
  }

  /* Position the modal dialog at the top-left of the printed page */
  #receiptModal .modal-dialog {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
    transform: none !important;
  }

  /* Remove borders/shadows */
  .modal-content {
    border: none !important;
    box-shadow: none !important;
  }

  /* Hide modal header/footer (buttons) */
  .modal-header,
  .modal-footer {
    display: none !important;
  }

  /* Ensure images (logo, QR code) are printed */
  #receiptModal img {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid; /* prevent image from being split across pages */
  }
}

.mpesa-stat-card {
    border: 1px solid rgba(25, 135, 84, 0.15);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

#mpesaTransactionsTable code {
    white-space: normal;
    word-break: break-all;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* PREMIUM BUSINESS PROFILE STYLES (v3)                                      */
/* Distinct visual identity - completely separate from branch workspace.     */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* -- Business Profile KPI Cards -- */
.bp-kpi-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  height: 100%;
}
.bp-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}
.bp-kpi-card .bp-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.bp-kpi-card.primary .bp-kpi-icon { background: #dbeafe; color: #2563eb; }
.bp-kpi-card.success .bp-kpi-icon { background: #d1fae5; color: #10b981; }
.bp-kpi-card.warning .bp-kpi-icon { background: #fef3c7; color: #f59e0b; }
.bp-kpi-card.info .bp-kpi-icon { background: #cffafe; color: #06b6d4; }
.bp-kpi-card.danger .bp-kpi-icon { background: #fee2e2; color: #ef4444; }
.bp-kpi-card .bp-kpi-body { flex: 1; min-width: 0; }
.bp-kpi-card .bp-kpi-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.25rem;
  font-weight: 600;
}
.bp-kpi-card .bp-kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}
.bp-kpi-card .bp-kpi-sub {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

/* -- Branch Comparison Cards -- */
.bp-branch-card {
  border-radius: 0.75rem;
  border-left: 4px solid #e2e8f0;
  transition: transform 0.15s ease;
}
.bp-branch-card:hover { transform: translateY(-1px); }
.bp-branch-card.bp-best { border-left-color: #f59e0b; background: #fffdf5; }
.bp-branch-card.bp-worst { border-left-color: #ef4444; background: #fff5f5; }

/* -- Stat Cards -- */
.bp-stat-card {
  border-radius: 0.75rem;
  transition: transform 0.15s ease;
}
.bp-stat-card:hover { transform: translateY(-2px); }

/* -- Section Header -- */
.bp-section-header {
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e2e8f0;
}

/* -- Branch Admin Cards -- */
.bp-branch-admin-card {
  border-radius: 1rem;
  border-left: 4px solid #2563eb;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bp-branch-admin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

/* -- Product Cards (Master Catalogue) -- */
.bp-product-card {
  border-radius: 0.75rem;
  transition: transform 0.15s ease;
}
.bp-product-card:hover { transform: translateY(-1px); }

/* -- Customer Cards -- */
.bp-customer-card {
  border-radius: 0.75rem;
  border-left: 4px solid #8b5cf6;
  transition: transform 0.15s ease;
}
.bp-customer-card:hover { transform: translateY(-1px); }

/* -- Financial Cards -- */
.bp-fin-card {
  border-radius: 0.75rem;
  transition: transform 0.15s ease;
}
.bp-fin-card:hover { transform: translateY(-2px); }


