/* theme.css — تمِ روز/شبِ یکپارچه برای همه‌ی صفحات.
   همه‌ی قوانینِ دارک زیر html[data-theme="dark"] هستند تا حالتِ روز کاملاً دست‌نخورده بماند.
   اکسنتِ بنفش (#667eea/#764ba2) در هر دو تم ثابت می‌ماند. */

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

/* توجه: overflow-x:hidden روی html/body عمداً گذاشته نشده چون position:sticky هدر را می‌شکند. */

/* گذارِ نرمِ تغییر تم */
html[data-theme="dark"] body,
html[data-theme="dark"] .main-header,
html[data-theme="dark"] .card,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ── پایه ── */
html[data-theme="dark"] { background: #0f172a; }
html[data-theme="dark"] body {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}

/* پس‌زمینه‌های روشنِ inline → تیره */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background:#f8f9fa"],
html[data-theme="dark"] [style*="background: #f8f9fa"],
html[data-theme="dark"] [style*="background:#f5f5f5"],
html[data-theme="dark"] [style*="background: #f5f5f5"],
html[data-theme="dark"] [style*="background:#f0f0f0"],
html[data-theme="dark"] [style*="background: #f0f0f0"],
html[data-theme="dark"] [style*="background:#f8f9ff"],
html[data-theme="dark"] [style*="background: #f8f9ff"],
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"] {
    background: #1e293b !important;
}

/* متن‌های تیره‌ی inline → روشن */
html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color: #333"],
html[data-theme="dark"] [style*="color:#222"],
html[data-theme="dark"] [style*="color: #222"],
html[data-theme="dark"] [style*="color:#000"],
html[data-theme="dark"] [style*="color: #000"],
html[data-theme="dark"] [style*="color:#1e293b"],
html[data-theme="dark"] [style*="color: #1e293b"],
html[data-theme="dark"] [style*="color:#212529"],
html[data-theme="dark"] [style*="color: #212529"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] [style*="color:#666"],
html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #64748b"],
html[data-theme="dark"] [style*="color:#495057"],
html[data-theme="dark"] [style*="color: #495057"],
html[data-theme="dark"] [style*="color:#6c757d"],
html[data-theme="dark"] [style*="color: #6c757d"] {
    color: #94a3b8 !important;
}

/* ── کارت‌ها و ظرف‌های رایج (کلاس‌محور) ── */
html[data-theme="dark"] .card,
html[data-theme="dark"] .box,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .container-box,
html[data-theme="dark"] .content-box,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .section,
html[data-theme="dark"] [class*="card"],
html[data-theme="dark"] [class*="-box"] {
    background: #1e293b !important;
    color: #e2e8f0;
    border-color: #334155 !important;
}

/* ── کلاس‌های واقعیِ صفحات که پس‌زمینه‌ی روشن دارند (استخراج‌شده از خودِ تمپلیت‌ها) ── */
html[data-theme="dark"] .about-container,
html[data-theme="dark"] .actions-bar,
html[data-theme="dark"] .amount-info,
html[data-theme="dark"] .benefit-item,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .card-section,
html[data-theme="dark"] .container,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .feature-badge,
html[data-theme="dark"] .feature-card,
html[data-theme="dark"] .filter-tab,
html[data-theme="dark"] .filter-tabs,
html[data-theme="dark"] .filters,
html[data-theme="dark"] .footer-terms-card,
html[data-theme="dark"] .footer-terms-preview,
html[data-theme="dark"] .info-item,
html[data-theme="dark"] .item-row,
html[data-theme="dark"] .login-container,
html[data-theme="dark"] .logo-preview-box,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .packing-details,
html[data-theme="dark"] .payment-item,
html[data-theme="dark"] .payment-method-btn,
html[data-theme="dark"] .recent-section,
html[data-theme="dark"] .stat-item,
html[data-theme="dark"] .stats-section {
    background: #1e293b !important;
    color: #e2e8f0;
    border-color: #334155 !important;
}
/* تبِ فیلترِ فعال، اکسنت را نگه دارد */
html[data-theme="dark"] .filter-tab.active,
html[data-theme="dark"] .payment-method-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
    border-color: transparent !important;
}

/* ── هدرِ مشترک ── */
html[data-theme="dark"] .main-header {
    background: #1e293b !important;
    border-bottom-color: #334155 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
html[data-theme="dark"] .logo { color: #f1f5f9 !important; }
html[data-theme="dark"] .nav-menu a,
html[data-theme="dark"] .nav-menu button { color: #cbd5e1; }
html[data-theme="dark"] .nav-menu a:hover,
html[data-theme="dark"] .nav-menu button:hover {
    color: #a5b4fc;
    background: rgba(129,140,248,0.12);
}
html[data-theme="dark"] .user-info { background: #334155; color: #e2e8f0; }
html[data-theme="dark"] .divider { background: #334155; }
html[data-theme="dark"] .mobile-menu-toggle { color: #cbd5e1; }
html[data-theme="dark"] .btn-primary { color: #fff !important; }

/* ── فرم‌ها ── */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #64748b; }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: #818cf8 !important;
    outline-color: #818cf8;
}
html[data-theme="dark"] label { color: #cbd5e1; }

/* ── جدول‌ها ── */
html[data-theme="dark"] table { color: #e2e8f0; }
html[data-theme="dark"] th {
    background: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] td { border-color: #334155 !important; }
html[data-theme="dark"] tr:nth-child(even) td { background: rgba(148,163,184,0.06); }
html[data-theme="dark"] tbody tr:hover td { background: rgba(129,140,248,0.08); }

/* جدول‌های عریض روی موبایل اسکرول شوند نه اینکه صفحه را بشکنند */
.table-responsive, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── متن‌های کمکی و لینک ── */
html[data-theme="dark"] a { color: #a5b4fc; }
html[data-theme="dark"] .muted,
html[data-theme="dark"] small,
html[data-theme="dark"] .text-muted { color: #94a3b8 !important; }
html[data-theme="dark"] hr { border-color: #334155; }

/* ── دکمه‌ی تغییر تم (شناور، برای صفحاتِ بدونِ هدر) ── */
.theme-fab {
    position: fixed;
    left: 16px;
    bottom: 16px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(102,126,234,0.4);
    z-index: 2000;
    transition: transform .2s ease;
}
.theme-fab:hover { transform: translateY(-2px) scale(1.05); }
.theme-fab:active { transform: scale(0.95); }

/* دکمه‌ی تم داخل هدر */
.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: rgba(102,126,234,0.10);
    color: #667eea;
    font-size: 18px;
    transition: background .2s ease, transform .2s ease;
}
.theme-btn:hover { background: rgba(102,126,234,0.18); transform: translateY(-1px); }
.theme-btn:active { transform: scale(0.94); }
html[data-theme="dark"] .theme-btn { background: rgba(129,140,248,0.15); color: #c7d2fe; }
