/**
 * ============================================================================
 * Global Theme Mode CSS (Light / Dark Model)
 * File: theme_model.css
 * ============================================================================
 * Rules: 
 *  - 100% External Global CSS
 *  - Supports Light Mode (White) and Dark Mode (Night)
 *  - Pure CSS Custom Properties with deep component overrides
 *  - Zero inline styles, Zero internal CSS
 * ============================================================================
 */

/* ==========================================================================
   1. CSS Custom Properties / Color Tokens
   ========================================================================== */
:root,
html[data-layout-mode="light"],
html.light-mode,
body.light-theme {
    --tm-bg-body: #f3f3f9;
    --tm-bg-surface: #ffffff;
    --tm-bg-surface-secondary: #f8f9fa;
    --tm-bg-surface-tertiary: #f1f5f9;
    --tm-border-color: #e9ebec;
    --tm-border-color-subtle: #f1f3f5;
    --tm-text-primary: #212529;
    --tm-text-secondary: #64748b;
    --tm-text-muted: #878a99;
    --tm-text-heading: #1e293b;
    
    --tm-topbar-bg: #0f172a;
    --tm-topbar-border: #1e293b;
    --tm-topbar-text: #f8fafc;
    
    --tm-sidebar-bg: #ffffff;
    --tm-sidebar-border: #e9ebec;
    --tm-sidebar-text: #495057;
    --tm-sidebar-text-active: #2563eb;
    
    --tm-card-bg: #ffffff;
    --tm-card-border: #e9ebec;
    --tm-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --tm-card-hover-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.07);
    
    --tm-table-bg: #ffffff;
    --tm-table-header-bg: #f8f9fa;
    --tm-table-header-color: #495057;
    --tm-table-row-hover: #f8fafc;
    --tm-table-border: #eff2f7;
    --tm-table-striped-bg: rgba(0, 0, 0, 0.015);
    
    --tm-input-bg: #ffffff;
    --tm-input-border: #ced4da;
    --tm-input-focus-border: #2563eb;
    --tm-input-text: #212529;
    --tm-input-placeholder: #adb5bd;
    
    --tm-dropdown-bg: #ffffff;
    --tm-dropdown-border: #e2e8f0;
    --tm-dropdown-item-color: #334155;
    --tm-dropdown-item-hover: #f1f5f9;
    --tm-dropdown-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    --tm-modal-bg: #ffffff;
    --tm-modal-header-bg: #ffffff;
    --tm-modal-footer-bg: #f8fafc;
    --tm-modal-border: #e2e8f0;
    
    --tm-code-bg: #f1f5f9;
    --tm-code-text: #0f172a;
    --tm-code-border: #e2e8f0;
    
    --tm-scrollbar-thumb: #cbd5e1;
    --tm-scrollbar-track: #f1f5f9;
}

html[data-layout-mode="dark"],
html[data-theme="dark"],
html.dark-mode,
body.dark-theme {
    --tm-bg-body: #0b0f19;
    --tm-bg-surface: #111827;
    --tm-bg-surface-secondary: #1f2937;
    --tm-bg-surface-tertiary: #1e293b;
    --tm-border-color: #1f2937;
    --tm-border-color-subtle: #1e293b;
    --tm-text-primary: #f3f4f6;
    --tm-text-secondary: #9ca3af;
    --tm-text-muted: #6b7280;
    --tm-text-heading: #f9fafb;
    
    --tm-topbar-bg: #0b0f19;
    --tm-topbar-border: #1f2937;
    --tm-topbar-text: #f9fafb;
    
    --tm-sidebar-bg: #111827;
    --tm-sidebar-border: #1f2937;
    --tm-sidebar-text: #9ca3af;
    --tm-sidebar-text-active: #60a5fa;
    
    --tm-card-bg: #111827;
    --tm-card-border: #1f2937;
    --tm-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --tm-card-hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    
    --tm-table-bg: #111827;
    --tm-table-header-bg: #0f172a;
    --tm-table-header-color: #94a3b8;
    --tm-table-row-hover: #1e293b;
    --tm-table-border: #1f2937;
    --tm-table-striped-bg: rgba(255, 255, 255, 0.02);
    
    --tm-input-bg: #0f172a;
    --tm-input-border: #334155;
    --tm-input-focus-border: #3b82f6;
    --tm-input-text: #f9fafb;
    --tm-input-placeholder: #64748b;
    
    --tm-dropdown-bg: #111827;
    --tm-dropdown-border: #1f2937;
    --tm-dropdown-item-color: #e2e8f0;
    --tm-dropdown-item-hover: #1e293b;
    --tm-dropdown-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    
    --tm-modal-bg: #111827;
    --tm-modal-header-bg: #111827;
    --tm-modal-footer-bg: #0f172a;
    --tm-modal-border: #1f2937;
    
    --tm-code-bg: #0f172a;
    --tm-code-text: #38bdf8;
    --tm-code-border: #1e293b;
    
    --tm-scrollbar-thumb: #334155;
    --tm-scrollbar-track: #0f172a;
}

