:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --primary-gradient-hover: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --danger-color: #f43f5e;
    --danger-hover: #e11d48;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 8px -1px rgba(15, 23, 42, 0.02);
    --shadow-lg: 0 10px 30px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
    --shadow-xl: 0 20px 50px -12px rgba(15, 23, 42, 0.25);
    --radius-md: 10px;
    --radius-lg: 16px;
    --sidebar-width: 280px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    letter-spacing: -0.01em;
}

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

/* Custom Typography & Utility classes */
h1, h2, h3, h4, h5 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.btn-primary:hover {
    background: var(--primary-gradient-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.15);
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.25);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25);
}

.btn-light {
    background-color: #e2e8f0;
    color: var(--text-primary);
}
.btn-light:hover {
    background-color: #cbd5e1;
    transform: translateY(-1px);
}

/* Form Styling */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    background-color: var(--surface-color);
    color: var(--text-primary);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control::placeholder {
    color: #94a3b8;
}

/* Auth Page Layout */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgb(90, 92, 234) 0%, rgb(32, 45, 107) 100%);
    padding: 1.5rem;
}

.auth-card {
    background: var(--surface-color);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-size: 1.85rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

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

.sidebar {
    width: var(--sidebar-width);
    background-color: #0b0f19;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(11, 15, 25, 0.2);
}

.sidebar-header {
    padding: 1.5rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header img {
    height: 48px;
    width: 48px;
    object-fit: contain;
    border-radius: 50%;
    padding: 3px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(109, 93, 252, 0.4);
    box-shadow: 0 0 12px rgba(109, 93, 252, 0.3), inset 0 0 8px rgba(109, 93, 252, 0.1);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    animation: logoPulseGlow 3s infinite ease-in-out;
}

.sidebar-header img:hover {
    transform: scale(1.08) rotate(5deg);
    border-color: #06b6d4;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.6), inset 0 0 10px rgba(6, 182, 212, 0.2);
}

@keyframes logoPulseGlow {
    0% {
        box-shadow: 0 0 10px rgba(109, 93, 252, 0.3), inset 0 0 6px rgba(109, 93, 252, 0.1);
        border-color: rgba(109, 93, 252, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(109, 93, 252, 0.6), 0 0 30px rgba(6, 182, 212, 0.3), inset 0 0 10px rgba(109, 93, 252, 0.2);
        border-color: rgba(6, 182, 212, 0.6);
    }
    100% {
        box-shadow: 0 0 10px rgba(109, 93, 252, 0.3), inset 0 0 6px rgba(109, 93, 252, 0.1);
        border-color: rgba(109, 93, 252, 0.4);
    }
}

.sidebar-nav {
    padding: 1.5rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 8px;
    margin: 4px 14px;
    padding: 0.75rem 1.15rem;
    color: #94a3b8;
    text-decoration: none;
    gap: 0.85rem;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary-gradient) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    border-left: 4px solid #06b6d4 !important;
    font-weight: 700;
}

.nav-item.active i {
    color: white !important;
}

/* Main Content area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents layout breakdown inside flex */
}

/* Topbar */
.topbar {
    height: 70px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.user-profile, .user-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    cursor: pointer;
    position: relative;
    user-select: none;
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    transition: var(--transition);
}

.user-profile:hover, .user-info:hover {
    background-color: rgba(15, 23, 42, 0.04);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 
        0 0 0 2px rgba(79, 70, 229, 0.2), 
        0 4px 12px rgba(79, 70, 229, 0.25);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-profile:hover .user-avatar,
.user-info:hover .user-avatar,
.user-avatar:hover {
    transform: scale(1.08) rotate(5deg);
    border-color: #ffffff;
    box-shadow: 
        0 0 0 4px rgba(79, 70, 229, 0.35), 
        0 8px 20px rgba(79, 70, 229, 0.4);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content Container */
.content-wrapper {
    padding: 2rem;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* Cards & Layout */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.75rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-primary);
}

/* Dashboard Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
    cursor: default;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.metric-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

/* Color schemes for metric icon backgrounds */
.metric-blue {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}
.metric-green {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}
.metric-indigo {
    background-color: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
}
.metric-purple {
    background-color: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}
.metric-rose {
    background-color: rgba(244, 63, 94, 0.1);
    color: #f43f5e;
}
.metric-orange {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.metric-details {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

/* Tables styling */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface-color);
}

th, td {
    padding: 0.85rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8fafc;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background-color: #f8fafc;
}

tr.removing {
    animation: fadeOut 0.3s ease-out forwards;
}

tr.low-stock {
    background-color: rgba(244, 63, 94, 0.03);
}

tr.low-stock td {
    color: #e11d48;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.35rem;
}

.badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #047857;
}
.badge-success::before { background-color: #10b981; }

.badge-danger {
    background-color: rgba(244, 63, 94, 0.1);
    color: #be123c;
}
.badge-danger::before { background-color: #f43f5e; }

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #b45309;
}
.badge-warning::before { background-color: #f59e0b; }

.badge-info {
    background-color: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}
.badge-info::before { background-color: #3b82f6; }

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(15, 23, 42, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal.show {
    display: flex;
    animation: modalBackdropFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 2.25rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 550px;
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    transform: scale(0.92) translateY(24px);
    opacity: 0;
    animation: modalContentZoomIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalBackdropFadeIn {
    from {
        background-color: rgba(15, 23, 42, 0);
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        background-color: rgba(15, 23, 42, 0.35);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

@keyframes modalContentZoomIn {
    from {
        transform: scale(0.92) translateY(24px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background-color: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

/* User profile Dropdown in Topbar */
.user-info {
    position: relative;
}

.topbar-dropdown {
    display: block;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 245px;
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.topbar-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.topbar-dropdown-header {
    padding: 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.topbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.topbar-dropdown-item:hover {
    background-color: #f8fafc;
    color: var(--primary-color);
}

.topbar-dropdown-danger {
    color: var(--danger-color) !important;
}

.topbar-dropdown-danger:hover {
    background-color: rgba(244, 63, 94, 0.08) !important;
    color: var(--danger-color) !important;
}

.topbar-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Responsive Grid / Column layouts */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.dashboard-grid-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-grid, .dashboard-grid-equal {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.show-mobile {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .topbar {
        padding: 0 1.25rem;
    }
    .content-wrapper {
        padding: 1.25rem;
    }
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Empty states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Sidebar footer - Ẩn (đã chuyển lên topbar dropdown) */
.sidebar-footer {
    display: none !important;
}

/* Dark Mode Toggle Switch */
.dark-mode-toggle-wrap {
    padding: 0.5rem 1.25rem;
    margin: 4px 0;
}

.dark-mode-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark-mode-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 10px;
}

body.dark-mode .dark-mode-label {
    color: #f8fafc;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s ease;
    border-radius: 34px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s ease;
    border-radius: 50%;
}

input:checked + .theme-slider {
    background-color: var(--primary-color);
}

input:checked + .theme-slider:before {
    transform: translateX(20px);
}

/* Dark mode overrides for other elements */
/* ==========================================================================
   Dark Mode Premium Color System Override
   ========================================================================== */
body.dark-mode {
    /* 1. Global Tokens */
    --background-color: #0B1120;
    --surface-color: #111C2E;
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --border-color: rgba(148, 163, 184, 0.18);
    
    --primary-color: #6D5DFC;
    --primary-hover: #7C6DFF;
    --primary-gradient: linear-gradient(135deg, #6D5DFC 0%, #8B5CF6 100%);
    --primary-gradient-hover: linear-gradient(135deg, #7C6DFF 0%, #9D7CFF 100%);
    
    --secondary-color: #10B981;
    --secondary-hover: #059669;
    
    --danger-color: #EF4444;
    --danger-hover: #F87171;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.4), 0 2px 8px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 30px -4px rgba(0, 0, 0, 0.45), 0 4px 12px -2px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.6);

    /* POS variables */
    --pos-bg: #0B1120;
    --pos-surface: #111C2E;
    --pos-border: rgba(148, 163, 184, 0.18);
    
    background-color: var(--background-color) !important;
    color: var(--text-primary) !important;
}

/* 2. Sidebar Dark Mode */
body.dark-mode .sidebar {
    background: linear-gradient(180deg, #020617, #0F172A) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.1) !important;
}

body.dark-mode .sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .nav-item {
    color: #CBD5E1 !important;
}

body.dark-mode .nav-item i {
    color: #94A3B8 !important;
}

body.dark-mode .nav-item:hover {
    background-color: rgba(109, 93, 252, 0.16) !important;
    color: #FFFFFF !important;
}

body.dark-mode .nav-item:hover i {
    color: #FFFFFF !important;
}

body.dark-mode .nav-item.active {
    background: linear-gradient(135deg, #6D5DFC, #8B5CF6) !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 14px rgba(109, 93, 252, 0.4) !important;
}

body.dark-mode .nav-item.active i {
    color: #FFFFFF !important;
}

/* 3. Header / Topbar Dark Mode */
body.dark-mode .topbar {
    background: rgba(15, 23, 42, 0.92) !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .topbar .page-title {
    color: #F8FAFC !important;
}

body.dark-mode .topbar .page-subtitle {
    color: #94A3B8 !important;
}

body.dark-mode .user-info {
    color: #F8FAFC !important;
}

body.dark-mode .user-info:hover, body.dark-mode .user-profile:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

body.dark-mode .user-avatar {
    box-shadow: 0 0 0 2px rgba(109, 93, 252, 0.55);
}

body.dark-mode .user-role {
    color: #94A3B8 !important;
}

/* 4. Statistics / Metric Cards Dark Mode */
body.dark-mode .metric-card {
    background: linear-gradient(145deg, #111827, #1E293B) !important;
    border: 1px solid rgba(148, 163, 184, 0.14) !important;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35) !important;
}

body.dark-mode .metric-label {
    color: #94A3B8 !important;
}

body.dark-mode .metric-value {
    color: #F8FAFC !important;
}

body.dark-mode .metric-blue {
    background-color: rgba(109, 93, 252, 0.15) !important;
    color: #6D5DFC !important;
}

body.dark-mode .metric-green {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #10B981 !important;
}

body.dark-mode .metric-orange {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #F59E0B !important;
}

body.dark-mode .metric-red {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #EF4444 !important;
}

/* 5. Buttons Dark Mode */
body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #6D5DFC, #8B5CF6) !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 12px rgba(109, 93, 252, 0.25) !important;
}

body.dark-mode .btn-primary:hover {
    background: linear-gradient(135deg, #7C6DFF, #9D7CFF) !important;
    box-shadow: 0 6px 18px rgba(109, 93, 252, 0.4) !important;
}

body.dark-mode .btn-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #CBD5E1 !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
}

body.dark-mode .btn-light:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #FFFFFF !important;
}

body.dark-mode .btn-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #FCA5A5 !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    box-shadow: none !important;
}

body.dark-mode .btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.25) !important;
    color: #FFFFFF !important;
}

body.dark-mode .btn-secondary {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #6EE7B7 !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
    box-shadow: none !important;
}

body.dark-mode .btn-secondary:hover {
    background-color: rgba(16, 185, 129, 0.25) !important;
    color: #FFFFFF !important;
}

/* 6. Form Controls Dark Mode */
body.dark-mode .form-label {
    color: #CBD5E1 !important;
}

body.dark-mode .form-control {
    background-color: #0F172A !important;
    color: #F8FAFC !important;
    border: 1px solid rgba(148, 163, 184, 0.28) !important;
}

body.dark-mode .form-control::placeholder {
    color: #64748B !important;
}

body.dark-mode .form-control:focus {
    border-color: #6D5DFC !important;
    box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.18) !important;
}

/* 7. Tables Dark Mode */
body.dark-mode .table-responsive {
    border-color: rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode table {
    background-color: #111827 !important;
}

body.dark-mode th {
    background-color: #1E293B !important;
    color: #CBD5E1 !important;
    border-bottom: 2px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode td {
    color: #E2E8F0 !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12) !important;
}

body.dark-mode tbody tr:hover {
    background-color: rgba(109, 93, 252, 0.10) !important;
}

/* 8. Status Badges Dark Mode */
body.dark-mode .badge-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #6EE7B7 !important;
}

body.dark-mode .badge-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #FCA5A5 !important;
}

body.dark-mode .badge-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #FDE047 !important;
}

body.dark-mode .badge-info {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: #93C5FD !important;
}

body.dark-mode .badge[style*="background-color:#E5E7EB"],
body.dark-mode .badge[style*="background-color: rgb(229, 231, 235)"],
body.dark-mode .badge[style*="background-color:rgb(229, 231, 235)"] {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #CBD5E1 !important;
}

/* 9. Modals Dark Mode */
body.dark-mode .modal-content {
    background-color: #111827 !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .modal.show {
    animation: modalBackdropFadeInDark 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes modalBackdropFadeInDark {
    from {
        background-color: rgba(2, 6, 23, 0);
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        background-color: rgba(2, 6, 23, 0.75);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* 10. Dashboard & General Card Dark Mode overrides */
body.dark-mode .card {
    background: #111C2E !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    box-shadow: var(--shadow-md) !important;
}

body.dark-mode .card:hover {
    box-shadow: var(--shadow-lg) !important;
}

body.dark-mode .card-header {
    border-bottom: 1px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .card-title {
    color: #F8FAFC !important;
}

body.dark-mode .empty-state {
    color: #94A3B8 !important;
}

body.dark-mode .empty-state i {
    color: #4b5563 !important;
}

/* 11. POS Specific Dark Mode Overrides */
body.dark-mode .pos-search-group {
    background: #0F172A !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
}

body.dark-mode .pos-search-group i {
    color: #64748B !important;
}

body.dark-mode .pos-search-input {
    background: transparent !important;
    color: #F8FAFC !important;
}

body.dark-mode .empty-cart-state {
    color: #CBD5E1 !important;
}

body.dark-mode .empty-cart-state i {
    color: rgba(255, 255, 255, 0.08) !important;
}

body.dark-mode .category-pill {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #CBD5E1 !important;
    border-color: rgba(148, 163, 184, 0.12) !important;
}

body.dark-mode .category-pill:hover {
    background-color: rgba(255, 255, 255, 0.10) !important;
    color: #FFFFFF !important;
}

body.dark-mode .category-pill.active {
    background: linear-gradient(135deg, #6D5DFC, #8B5CF6) !important;
    color: #FFFFFF !important;
    border-color: transparent !important;
}

body.dark-mode .product-card {
    background: #111C2E !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .product-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(109, 93, 252, 0.4) !important;
}

body.dark-mode .product-title {
    color: #F8FAFC !important;
}

body.dark-mode .product-price {
    color: #06B6D4 !important;
}

body.dark-mode .product-stock {
    color: #CBD5E1 !important;
}

body.dark-mode .cart-item-title {
    color: #F8FAFC !important;
}

body.dark-mode .cart-item-price {
    color: #06B6D4 !important;
}

body.dark-mode .billing-box {
    background-color: #111C2E !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .billing-title {
    color: #F8FAFC !important;
    border-bottom-color: rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .receipt-summary {
    background-color: #0F172A !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .receipt-row {
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
}

body.dark-mode .receipt-row span {
    color: #CBD5E1 !important;
}

body.dark-mode .receipt-row strong {
    color: #F8FAFC !important;
}

body.dark-mode .receipt-total {
    color: #6D5DFC !important;
}

body.dark-mode .receipt-change {
    color: #10B981 !important;
}

body.dark-mode .search-results {
    background-color: #111C2E !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .search-item {
    border-bottom: 1px solid rgba(148, 163, 184, 0.12) !important;
    color: #CBD5E1 !important;
}

body.dark-mode .search-item:hover {
    background-color: rgba(109, 93, 252, 0.1) !important;
    color: #FFFFFF !important;
}

body.dark-mode .search-item .product-code {
    color: #94A3B8 !important;
}

body.dark-mode .customer-results {
    background-color: #111C2E !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .customer-item {
    border-bottom: 1px solid rgba(148, 163, 184, 0.12) !important;
    color: #CBD5E1 !important;
}

body.dark-mode .customer-item:hover {
    background-color: rgba(109, 93, 252, 0.1) !important;
    color: #FFFFFF !important;
}

body.dark-mode .qty-btn {
    background-color: #0F172A !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
    color: #CBD5E1 !important;
}

body.dark-mode .qty-btn:hover {
    background-color: rgba(109, 93, 252, 0.16) !important;
    color: #FFFFFF !important;
    border-color: #6D5DFC !important;
}

body.dark-mode .customer-selected-badge {
    background-color: #0F172A !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
    color: #6D5DFC !important;
}

body.dark-mode .table-responsive th {
    background-color: #1E293B !important;
    color: #CBD5E1 !important;
    border-bottom: 2px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .table-responsive tbody tr:hover {
    background-color: rgba(109, 93, 252, 0.08) !important;
}

/* 12. Profile / Avatar Selection Dark Mode */
body.dark-mode .avatar-option {
    border-color: rgba(148, 163, 184, 0.18) !important;
    background-color: #0F172A !important;
}

body.dark-mode .avatar-option:hover {
    border-color: #6D5DFC !important;
}

body.dark-mode .avatar-option.selected {
    border-color: transparent !important;
    box-shadow: 0 0 0 3px #6D5DFC !important;
}

body.dark-mode .profile-card {
    background: #111C2E !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
}

/* 13. Topbar Avatar Dropdown Dark Mode overrides */
body.dark-mode .topbar-dropdown {
    background-color: #111C2E !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .topbar-dropdown-header {
    background-color: #0F172A !important;
    border-bottom-color: rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .topbar-dropdown-item {
    color: #CBD5E1 !important;
}

body.dark-mode .topbar-dropdown-item:hover {
    background-color: rgba(109, 93, 252, 0.16) !important;
    color: #FFFFFF !important;
}

body.dark-mode .topbar-dropdown-divider {
    background-color: rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode .close-btn {
    color: var(--text-secondary) !important;
}

body.dark-mode .close-btn:hover {
    color: var(--text-primary) !important;
}

/* Icon-only action buttons (edit / delete / save / cancel in compact lists) */
.icon-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.icon-action-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.icon-action-edit {
    color: var(--primary-color);
}
.icon-action-edit:hover {
    background-color: rgba(79, 70, 229, 0.1);
}

.icon-action-delete {
    color: var(--danger-color);
}
.icon-action-delete:hover {
    background-color: rgba(244, 63, 94, 0.1);
}

.icon-action-save {
    color: var(--secondary-color);
}
.icon-action-save:hover {
    background-color: rgba(16, 185, 129, 0.12);
}
.icon-action-save:disabled {
    opacity: 0.6;
    cursor: default;
}

.icon-action-cancel {
    color: var(--text-secondary);
}
.icon-action-cancel:hover {
    background-color: rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
}

body.dark-mode .icon-action-edit:hover {
    background-color: rgba(109, 93, 252, 0.18) !important;
}
body.dark-mode .icon-action-delete:hover {
    background-color: rgba(239, 68, 68, 0.18) !important;
}
body.dark-mode .icon-action-save:hover {
    background-color: rgba(16, 185, 129, 0.18) !important;
}
body.dark-mode .icon-action-cancel:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #F8FAFC !important;
}

/* Custom Filter & Search styles */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 280px;
}

/* Beautiful Unified Search Group */
.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    width: 320px;
    max-width: 100%;
}

.search-input-group .form-control {
    padding-right: 42px;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.search-input-group .btn-search {
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.9rem;
}

.search-input-group .btn-search:hover {
    background: #4338ca;
    transform: scale(1.04);
}

.search-input-group .btn-search:active {
    transform: scale(0.96);
}

.search-input-group .form-control:focus + .btn-search {
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* ==========================================================================
   Additional Premium Dark Mode & Component Readability Overrides
   ========================================================================== */
body.dark-mode {
    /* Global navigation active border & layout variables */
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
}

/* Force dark mode navigation elements to follow unified spacing & active state with cyan border */
body.dark-mode .nav-item {
    color: #CBD5E1 !important;
}

body.dark-mode .nav-item i {
    color: #94A3B8 !important;
}

body.dark-mode .nav-item:hover:not(.active) {
    background-color: rgba(109, 93, 252, 0.16) !important;
    color: #FFFFFF !important;
    transform: translateX(4px);
}

body.dark-mode .nav-item:hover:not(.active) i {
    color: #FFFFFF !important;
}

body.dark-mode .nav-item.active {
    background: var(--primary-gradient) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3) !important;
    border-left: 4px solid #06b6d4 !important;
    font-weight: 700;
}

body.dark-mode .nav-item.active i {
    color: white !important;
}

/* Settings page containers */
body.dark-mode .logo-preview-container {
    background: #0F172A !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
}

body.dark-mode .logo-preview-img {
    background: #1E293B !important;
    border: 1px solid rgba(148, 163, 184, 0.12) !important;
}

body.dark-mode .backup-restore-zone {
    background: #0F172A !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
}

/* Invoices summary metrics cards */
body.dark-mode .summary-card {
    background: #111C2E !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    box-shadow: var(--shadow-md) !important;
}

body.dark-mode .summary-card .label {
    color: #94A3B8 !important;
}

body.dark-mode .summary-card .value {
    color: #F8FAFC !important;
}

/* High contrast inputs and select controls */
body.dark-mode select, 
body.dark-mode .form-control {
    background-color: #0F172A !important;
    color: #F8FAFC !important;
    border: 1px solid rgba(148, 163, 184, 0.28) !important;
}

body.dark-mode select option {
    background-color: #111C2E !important;
    color: #F8FAFC !important;
}

/* Product cards internal items */
body.dark-mode .product-card-img {
    background-color: #0F172A !important;
    border-color: rgba(148, 163, 184, 0.12) !important;
}

body.dark-mode .product-card-img-placeholder {
    background-color: rgba(109, 93, 252, 0.15) !important;
    color: #a5b4fc !important;
}

/* Filters & History search block */
body.dark-mode .filters-history {
    background-color: #111C2E !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
}

/* High-readability table header globally in dark mode */
body.dark-mode th,
body.dark-mode .table-responsive th {
    background-color: #1E293B !important;
    color: #F1F5F9 !important; /* brighter white-gray for maximum readability */
    border-bottom: 2px solid rgba(148, 163, 184, 0.25) !important;
}

body.dark-mode td,
body.dark-mode .table-responsive td {
    color: #E2E8F0 !important;
}

/* High-readability empty cart states */
body.dark-mode .empty-cart-state i {
    color: rgba(255, 255, 255, 0.08) !important;
}

body.dark-mode .empty-cart-state p {
    color: #CBD5E1 !important;
}

/* Form labels high contrast */
body.dark-mode .form-label {
    color: #CBD5E1 !important;
}

/* Filter select with active value */
body.dark-mode .filter-select-wrap select.has-value {
    background-color: rgba(109, 93, 252, 0.2) !important;
    color: #a5b4fc !important;
    border-color: #6D5DFC !important;
}
