:root {
    --lw-theme-bg: #1b1b23;
    --lw-theme-surface: #121117;
    --lw-theme-surface-raised: #1d1d27;
    --lw-theme-border: rgba(255, 255, 255, .09);
    --lw-theme-text: #e8e7ec;
    --lw-theme-muted: #96939f;
    --lw-theme-shadow: 0 14px 34px rgba(0, 0, 0, .18);
}

html[data-theme="light"] {
    color-scheme: light;
    --lw-theme-bg: #f4f5f8;
    --lw-theme-surface: #ffffff;
    --lw-theme-surface-raised: #f7f7fa;
    --lw-theme-border: rgba(31, 33, 43, .11);
    --lw-theme-text: #24252d;
    --lw-theme-muted: #727582;
    --lw-theme-shadow: 0 14px 34px rgba(35, 38, 50, .08);
    --lw-page-bg-color: #f4f5f8;
}

.lw-theme-toggle-item {
    display: flex;
    align-items: center;
}

.topbar .lw-theme-toggle {
    display: grid !important;
    place-items: center;
    width: 42px;
    height: 42px !important;
    margin: auto .2rem;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 13px;
    outline: 0;
    background: rgba(255, 255, 255, .045);
    color: #bbb9c3 !important;
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.topbar .lw-theme-toggle:hover {
    border-color: rgba(207, 29, 104, .38);
    background: rgba(207, 29, 104, .1);
    color: #fff !important;
    transform: translateY(-1px);
}

.lw-theme-toggle-icon {
    position: relative;
    display: block;
    width: 23px;
    height: 23px;
}

.lw-theme-toggle-icon i {
    position: absolute;
    transition: opacity .22s ease, transform .28s ease;
}

.lw-theme-sun {
    top: 1px;
    left: 0;
    color: #f1bd4b;
    font-size: 14px;
}

.lw-theme-moon {
    right: 0;
    bottom: 0;
    color: #9da5dc;
    font-size: 13px;
}

html[data-theme="dark"] .lw-theme-sun { opacity: .55; transform: rotate(-18deg) scale(.84); }
html[data-theme="dark"] .lw-theme-moon { opacity: 1; transform: translate(-1px, -1px) scale(1); }
html[data-theme="light"] .lw-theme-sun { opacity: 1; transform: rotate(20deg) scale(1); }
html[data-theme="light"] .lw-theme-moon { opacity: .42; transform: translate(1px, 1px) scale(.82); }

html[data-theme="light"] body.lw-public-master,
html[data-theme="light"] body.lw-admin-section,
html[data-theme="light"] body.lw-public-master .lw-page-bg,
html[data-theme="light"] body.lw-admin-section .lw-page-bg,
html[data-theme="light"] body.lw-public-master #content-wrapper,
html[data-theme="light"] body.lw-admin-section #content-wrapper,
html[data-theme="light"] body.lw-admin-section #content-wrapper.bg-gray-900 {
    background-color: var(--lw-theme-bg) !important;
    color: var(--lw-theme-text);
}

html[data-theme="light"] body.lw-public-master .topbar,
html[data-theme="light"] body.lw-admin-section .topbar {
    border-bottom: 1px solid var(--lw-theme-border);
    background: rgba(255, 255, 255, .94) !important;
    box-shadow: 0 8px 24px rgba(35, 38, 50, .06) !important;
}

html[data-theme="light"] .topbar .nav-link,
html[data-theme="light"] .topbar strong,
html[data-theme="light"] .topbar .navbar-nav .nav-item .nav-link {
    color: #555865 !important;
}

html[data-theme="light"] .topbar .lw-theme-toggle {
    border-color: var(--lw-theme-border);
    background: #f6f6f9;
}

html[data-theme="light"] .topbar .topbar-divider { border-color: var(--lw-theme-border); }

html[data-theme="light"] body.lw-public-master #accordionSidebar,
html[data-theme="light"] body.lw-admin-section #accordionSidebar {
    border-right: 1px solid var(--lw-theme-border);
    background: #fff !important;
}