/* ==========================================================================
   2. Global Layout & Page Background Overrides
   ========================================================================== */
body,
#layout-wrapper,
.main-content,
.page-content {
    background-color: var(--tm-bg-body) !important;
    color: var(--tm-text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Typography & Headings in Theme */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--tm-text-heading);
}

.text-dark {
    color: var(--tm-text-primary) !important;
}

.text-muted {
    color: var(--tm-text-muted) !important;
}

.text-secondary {
    color: var(--tm-text-secondary) !important;
}

/* ==========================================================================
   3. Card & Panel Components
   ========================================================================== */
.card {
    background-color: var(--tm-card-bg) !important;
    border: 1px solid var(--tm-card-border) !important;
    box-shadow: var(--tm-card-shadow) !important;
    color: var(--tm-text-primary);
    transition: all 0.2s ease;
}

.card-header {
    background-color: var(--tm-card-bg) !important;
    border-bottom: 1px solid var(--tm-card-border) !important;
    color: var(--tm-text-heading) !important;
}

.card-footer {
    background-color: var(--tm-card-bg) !important;
    border-top: 1px solid var(--tm-card-border) !important;
    color: var(--tm-text-secondary) !important;
}

.card-body {
    color: var(--tm-text-primary);
}

/* ==========================================================================
   4. Data Tables & DataGrid Theme Overrides
   ========================================================================== */
.table {
    color: var(--tm-text-primary) !important;
    border-color: var(--tm-table-border) !important;
}

.table > :not(caption) > * > * {
    background-color: var(--tm-table-bg);
    color: var(--tm-text-primary) !important;
    border-bottom-color: var(--tm-table-border) !important;
}

.table thead th,
.table-light th,
thead.table-light th {
    background-color: var(--tm-table-header-bg) !important;
    color: var(--tm-table-header-color) !important;
    border-bottom: 1px solid var(--tm-table-border) !important;
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--tm-table-row-hover) !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--tm-table-striped-bg) !important;
}

/* ==========================================================================
   5. Form Controls, Inputs, Selects, and Switches
   ========================================================================== */
.form-control,
.form-select {
    background-color: var(--tm-input-bg) !important;
    border: 1px solid var(--tm-input-border) !important;
    color: var(--tm-input-text) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--tm-input-bg) !important;
    border-color: var(--tm-input-focus-border) !important;
    color: var(--tm-input-text) !important;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25) !important;
}

.form-control::placeholder {
    color: var(--tm-input-placeholder) !important;
}

.form-label,
label {
    color: var(--tm-text-primary);
    font-weight: 500;
}

.input-group-text {
    background-color: var(--tm-bg-surface-secondary) !important;
    border: 1px solid var(--tm-input-border) !important;
    color: var(--tm-text-secondary) !important;
}

.form-check-input {
    background-color: var(--tm-input-bg);
    border-color: var(--tm-input-border);
}

.form-check-input:checked {
    background-color: #2563eb;
    border-color: #2563eb;
}

.form-check-label {
    color: var(--tm-text-primary);
}

/* ==========================================================================
   6. Modals & Dialogs
   ========================================================================== */
.modal-content {
    background-color: var(--tm-modal-bg) !important;
    border: 1px solid var(--tm-modal-border) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35) !important;
    color: var(--tm-text-primary) !important;
}

