/* Theme Variables */
:root {
    /* Light Theme (Default) - Smoky Gray */
    --bg-primary: #e8e8e8;
    --bg-secondary: #d4d4d4;
    --bg-tertiary: #c0c0c0;
    --text-primary: #1a1a1a;
    --text-secondary: #3a3a3a;
    --text-muted: #666666;
    --border-color: #b8b8b8;
    --shadow: rgba(0, 0, 0, 0.15);
    --accent-primary: #3182ce;
    --accent-secondary: #4299e1;
    --success: #38a169;
    --warning: #d69e2e;
    --danger: #e53e3e;
    --info: #3182ce;
}

/* Light theme specific components */
[data-theme="light"] .navbar,
[data-theme="light"] .dashboard-header {
    background: rgba(212, 212, 212, 0.95) !important;
    backdrop-filter: blur(10px);
}

[data-theme="light"] .modern-footer {
    background: rgba(212, 212, 212, 0.8) !important;
}

[data-theme="light"] .dashboard-card,
[data-theme="light"] .card {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .card-body {
    background: transparent !important;
}

/* Light theme card text visibility */
[data-theme="light"] .card-title,
[data-theme="light"] .dashboard-card .card-title,
[data-theme="light"] .dashboard-card:hover .card-title {
    color: var(--text-primary) !important;
    font-weight: 600;
}

[data-theme="light"] .card-text,
[data-theme="light"] .dashboard-card .card-text,
[data-theme="light"] .card-description,
[data-theme="light"] .dashboard-card .card-description {
    color: var(--text-secondary) !important;
}

/* Ensure hover effect works for light theme */
[data-theme="light"] .dashboard-card:hover .card-title {
    color: var(--accent-primary) !important;
}

/* Light theme language dropdown */
[data-theme="light"] .modern-select {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .modern-select:hover {
    background: rgba(255, 255, 255, 1) !important;
    border-color: var(--accent-primary) !important;
}

/* Light theme forms and inputs */
[data-theme="light"] .form-control,
[data-theme="light"] .form-control-custom,
[data-theme="light"] .form-select {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-control-custom:focus,
[data-theme="light"] .form-select:focus {
    background: rgba(255, 255, 255, 1) !important;
    border-color: var(--accent-primary) !important;
}

[data-theme="light"] .form-label,
[data-theme="light"] .form-label-custom {
    color: var(--text-primary) !important;
}

/* Light theme tables */
[data-theme="light"] .table-container {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .table {
    background: transparent !important;
}

[data-theme="light"] .table thead th {
    background: rgba(200, 200, 200, 0.8) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .table tbody td {
    background: transparent !important;
    color: var(--text-primary) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .table tbody tr:hover td {
    background: rgba(240, 240, 240, 0.5) !important;
}

/* Light theme search bars and containers */
[data-theme="light"] .search-container,
[data-theme="light"] .modern-search-container {
    background: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .search-container:hover {
    border-color: rgba(0, 0, 0, 0.2) !important;
}

[data-theme="light"] .search-input,
[data-theme="light"] input[type="search"] {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

[data-theme="light"] .search-input::placeholder {
    color: var(--text-muted) !important;
}

/* Light theme modal/form containers */
[data-theme="light"] .modal-content,
[data-theme="light"] .auth-card {
    background: rgba(255, 255, 255, 1) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .modal-header {
    background: rgba(240, 240, 240, 1) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .modal-body {
    background: rgba(255, 255, 255, 1) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .modal-title {
    color: var(--text-primary) !important;
}

/* Light theme modal labels and text */
[data-theme="light"] .modal label,
[data-theme="light"] .modal-body label {
    color: var(--text-primary) !important;
}

[data-theme="light"] .modal .form-check-label,
[data-theme="light"] .modal-body .form-check-label {
    color: var(--text-primary) !important;
}

/* Light theme helper text */
[data-theme="light"] .form-text,
[data-theme="light"] .help-text,
[data-theme="light"] small {
    color: var(--text-muted) !important;
}

/* Light theme success alert */
[data-theme="light"] .modern-alert-success {
    background: linear-gradient(135deg, rgba(209, 250, 229, 0.9) 0%, rgba(167, 243, 208, 0.8) 100%) !important;
    border: 1px solid rgba(56, 161, 105, 0.4) !important;
    color: #2f855a !important;
}

[data-theme="light"] .modern-alert-success .modern-alert-icon {
    background: rgba(56, 161, 105, 0.2) !important;
    color: #2f855a !important;
}

[data-theme="light"] .modern-alert-success .modern-alert-icon svg {
    stroke: #2f855a !important;
}

[data-theme="light"] .modern-alert-success .modern-alert-close {
    color: #2f855a !important;
}

[data-theme="light"] .modern-alert-success .modern-alert-close svg {
    stroke: #2f855a !important;
}

[data-theme="light"] .modern-alert-success .modern-alert-message {
    color: #2f855a !important;
}

/* Override any Bootstrap alert-danger styles that might be applied */
[data-theme="light"] .alert.modern-alert-success {
    background: linear-gradient(135deg, rgba(209, 250, 229, 0.9) 0%, rgba(167, 243, 208, 0.8) 100%) !important;
    border-color: rgba(56, 161, 105, 0.4) !important;
    color: #2f855a !important;
}

/* Light theme form-specific classes */
[data-theme="light"] .form-container {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-control-custom,
[data-theme="light"] textarea.form-input {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-control-custom:focus,
[data-theme="light"] textarea.form-input:focus {
    background: rgba(255, 255, 255, 1) !important;
    border-color: var(--accent-primary) !important;
}

[data-theme="light"] .form-input::placeholder,
[data-theme="light"] textarea.form-input::placeholder {
    color: var(--text-muted) !important;
}

[data-theme="light"] .form-label {
    color: var(--text-primary) !important;
}

[data-theme="light"] .input-icon {
    color: var(--text-muted) !important;
}

[data-theme="light"] .input-wrapper:focus-within .input-icon {
    color: var(--accent-primary) !important;
}

[data-theme="light"] .form-hint {
    color: var(--text-muted) !important;
}

[data-theme="light"] .page-title {
    color: var(--text-primary) !important;
}

[data-theme="light"] .page-subtitle {
    color: var(--text-secondary) !important;
}

/* Light theme dropdown menus */
[data-theme="light"] select,
[data-theme="light"] .form-select,
[data-theme="light"] select.form-input {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

[data-theme="light"] select option,
[data-theme="light"] .form-select option {
    background: white !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] select:focus,
[data-theme="light"] .form-select:focus {
    background: rgba(255, 255, 255, 1) !important;
    border-color: var(--accent-primary) !important;
}

/* Light theme datepicker/calendar */
[data-theme="light"] input[readonly].flatpickr-input,
[data-theme="light"] input.flatpickr-input,
[data-theme="light"] .flatpickr-input[readonly],
[data-theme="light"] input.flatpickr-input.form-control,
[data-theme="light"] input[type="text"].flatpickr-input {
    background: rgba(255, 255, 255, 0.9) !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #1a1a1a !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    cursor: pointer !important;
}

[data-theme="light"] .flatpickr-calendar {
    background: white !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .flatpickr-months,
[data-theme="light"] .flatpickr-weekdays {
    background: white !important;
}

[data-theme="light"] .flatpickr-weekday {
    color: var(--text-secondary) !important;
}

[data-theme="light"] .flatpickr-day,
[data-theme="light"] .flatpickr-day.flatpickr-disabled,
[data-theme="light"] .flatpickr-day.prevMonthDay,
[data-theme="light"] .flatpickr-day.nextMonthDay,
[data-theme="light"] span.flatpickr-day {
    color: #1a1a1a !important;
}

[data-theme="light"] .flatpickr-day:hover {
    background: rgba(49, 130, 206, 0.1) !important;
    color: #1a1a1a !important;
}

[data-theme="light"] .flatpickr-day.selected,
[data-theme="light"] .flatpickr-day.selected:hover {
    background: var(--accent-primary) !important;
    color: white !important;
    border-color: var(--accent-primary) !important;
}

[data-theme="light"] .flatpickr-day.today {
    border-color: var(--accent-primary) !important;
}

[data-theme="light"] .flatpickr-day.flatpickr-disabled,
[data-theme="light"] .flatpickr-day.prevMonthDay,
[data-theme="light"] .flatpickr-day.nextMonthDay {
    color: #9ca3af !important;
}

[data-theme="light"] .flatpickr-current-month {
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-current-month .flatpickr-monthDropdown-months {
    background: white !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-monthDropdown-months,
[data-theme="light"] .numInputWrapper input {
    background: white !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-months .flatpickr-month {
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-months .flatpickr-prev-month,
[data-theme="light"] .flatpickr-months .flatpickr-next-month {
    fill: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-months .flatpickr-prev-month:hover,
[data-theme="light"] .flatpickr-months .flatpickr-next-month:hover {
    fill: var(--accent-primary) !important;
}

/* Light theme date range picker input (CheckPoints page) */
[data-theme="light"] #dateRangePicker {
    background: rgba(255, 255, 255, 0.9) !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #1a1a1a !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    cursor: pointer !important;
}

[data-theme="light"] #dateRangePicker:focus {
    background: rgba(255, 255, 255, 1) !important;
    background-color: rgba(255, 255, 255, 1) !important;
    border-color: var(--accent-primary) !important;
}

[data-theme="light"] #dateRangePicker[readonly] {
    background: rgba(255, 255, 255, 0.9) !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

[data-theme="light"] #dateRangePicker::placeholder {
    color: var(--text-muted) !important;
}

/* Light theme search input (CheckPoints page) */
[data-theme="light"] #searchInput {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #1a1a1a !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
}

[data-theme="light"] #searchInput:focus {
    background: rgba(255, 255, 255, 1) !important;
    border-color: var(--accent-primary) !important;
}

[data-theme="light"] #searchInput::placeholder {
    color: var(--text-muted) !important;
}

[data-theme="light"] .search-icon,
[data-theme="light"] .calendar-icon {
    color: var(--text-muted) !important;
}

[data-theme="light"] #searchInput:focus ~ .search-icon,
[data-theme="light"] #searchInput:not(:placeholder-shown) ~ .search-icon,
[data-theme="light"] #dateRangePicker:focus ~ .calendar-icon {
    color: var(--accent-primary) !important;
}

/* Light theme info cards (customer info display) */
[data-theme="light"] .info-card,
[data-theme="light"] .customer-info-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 240, 240, 0.9) 100%) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .customer-info-card::before {
    background: linear-gradient(135deg, rgba(49, 130, 206, 0.1), rgba(168, 85, 247, 0.1)) !important;
}

[data-theme="light"] .customer-info-card:hover {
    border-color: rgba(49, 130, 206, 0.4) !important;
    box-shadow: 0 8px 24px rgba(49, 130, 206, 0.2) !important;
}

[data-theme="light"] .info-card-title,
[data-theme="light"] .customer-info-title {
    color: var(--text-secondary) !important;
}

[data-theme="light"] .customer-info-label {
    color: var(--text-muted) !important;
}

[data-theme="light"] .info-card-value,
[data-theme="light"] .customer-info-value {
    color: var(--text-primary) !important;
    font-weight: 700;
}

/* Light theme alert/message boxes */
[data-theme="light"] .alert,
[data-theme="light"] .message-box,
[data-theme="light"] .no-customer-message,
[data-theme="light"] .customer-not-found {
    background: rgba(254, 226, 226, 0.8) !important;
    border: 1px solid rgba(229, 62, 62, 0.3) !important;
    color: #c53030 !important;
}

[data-theme="light"] .customer-not-found-text {
    color: #c53030 !important;
}

[data-theme="light"] .customer-fixed-discount {
    background: rgba(209, 250, 229, 0.8) !important;
    border: 1px solid rgba(56, 161, 105, 0.3) !important;
    color: #2f855a !important;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0a0b14;
    --bg-secondary: #1e293b;
    --bg-tertiary: #312e81;
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --accent-primary: #60a5fa;
    --accent-secondary: #a855f7;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --info: #60a5fa;
}

/* Dark theme body with gradient */
[data-theme="dark"] body {
    background: #0a0b14 !important;
    background-image: radial-gradient(circle at 25% 25%, #1e293b 0%, transparent 50%), 
                      radial-gradient(circle at 75% 75%, #312e81 0%, transparent 50%) !important;
    background-attachment: fixed !important;
}

/* Dark theme specific components */
[data-theme="dark"] .navbar,
[data-theme="dark"] .dashboard-header {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(20px);
}

[data-theme="dark"] .modern-footer {
    background: rgba(15, 23, 42, 0.5) !important;
}

[data-theme="dark"] .dashboard-card,
[data-theme="dark"] .card {
    background: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.15) !important;
}

[data-theme="dark"] .card-body {
    background: transparent !important;
}

/* System theme preference detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg-primary: #0a0b14;
        --bg-secondary: #1e293b;
        --bg-tertiary: #312e81;
        --text-primary: #f1f5f9;
        --text-secondary: #e2e8f0;
        --text-muted: #94a3b8;
        --border-color: #334155;
        --shadow: rgba(0, 0, 0, 0.3);
        --accent-primary: #60a5fa;
        --accent-secondary: #a855f7;
        --success: #48bb78;
        --warning: #ed8936;
        --danger: #f56565;
        --info: #60a5fa;
    }
    
    :root:not([data-theme="light"]):not([data-theme="dark"]) body {
        background: #0a0b14 !important;
        background-image: radial-gradient(circle at 25% 25%, #1e293b 0%, transparent 50%), 
                          radial-gradient(circle at 75% 75%, #312e81 0%, transparent 50%) !important;
        background-attachment: fixed !important;
    }
}

/* Base theme styles */
body {
    background-color: var(--bg-primary) !important;
    background-image: none !important;
    color: var(--text-primary) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px;
}

.theme-toggle-btn:hover {
    background: rgba(30, 41, 59, 1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.theme-icon {
    transition: all 0.3s ease;
}

/* Show/hide icons based on theme */
[data-theme="dark"] .theme-toggle-btn .sun-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle-btn .moon-icon {
    display: none;
}

[data-theme="light"] .theme-toggle-btn .sun-icon {
    display: none;
}

[data-theme="light"] .theme-toggle-btn .moon-icon {
    display: block;
}

/* Light theme button styling */
[data-theme="light"] .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

[data-theme="light"] .theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--accent-primary);
}

/* Dark theme - white icons */
[data-theme="dark"] .theme-toggle-btn svg,
[data-theme="dark"] .theme-icon {
    stroke: #f1f5f9 !important;
    color: #f1f5f9 !important;
}

/* Light theme - dark icons */
[data-theme="light"] .theme-toggle-btn svg,
[data-theme="light"] .theme-icon {
    stroke: #1a1a1a !important;
    color: #1a1a1a !important;
}

/* Apply theme variables to common elements */
.card, .modern-card, .dashboard-card {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.table {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

    .table th {
        background-color: var(--bg-secondary);
        border-color: var(--border-color);
        color: var(--text-primary);
    }

    .table td {
        border-color: var(--border-color);
        color: var(--text-secondary);
    }

/* Form elements */
.form-control, .form-control-custom {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

    .form-control:focus, .form-control-custom:focus {
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 0.2rem rgba(var(--accent-primary-rgb, 99, 179, 237), 0.25);
    }

/* Buttons */
.btn-primary {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

    .btn-primary:hover {
        background-color: var(--accent-secondary);
        border-color: var(--accent-secondary);
    }

/* Light theme header buttons (language, theme, QR) */
[data-theme="light"] .header-actions button,
[data-theme="light"] .header-actions .btn,
[data-theme="light"] button[data-theme-toggle-btn] {
    background: white !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    color: #1a1a1a !important;
}

[data-theme="light"] .header-actions button:hover,
[data-theme="light"] .header-actions .btn:hover,
[data-theme="light"] button[data-theme-toggle-btn]:hover {
    background: rgba(240, 240, 240, 1) !important;
    border-color: rgba(0, 0, 0, 0.3) !important;
}

/* Navigation */
.navbar {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

.navbar-brand, .nav-link {
    color: var(--text-primary) !important;
}

/* Dashboard specific */
.dashboard-header {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Modern layout adjustments */
.modern-layout {
    background-color: var(--bg-primary);
}

.modern-footer {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}