html[data-theme="light"] .sidebar-dark hr.sidebar-divider { border-top-color: var(--lw-theme-border); }
html[data-theme="light"] .sidebar-dark .nav-item .nav-link,
html[data-theme="light"] .sidebar-dark .nav-item .nav-link i { color: #676a76; }
html[data-theme="light"] .sidebar-dark .nav-item .nav-link:hover,
html[data-theme="light"] .sidebar-dark .nav-item .nav-link:hover i,
html[data-theme="light"] .sidebar-dark .nav-item.active .nav-link,
html[data-theme="light"] .sidebar-dark .nav-item.active .nav-link i { color: #c61d61; }
html[data-theme="light"] .sidebar-dark .collapse-inner { background: #f5f5f8; }
html[data-theme="light"] .sidebar-dark .collapse-inner .nav-link { color: #666976 !important; }
html[data-theme="light"] .sidebar-dark .collapse-inner .nav-link:hover,
html[data-theme="light"] .sidebar-dark .collapse-inner .nav-item.active .nav-link { background: #fff; color: #c61d61 !important; }

html[data-theme="light"] body.lw-public-master .card,
html[data-theme="light"] body.lw-admin-section .card,
html[data-theme="light"] body.lw-public-master .modal-content,
html[data-theme="light"] body.lw-admin-section .modal-content,
html[data-theme="light"] body.lw-public-master .list-group-item,
html[data-theme="light"] body.lw-admin-section .list-group-item {
    border-color: var(--lw-theme-border);
    background-color: var(--lw-theme-surface);
    color: var(--lw-theme-text);
    box-shadow: var(--lw-theme-shadow);
}

/* These legacy profile cards intentionally stay dark in light mode. */
html[data-theme="light"] .lw-user-thumbnail-block {
    color: #dfe0e7 !important;
    background-color: #202027 !important;
    background-image: linear-gradient(155deg, #25252e, #1b1b21) !important;
}
html[data-theme="light"] .lw-user-thumbnail-block .card-title,
html[data-theme="light"] .lw-user-thumbnail-block .card-title h5,
html[data-theme="light"] .lw-user-thumbnail-block .card-title span {
    color: #dfe0e7 !important;
}
html[data-theme="light"] .lw-user-thumbnail-block .card-title .text-secondary,
html[data-theme="light"] .lw-user-thumbnail-block .card-title .text-secondary:hover {
    color: #fff !important;
    border-bottom-color: rgba(255,255,255,.35);
}

html[data-theme="light"] .card .card-header,
html[data-theme="light"] .card .card-footer,
html[data-theme="light"] .modal-content .modal-header,
html[data-theme="light"] .modal-content .modal-footer {
    border-color: var(--lw-theme-border);
    background: var(--lw-theme-surface-raised);
    color: var(--lw-theme-text);
}

html[data-theme="light"] .modal-content .close { color: #545762; text-shadow: none; }
html[data-theme="light"] .dropdown-menu {
    border: 1px solid var(--lw-theme-border);
    background: #fff;
    color: var(--lw-theme-text);
    box-shadow: 0 18px 45px rgba(35, 38, 50, .13);
}
html[data-theme="light"] .dropdown-item { color: #555865; }
html[data-theme="light"] .dropdown-item:hover,
html[data-theme="light"] .dropdown-item:focus { background: #f3f3f7; color: #252630; }
html[data-theme="light"] .dropdown-divider { border-top-color: var(--lw-theme-border); }
html[data-theme="light"] .dropdown-header { color: #767985; }
html[data-theme="light"] .topbar .dropdown-menu .dropdown-item,
html[data-theme="light"] .topbar .dropdown-list .dropdown-item { color: #555865; }
html[data-theme="light"] .topbar .dropdown-menu .dropdown-item:hover,
html[data-theme="light"] .topbar .dropdown-menu .dropdown-item:focus { background: #f0f1f5; color: #252630; }
html[data-theme="light"] .topbar .dropdown-list #lwNotificationContent,
html[data-theme="light"] .topbar .dropdown-list .lw-notification-content { background: #f7f7fa; }
html[data-theme="light"] #dropdownAlerts .lw-notification-item .font-weight-bold { color: #30313a; }
html[data-theme="light"] #dropdownAlerts .lw-notification-item .text-gray-500 { color: #777a86 !important; }

/* Notification dropdowns use a dark palette in the legacy topbar styles.
   Re-map every layer in light mode so the content remains readable. */
html[data-theme="light"] .topbar #dropdownAlerts,
html[data-theme="light"] .topbar #adminDropdownAlerts {
    background: #ffffff !important;
    border-color: rgba(31, 33, 43, .12);
    box-shadow: 0 18px 45px rgba(35, 38, 50, .14);
}
html[data-theme="light"] .topbar #dropdownAlerts > .lw-mark-all-notifications-panel,
html[data-theme="light"] .topbar #adminDropdownAlerts > .lw-mark-all-notifications-panel {
    color: #656875;
    background: #f2f3f7;
    border-bottom-color: rgba(31, 33, 43, .1);
}
html[data-theme="light"] .topbar #dropdownAlerts .lw-notification-content,
html[data-theme="light"] .topbar #adminDropdownAlerts .lw-notification-content {
    background: #f7f7fa;
}
html[data-theme="light"] .topbar #dropdownAlerts .lw-notification-item,
html[data-theme="light"] .topbar #adminDropdownAlerts .lw-notification-item {
    color: #353742 !important;
    background: #ffffff !important;
    border-color: rgba(31, 33, 43, .12) !important;
    box-shadow: 0 4px 12px rgba(35, 38, 50, .06);
}
html[data-theme="light"] .topbar #dropdownAlerts .lw-notification-item > a .small,
html[data-theme="light"] .topbar #adminDropdownAlerts .lw-notification-item > a .small {
    color: #7b7e8a !important;
}
html[data-theme="light"] .topbar #dropdownAlerts .lw-notification-item > a .font-weight-bold,
html[data-theme="light"] .topbar #adminDropdownAlerts .lw-notification-item > a .font-weight-bold {
    color: #30313a !important;
}
html[data-theme="light"] .topbar #dropdownAlerts .lw-mark-notification-read,
html[data-theme="light"] .topbar #adminDropdownAlerts .lw-mark-notification-read {
    color: #686c79;
    border-color: rgba(31, 33, 43, .16);
}
html[data-theme="light"] .topbar #dropdownAlerts .lw-mark-notification-read:hover,
html[data-theme="light"] .topbar #adminDropdownAlerts .lw-mark-notification-read:hover {
    color: #c61d61;
    background: rgba(198, 29, 97, .08);
    border-color: rgba(198, 29, 97, .35);
}
html[data-theme="light"] .topbar #dropdownAlerts #lwShowAllNotifyLink,
html[data-theme="light"] .topbar #adminDropdownAlerts #lwShowAllNotifyLink {
    color: #c61d61 !important;
}

html[data-theme="light"] .form-control,
html[data-theme="light"] .custom-select,
html[data-theme="light"] .input-group-text,
html[data-theme="light"] .dataTables_wrapper input,
html[data-theme="light"] .dataTables_wrapper select {
    border-color: var(--lw-theme-border) !important;
    background-color: #fff !important;
    color: #292a33 !important;
}
html[data-theme="light"] .form-control:disabled,
html[data-theme="light"] .form-control[readonly] { background-color: #ececf1 !important; }
html[data-theme="light"] .form-control::placeholder { color: #a1a2aa; }
html[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }

html[data-theme="light"] .table,
html[data-theme="light"] .table td,
html[data-theme="light"] .table th { color: #454751; }
html[data-theme="light"] .table td,
html[data-theme="light"] .table th,
html[data-theme="light"] .table-bordered { border-color: var(--lw-theme-border) !important; }
html[data-theme="light"] .table thead th { background: #f2f3f6; color: #696c78; }
html[data-theme="light"] .table-hover tbody tr:hover { background-color: rgba(207, 29, 104, .045); }
html[data-theme="light"] .page-link {
    border-color: var(--lw-theme-border);
    background: #fff;
    color: #5d606b;
}
html[data-theme="light"] .page-item.disabled .page-link { background: #eceef2; color: #9a9ca5; }

html[data-theme="light"] .nav-tabs { border-bottom-color: var(--lw-theme-border); }
html[data-theme="light"] .nav-tabs .nav-link { color: #747783; }
html[data-theme="light"] .nav-tabs .nav-link.active,
html[data-theme="light"] .nav-tabs .nav-link:hover {
    border-color: var(--lw-theme-border) var(--lw-theme-border) #fff;
    background: #fff;
    color: #c61d61;
}

html[data-theme="light"] .text-gray-200,
html[data-theme="light"] .text-gray-300,
html[data-theme="light"] .text-gray-400 { color: #636672 !important; }
html[data-theme="light"] .text-gray-500,
html[data-theme="light"] .text-gray-600,
html[data-theme="light"] .text-muted { color: #797c87 !important; }
html[data-theme="light"] hr { border-top-color: var(--lw-theme-border); }
html[data-theme="light"] .bg-dark,
html[data-theme="light"] .bg-gray-900 { background-color: var(--lw-theme-bg) !important; }
html[data-theme="light"] .selectize-input,
html[data-theme="light"] .selectize-input.full,
html[data-theme="light"] .selectize-dropdown,
html[data-theme="light"] .selectize-dropdown.form-control {
    border-color: var(--lw-theme-border);
    background: #fff;
    color: #292a33;
}
html[data-theme="light"] .selectize-input input { color: #292a33; }
html[data-theme="light"] .selectize-dropdown .active { background: #f0f1f5; color: #24252d; }
html[data-theme="light"] .swal2-popup { background: #fff; color: #24252d; }
html[data-theme="light"] .swal2-title,
html[data-theme="light"] .swal2-html-container { color: #3c3e48 !important; }

html[data-theme="light"] .lw-top-wallet-group {
    border-color: var(--lw-theme-border);
    background: #f7f7fa;
}
html[data-theme="light"] .topbar .lw-top-wallet-link:hover { background: #ededf2; }
html[data-theme="light"] .lw-top-wallet-link + .lw-top-wallet-link { border-left-color: var(--lw-theme-border); }
html[data-theme="light"] .lw-top-wallet-currency { color: #777a85; }
html[data-theme="light"] .lw-top-wallet-amount { color: #24252d; }

html[data-theme="light"] .lw-admin-dashboard {
    --dashboard-bg: #f4f5f8;
    --dashboard-surface: #ffffff;
    --dashboard-surface-raised: #f5f6f9;
    --dashboard-border: rgba(31, 33, 43, .1);
    --dashboard-border-strong: rgba(31, 33, 43, .16);
    --dashboard-text: #24252d;
    --dashboard-muted: #727582;
    --dashboard-shadow: 0 14px 34px rgba(35, 38, 50, .08);
}

html[data-theme="light"] .lw-admin-users-page,
html[data-theme="light"] .lw-admin-list-page {
    --users-surface: #ffffff;
    --users-surface-raised: #f5f6f9;
    --users-border: rgba(31, 33, 43, .1);
    --users-text: #24252d;
    --users-muted: #727582;
}
html[data-theme="light"] .lw-user-management-panel,
html[data-theme="light"] .lw-admin-table-panel { background: #fff; border-color: var(--lw-theme-border); box-shadow: var(--lw-theme-shadow); }
html[data-theme="light"] .lw-admin-users-hero,
html[data-theme="light"] .lw-admin-list-hero,
html[data-theme="light"] .lw-dashboard-hero {
    background: radial-gradient(circle at 90% 5%, rgba(207,29,104,.1), transparent 31%), linear-gradient(135deg,#fff,#f3f4f8 72%);
}

@media (max-width: 767.98px) {
    .topbar .lw-theme-toggle { width: 38px; height: 38px !important; margin-right: .1rem; margin-left: .1rem; }

    html[data-theme="light"] .lw-mobile-bottom-nav {
        border-color: rgba(31, 33, 43, .12);
        background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(244,245,248,.98));
        box-shadow: 0 18px 45px rgba(38, 41, 54, .16), inset 0 1px 0 #fff;
    }
    html[data-theme="light"] .lw-mobile-bottom-nav a { color: #777a86; }
    html[data-theme="light"] .lw-mobile-bottom-nav a i { background: rgba(31,33,43,.055); color: #616470; }
    html[data-theme="light"] .lw-mobile-bottom-nav a.active,
    html[data-theme="light"] body:has(#messengerDialog.show) .lw-mobile-bottom-nav .lw-mobile-messenger-link,
    html[data-theme="light"] .lw-mobile-bottom-nav a:hover { color: #282a33; }
    html[data-theme="light"] .lw-mobile-bottom-nav .lw-mobile-bottom-badge { border-color: #f5f6f8; }
}
