/* ==========================================================================
   Faslun Store - Global Theme System (Light, Dark, System)
   ========================================================================== */

/* ---------------- CSS Variables ---------------- */
:root {
    --theme-bg-body: #F1F5F9;
    --theme-bg-app: #F8FAFC;
    --theme-bg-card: #FFFFFF;
    --theme-bg-card-subtle: #F8FAFC;
    --theme-bg-input: #FFFFFF;
    --theme-bg-nav: #FFFFFF;
    --theme-bg-header: linear-gradient(135deg, #0F52BA, #1E88E5);
    
    --theme-border: #E2E8F0;
    --theme-border-card: #F1F5F9;
    --theme-border-accent: #0F52BA;
    
    --theme-text-primary: #0F172A;
    --theme-text-secondary: #475569;
    --theme-text-muted: #94A3B8;
    --theme-text-inverse: #FFFFFF;
    
    --theme-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    --theme-shadow-lg: 0 8px 24px rgba(15, 82, 186, 0.08);
    --theme-shadow-nav: 0 -10px 40px rgba(0, 0, 0, 0.06);
    
    --theme-accent: #0F52BA;
    --theme-accent-light: #E0F2FE;
    --theme-success: #10B981;
    --theme-danger: #EF4444;
}

[data-theme="dark"] {
    --theme-bg-body: #090D16;
    --theme-bg-app: #0F172A;
    --theme-bg-card: #1E293B;
    --theme-bg-card-subtle: #182234;
    --theme-bg-input: #151E2E;
    --theme-bg-nav: #162032;
    --theme-bg-header: linear-gradient(135deg, #1E293B, #0F172A);
    
    --theme-border: #334155;
    --theme-border-card: #283548;
    --theme-border-accent: #38BDF8;
    
    --theme-text-primary: #FFFFFF;
    --theme-text-secondary: #E2E8F0;
    --theme-text-muted: #CBD5E1;
    --theme-text-inverse: #0F172A;
    
    --theme-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --theme-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
    --theme-shadow-nav: 0 -10px 30px rgba(0, 0, 0, 0.4);
    
    --theme-accent: #38BDF8;
    --theme-accent-light: rgba(56, 189, 248, 0.15);
    --theme-success: #34D399;
    --theme-danger: #F87171;
}

/* ---------------- Global Overrides for Dark Mode ---------------- */
[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="dark"],
[data-theme="dark"] body {
    background-color: var(--theme-bg-body) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .app-container {
    background-color: var(--theme-bg-app) !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6) !important;
}

/* Headers */
[data-theme="dark"] .dp-header,
[data-theme="dark"] .dp-sub-header,
[data-theme="dark"] .dp-appbar,
[data-theme="dark"] .header-section {
    background: var(--theme-bg-header) !important;
    border-bottom: 1px solid var(--theme-border) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .dp-header-clean {
    background: var(--theme-bg-card) !important;
    border-bottom: 1px solid var(--theme-border) !important;
}

[data-theme="dark"] .dp-header-clean a {
    color: #FFFFFF !important;
}

/* ---------------- Universal White Font Colors ---------------- */
[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6,
[data-theme="dark"] .dp-header-clean h3,
[data-theme="dark"] .page-title,
[data-theme="dark"] .section-title,
[data-theme="dark"] .menu-card-title,
[data-theme="dark"] .dp-grid-label,
[data-theme="dark"] .dp-grid-item span,
[data-theme="dark"] .dp-grid-item,
[data-theme="dark"] .wallet-menu,
[data-theme="dark"] .wallet-menu span,
[data-theme="dark"] .wallet-balance .amount,
[data-theme="dark"] #saldo-value,
[data-theme="dark"] .dp-card-outline h4,
[data-theme="dark"] .profile-info h4,
[data-theme="dark"] .menu-text,
[data-theme="dark"] .menu-item,
[data-theme="dark"] .menu-item span,
[data-theme="dark"] .nav-item.active span,
[data-theme="dark"] .live-feed-title,
[data-theme="dark"] .live-feed-user,
[data-theme="dark"] .live-feed-product,
[data-theme="dark"] .nominal-text,
[data-theme="dark"] .price,
[data-theme="dark"] .product-name,
[data-theme="dark"] .product-title,
[data-theme="dark"] .tx-title,
[data-theme="dark"] .item-title,
[data-theme="dark"] .card-title,
[data-theme="dark"] .desc-title,
[data-theme="dark"] .stat-value,
[data-theme="dark"] .title,
[data-theme="dark"] .form-label,
[data-theme="dark"] .label-text,
[data-theme="dark"] .protection-brand strong,
[data-theme="dark"] .toast-title,
[data-theme="dark"] marquee,
[data-theme="dark"] strong,
[data-theme="dark"] b,
[data-theme="dark"] th,
[data-theme="dark"] td,
[data-theme="dark"] label {
    color: #FFFFFF !important;
}

/* Secondary & Muted Typography */
[data-theme="dark"] p,
[data-theme="dark"] .subtext,
[data-theme="dark"] .text-muted,
[data-theme="dark"] .wallet-balance .label,
[data-theme="dark"] .profile-info p,
[data-theme="dark"] .menu-subtext,
[data-theme="dark"] .item-desc,
[data-theme="dark"] .product-desc,
[data-theme="dark"] .input-label,
[data-theme="dark"] .tx-date,
[data-theme="dark"] .time-text,
[data-theme="dark"] .stat-label,
[data-theme="dark"] .protection-brand span,
[data-theme="dark"] .toast-message,
[data-theme="dark"] .dp-card-outline p,
[data-theme="dark"] .info-text,
[data-theme="dark"] .help-text {
    color: #CBD5E1 !important;
}

/* Cards & Containers in Dark Mode */
[data-theme="dark"] .profile-card,
[data-theme="dark"] .menu-section,
[data-theme="dark"] .dp-wallet-card,
[data-theme="dark"] .input-card,
[data-theme="dark"] .menu-card,
[data-theme="dark"] .live-feed-card,
[data-theme="dark"] .card,
[data-theme="dark"] .trans-card,
[data-theme="dark"] .product-card,
[data-theme="dark"] .bank-card,
[data-theme="dark"] .history-card,
[data-theme="dark"] .info-card,
[data-theme="dark"] .detail-card,
[data-theme="dark"] .summary-card,
[data-theme="dark"] .auth-card,
[data-theme="dark"] .box-item,
[data-theme="dark"] .setting-card,
[data-theme="dark"] .promo-card-item,
[data-theme="dark"] .item-card,
[data-theme="dark"] .grid-card,
[data-theme="dark"] .service-card,
[data-theme="dark"] .kiblat-card,
[data-theme="dark"] .notif-card,
[data-theme="dark"] .info-banner,
[data-theme="dark"] .payment-guide-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .downline-card,
[data-theme="dark"] .table-card,
[data-theme="dark"] .profile-edit-header,
[data-theme="dark"] .profile-edit-form,
[data-theme="dark"] .summary-box,
[data-theme="dark"] .info-box,
[data-theme="dark"] .protection-card,
[data-theme="dark"] .dp-banner-wrap > div {
    background: var(--theme-bg-card) !important;
    border: 1px solid var(--theme-border-card) !important;
    box-shadow: var(--theme-shadow) !important;
    color: #FFFFFF !important;
}

/* Menu items */
[data-theme="dark"] .menu-item {
    color: #FFFFFF !important;
    border-bottom: 1px solid var(--theme-border) !important;
}

[data-theme="dark"] .menu-item:hover,
[data-theme="dark"] .menu-item:active {
    background-color: var(--theme-bg-card-subtle) !important;
}

[data-theme="dark"] .menu-icon {
    background-color: #151E2E !important;
}

[data-theme="dark"] .menu-text {
    color: #FFFFFF !important;
}

[data-theme="dark"] .menu-item i.fa-chevron-right,
[data-theme="dark"] .menu-item i.ri-arrow-right-s-line {
    color: #64748B !important;
}

/* Grid & Squircle Icons in Dark Mode */
[data-theme="dark"] .squircle-icon {
    background-color: #151E2E !important;
    border: 1px solid #334155 !important;
}

[data-theme="dark"] .dp-grid-item:active .squircle-icon {
    background-color: #334155 !important;
}

/* Wallet Card Action Icons & Labels */
[data-theme="dark"] .wallet-menu i {
    color: #38BDF8 !important;
}

[data-theme="dark"] .wallet-menu span {
    color: #FFFFFF !important;
}

[data-theme="dark"] .wallet-top {
    border-bottom-color: #334155 !important;
}

/* Card Outline */
[data-theme="dark"] .dp-card-outline {
    background-color: var(--theme-bg-card) !important;
    border-color: #38BDF8 !important;
}

[data-theme="dark"] .dp-card-outline .card-icon {
    background-color: rgba(56, 189, 248, 0.15) !important;
    border-color: #38BDF8 !important;
    color: #38BDF8 !important;
}

/* Protection Card */
[data-theme="dark"] .protection-bottom {
    background: #151E2E !important;
    border: 1px solid #334155 !important;
    color: #E2E8F0 !important;
}

/* Inputs & Form Controls */
[data-theme="dark"] input:not([type="submit"]):not([type="button"]):not([type="radio"]):not([type="checkbox"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .form-control,
[data-theme="dark"] .phone-input,
[data-theme="dark"] .id-input,
[data-theme="dark"] .search-input {
    background-color: var(--theme-bg-input) !important;
    color: #FFFFFF !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .phone-input::placeholder,
[data-theme="dark"] .id-input::placeholder,
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #64748B !important;
}

[data-theme="dark"] .dp-input-group,
[data-theme="dark"] .input-group-custom {
    background-color: var(--theme-bg-input) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] .dp-input-group input {
    background: transparent !important;
    color: #FFFFFF !important;
}

/* Fast nominal buttons / pills */
[data-theme="dark"] .nominal-btn,
[data-theme="dark"] .fast-nominal-btn,
[data-theme="dark"] .quick-amount-btn {
    background: var(--theme-bg-card-subtle) !important;
    border: 1px solid var(--theme-border) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .nominal-btn.active,
[data-theme="dark"] .fast-nominal-btn.active,
[data-theme="dark"] .quick-amount-btn.active {
    background: rgba(56, 189, 248, 0.18) !important;
    border-color: var(--theme-accent) !important;
    color: var(--theme-accent) !important;
}

/* Bottom Navigation */
[data-theme="dark"] .dp-bottom-nav {
    background-color: var(--theme-bg-nav) !important;
    border-top: 1px solid var(--theme-border) !important;
    box-shadow: var(--theme-shadow-nav) !important;
}

[data-theme="dark"] .nav-item {
    color: #94A3B8 !important;
}

[data-theme="dark"] .nav-item span {
    color: #94A3B8 !important;
}

[data-theme="dark"] .nav-item.active {
    color: #38BDF8 !important;
}

[data-theme="dark"] .nav-item.active span {
    color: #FFFFFF !important;
    font-weight: 800 !important;
}

[data-theme="dark"] .nav-item.active::after {
    background-color: #38BDF8 !important;
}

/* Badges & Pills */
[data-theme="dark"] .member-badge {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #38BDF8 !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

[data-theme="dark"] .wallet-qr-btn {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #38BDF8 !important;
    border-color: #38BDF8 !important;
}

/* Logout Button */
[data-theme="dark"] .btn-logout {
    background-color: rgba(239, 68, 68, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
    color: #F87171 !important;
}

[data-theme="dark"] .btn-logout:active {
    background-color: rgba(239, 68, 68, 0.2) !important;
}

/* Filter chips & tabs */
[data-theme="dark"] .filter-chip,
[data-theme="dark"] .tab-item,
[data-theme="dark"] .category-tab {
    background-color: var(--theme-bg-card-subtle) !important;
    border-color: var(--theme-border) !important;
    color: #CBD5E1 !important;
}

[data-theme="dark"] .filter-chip.active,
[data-theme="dark"] .tab-item.active,
[data-theme="dark"] .category-tab.active {
    background-color: var(--theme-accent) !important;
    color: #0F172A !important;
    border-color: var(--theme-accent) !important;
}

/* Tables & Lists */
[data-theme="dark"] table th {
    background-color: var(--theme-bg-card-subtle) !important;
    color: #94A3B8 !important;
    border-bottom-color: var(--theme-border) !important;
}

[data-theme="dark"] table td {
    border-bottom-color: var(--theme-border) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] table tr:hover td {
    background-color: var(--theme-bg-card-subtle) !important;
}

/* Alerts & Toasts */
[data-theme="dark"] .alert-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
    color: #34D399 !important;
}

[data-theme="dark"] .alert-error,
[data-theme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #F87171 !important;
}

[data-theme="dark"] .toast-container,
[data-theme="dark"] #app-toast {
    background: #1E293B !important;
    color: #FFFFFF !important;
    border: 1px solid #334155 !important;
    border-left: 4px solid #38BDF8 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .toast-title {
    color: #FFFFFF !important;
}

[data-theme="dark"] .toast-message {
    color: #CBD5E1 !important;
}

[data-theme="dark"] .toast-icon {
    background: rgba(56, 189, 248, 0.15) !important;
    color: #38BDF8 !important;
}

[data-theme="dark"] .toast-close {
    color: #CBD5E1 !important;
}

/* Modals & Popups */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .popup-content,
[data-theme="dark"] .sheet-content {
    background-color: var(--theme-bg-card) !important;
    border-color: var(--theme-border) !important;
    color: #FFFFFF !important;
}

/* QR Code Display Container */
[data-theme="dark"] .qr-container,
[data-theme="dark"] .qr-image-wrapper,
[data-theme="dark"] #qrcode,
[data-theme="dark"] .qr-box {
    background-color: #FFFFFF !important;
    padding: 12px !important;
    border-radius: 16px !important;
    display: inline-block !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
}

/* Admin Specific Dark Overrides */
[data-theme="dark"] .sidebar {
    background: #111827 !important;
    border-right: 1px solid #1F2937 !important;
}

[data-theme="dark"] .sidebar-brand h2,
[data-theme="dark"] .profile-info .greeting {
    color: #FFFFFF !important;
}

[data-theme="dark"] .nav-item {
    color: #94A3B8 !important;
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .nav-item.active {
    background: rgba(56, 189, 248, 0.15) !important;
    color: #38BDF8 !important;
    border-right: 4px solid #38BDF8 !important;
}

[data-theme="dark"] .nav-item i {
    color: #94A3B8 !important;
}

[data-theme="dark"] .nav-item.active i {
    color: #38BDF8 !important;
}

[data-theme="dark"] .mobile-topbar {
    background: #111827 !important;
    border-bottom: 1px solid #1F2937 !important;
}

[data-theme="dark"] .hamburger-btn {
    color: #FFFFFF !important;
}

/* Theme Pill Badge */
.theme-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    background: #EFF6FF;
    color: #2563EB;
    border: 1px solid #DBEAFE;
    transition: all 0.2s ease;
}

[data-theme="dark"] .theme-pill-badge {
    background: rgba(56, 189, 248, 0.15) !important;
    color: #38BDF8 !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

/* Quick Toggle Header Button */
.theme-quick-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.theme-quick-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.theme-quick-btn:active {
    transform: scale(0.92);
}

/* ---------------- Theme Selection Modal / Bottom Sheet ---------------- */
.theme-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.theme-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.theme-modal-sheet {
    width: 100%;
    max-width: 480px;
    background: #FFFFFF;
    border-radius: 28px 28px 0 0;
    padding: 20px 24px calc(24px + env(safe-area-inset-bottom)) 24px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

[data-theme="dark"] .theme-modal-sheet {
    background: #1E293B;
    border-top: 1px solid #334155;
    color: #FFFFFF;
}

.theme-modal-backdrop.active .theme-modal-sheet {
    transform: translateY(0);
}

.theme-sheet-handle {
    width: 40px;
    height: 4px;
    background: #CBD5E1;
    border-radius: 4px;
    margin: 0 auto 16px auto;
}

[data-theme="dark"] .theme-sheet-handle {
    background: #475569;
}

.theme-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.theme-sheet-header h3 {
    font-size: 17px;
    font-weight: 800;
    color: #0F172A;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

[data-theme="dark"] .theme-sheet-header h3 {
    color: #FFFFFF !important;
}

.theme-sheet-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F1F5F9;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748B;
    font-size: 18px;
    cursor: pointer;
    transition: 0.2s;
}

[data-theme="dark"] .theme-sheet-close {
    background: #334155;
    color: #CBD5E1;
}

.theme-sheet-close:active {
    transform: scale(0.9);
}

.theme-sheet-sub {
    font-size: 12px;
    color: #64748B;
    margin-bottom: 20px;
    font-weight: 500;
    line-height: 1.5;
}

[data-theme="dark"] .theme-sheet-sub {
    color: #CBD5E1 !important;
}

.theme-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.theme-option-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 16px;
    border: 2px solid #E2E8F0;
    background: #F8FAFC;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .theme-option-card {
    border-color: #334155;
    background: #182234;
}

.theme-option-card:active {
    transform: scale(0.98);
}

.theme-option-card.active {
    border-color: #0F52BA;
    background: #EFF6FF;
    box-shadow: 0 4px 14px rgba(15, 82, 186, 0.1);
}

[data-theme="dark"] .theme-option-card.active {
    border-color: #38BDF8;
    background: rgba(56, 189, 248, 0.12);
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.15);
}

.theme-option-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-option-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
}

.theme-opt-light .theme-option-icon {
    background: #FEF3C7;
    color: #D97706;
}

.theme-opt-dark .theme-option-icon {
    background: #312E81;
    color: #A5B4FC;
}

.theme-opt-system .theme-option-icon {
    background: #E0E7FF;
    color: #4F46E5;
}

[data-theme="dark"] .theme-opt-system .theme-option-icon {
    background: #2E3856;
    color: #818CF8;
}

.theme-option-info h4 {
    font-size: 14px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 2px;
}

[data-theme="dark"] .theme-option-info h4 {
    color: #FFFFFF !important;
}

.theme-option-info p {
    font-size: 11px;
    color: #64748B;
    font-weight: 500;
    margin: 0;
}

[data-theme="dark"] .theme-option-info p {
    color: #CBD5E1 !important;
}

.theme-radio-indicator {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #CBD5E1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

[data-theme="dark"] .theme-radio-indicator {
    border-color: #475569;
}

.theme-option-card.active .theme-radio-indicator {
    border-color: #0F52BA;
    background: #0F52BA;
}

[data-theme="dark"] .theme-option-card.active .theme-radio-indicator {
    border-color: #38BDF8;
    background: #38BDF8;
}

.theme-radio-indicator i {
    color: white;
    font-size: 12px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .theme-option-card.active .theme-radio-indicator i {
    color: #0F172A;
}

.theme-option-card.active .theme-radio-indicator i {
    opacity: 1;
    transform: scale(1);
}