.modal-header {
    background-color: var(--tm-modal-header-bg) !important;
    border-bottom: 1px solid var(--tm-modal-border) !important;
    color: var(--tm-text-heading) !important;
}

.modal-footer {
    background-color: var(--tm-modal-footer-bg) !important;
    border-top: 1px solid var(--tm-modal-border) !important;
}

.modal-title {
    color: var(--tm-text-heading) !important;
}

/* ==========================================================================
   7. Dropdowns & Menus
   ========================================================================== */
.dropdown-menu {
    background-color: var(--tm-dropdown-bg) !important;
    border: 1px solid var(--tm-dropdown-border) !important;
    box-shadow: var(--tm-dropdown-shadow) !important;
    color: var(--tm-dropdown-item-color) !important;
}

.dropdown-item {
    color: var(--tm-dropdown-item-color) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--tm-dropdown-item-hover) !important;
    color: var(--tm-text-heading) !important;
}

.dropdown-divider {
    border-top-color: var(--tm-border-color) !important;
}

.dropdown-header {
    color: var(--tm-text-muted) !important;
}

/* ==========================================================================
   8. Navigation Tabs & Pills
   ========================================================================== */
.nav-tabs {
    border-bottom-color: var(--tm-border-color) !important;
}

.nav-tabs .nav-link {
    color: var(--tm-text-secondary);
    border-color: transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--tm-text-primary);
    border-color: var(--tm-border-color) var(--tm-border-color) transparent;
}

.nav-tabs .nav-link.active {
    background-color: var(--tm-card-bg) !important;
    color: #2563eb !important;
    border-color: var(--tm-border-color) var(--tm-border-color) var(--tm-card-bg) !important;
}

/* ==========================================================================
   9. Background Utility Overrides in Dark Mode
   ========================================================================== */
html[data-layout-mode="dark"] .bg-light,
html[data-layout-mode="dark"] .bg-white,
body.dark-theme .bg-light,
body.dark-theme .bg-white {
    background-color: var(--tm-bg-surface-secondary) !important;
    color: var(--tm-text-primary) !important;
}

html[data-layout-mode="dark"] .border-light,
body.dark-theme .border-light {
    border-color: var(--tm-border-color) !important;
}

/* Code & Monospace Badges */
code,
pre,
kbd,
samp {
    background-color: var(--tm-code-bg);
    color: var(--tm-code-text);
    border: 1px solid var(--tm-code-border);
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
}

/* Subtle Badges in Dark Mode */
html[data-layout-mode="dark"] .bg-primary-subtle,
body.dark-theme .bg-primary-subtle {
    background-color: rgba(37, 99, 235, 0.2) !important;
    color: #93c5fd !important;
}

html[data-layout-mode="dark"] .bg-success-subtle,
body.dark-theme .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}

html[data-layout-mode="dark"] .bg-danger-subtle,
body.dark-theme .bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}

html[data-layout-mode="dark"] .bg-warning-subtle,
body.dark-theme .bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fcd34d !important;
}

html[data-layout-mode="dark"] .bg-info-subtle,
body.dark-theme .bg-info-subtle {
    background-color: rgba(6, 182, 212, 0.2) !important;
    color: #67e8f9 !important;
}

html[data-layout-mode="dark"] .bg-secondary-subtle,
body.dark-theme .bg-secondary-subtle {
    background-color: rgba(148, 163, 184, 0.2) !important;
    color: #cbd5e1 !important;
}

/* ==========================================================================
   10. Sidebar Navigation Theme Tuning
   ========================================================================== */
.app-menu.navbar-menu {
    background: var(--tm-sidebar-bg) !important;
    border-right: 1px solid var(--tm-sidebar-border) !important;
}

html[data-layout-mode="dark"] .app-menu.navbar-menu,
body.dark-theme .app-menu.navbar-menu {
    background: #111827 !important;
    border-right: 1px solid #1f2937 !important;
}

html[data-layout-mode="dark"] .navbar-menu .navbar-nav .nav-link,
body.dark-theme .navbar-menu .navbar-nav .nav-link {
    color: #9ca3af !important;
}

html[data-layout-mode="dark"] .navbar-menu .navbar-nav .nav-link:hover,
html[data-layout-mode="dark"] .navbar-menu .navbar-nav .nav-link.active,
body.dark-theme .navbar-menu .navbar-nav .nav-link:hover,
body.dark-theme .navbar-menu .navbar-nav .nav-link.active {
    color: #60a5fa !important;
}

html[data-layout-mode="dark"] .menu-title,
body.dark-theme .menu-title {
    color: #64748b !important;
}

/* ==========================================================================
   11. Top Navigation Bar Classes (Centralized in theme_model.css)
   ========================================================================== */
.gw-topbar-header {
    background: var(--tm-topbar-bg) !important;
    border-bottom: 1px solid var(--tm-topbar-border) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}

.gw-hamburger-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.07);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.15s ease;
}

.gw-hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

.gw-header-badge {
    font-size: 13.5px;
}

.gw-app-pill {
    background: rgba(37, 99, 235, 0.18);
    color: #93c5fd;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(37, 99, 235, 0.35);
    font-size: 12.5px;
}

.gw-divider-slash {
    color: #64748b;
    opacity: 0.6;
}

.gw-company-pill {
    color: #cbd5e1;
    font-weight: 600;
    font-size: 13px;
}

.gw-node-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    font-size: 11.5px;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.gw-node-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.gw-topbar-btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 5px 12px;
    font-size: 12.5px;
}

.gw-btn-outline-dark {
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1 !important;
    background: rgba(255, 255, 255, 0.05);
}

.gw-btn-outline-dark:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.3);
}

.gw-btn-ticket {
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.1);
}

.gw-btn-ticket:hover {
    background: #0284c7;
    color: #ffffff !important;
    border-color: #0284c7;
}

.gw-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    transition: all 0.15s ease;
}

.gw-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

.gw-avatar {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.gw-user-btn {
    border: 1px solid transparent;
    border-radius: 10px;
    transition: all 0.15s ease;
}

.gw-user-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.gw-user-role-text {
    font-size: 11px;
    line-height: 1;
    color: #94a3b8 !important;
}

.gw-user-chevron {
    font-size: 10px;
    color: #94a3b8 !important;
}

.gw-notif-dropdown {
    width: 320px;
    border-radius: 14px;
    border: 1px solid var(--tm-border-color);
    background-color: var(--tm-dropdown-bg);
}

.gw-notif-badge-pill {
    font-size: 10px;
}

.gw-notif-body {
    max-height: 280px;
    overflow-y: auto;
}

.gw-notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 14px;
    flex-shrink: 0;
}

.gw-notif-item:hover {
    background: var(--tm-dropdown-item-hover);
}

.gw-notif-time {
    font-size: 11px;
}

.gw-notif-text {
    max-width: 230px;
}

.gw-user-dropdown {
    width: 220px;
    border-radius: 12px;
    border: 1px solid var(--tm-border-color);
    background-color: var(--tm-dropdown-bg);
}

/* ==========================================================================
   12. Pagination Theme Tuning
   ========================================================================== */
.page-link {
    background-color: var(--tm-card-bg) !important;
    border-color: var(--tm-border-color) !important;
    color: var(--tm-text-secondary) !important;
}

.page-link:hover {
    background-color: var(--tm-bg-surface-secondary) !important;
    color: var(--tm-text-primary) !important;
}

.page-item.active .page-link {
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
}

.page-item.disabled .page-link {
    background-color: var(--tm-bg-surface-secondary) !important;
    color: var(--tm-text-muted) !important;
}

/* ==========================================================================
   13. Custom Scrollbar Styling
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--tm-scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--tm-scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ==========================================================================
   14. SweetAlert2 / Toastr / Popup Overrides in Dark Mode
   ========================================================================== */
html[data-layout-mode="dark"] .swal2-popup,
body.dark-theme .swal2-popup {
    background: #111827 !important;
    color: #f3f4f6 !important;
    border: 1px solid #1f2937 !important;
}

html[data-layout-mode="dark"] .swal2-title,
html[data-layout-mode="dark"] .swal2-html-container,
body.dark-theme .swal2-title,
body.dark-theme .swal2-html-container {
    color: #e5e7eb !important;
}
