/* ============================================================
   عطاچوب — تم تاریک (Dark mode)
   با گذاشتن data-theme="dark" روی <html> فعال می‌شود.
   همه‌چیز فقط در همین فایل است؛ style.css دست‌نخورده می‌ماند.
   ============================================================ */

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

    --bg:             #12162a;
    --primary:        #4d6ee6;
    --primary-dark:   #9db2f7;   /* در تم تاریک فقط به‌عنوان رنگ متن روشن استفاده می‌شود */
    --primary-light:  #7f9bf5;
    --text:           #e6e9f2;
    --muted:          #9aa3b8;
    --danger:         #ef5a5f;
    --danger-dark:    #ff8a8e;
    --success:        #34c26b;

    --glass-bg:        rgba(34, 40, 66, 0.55);
    --glass-bg-strong: rgba(30, 36, 60, 0.78);
    --glass-border:    rgba(255, 255, 255, 0.10);
    --glass-shadow:    0 8px 32px rgba(0, 0, 0, 0.40);

    /* مقادیر داخلی تم تاریک (سطح‌های نیمه‌شفاف) */
    --d-field:      rgba(14, 18, 36, .62);
    --d-field-hov:  rgba(14, 18, 36, .85);
    --d-surf-1:     rgba(255,255,255,.04);
    --d-surf-2:     rgba(255,255,255,.07);
    --d-surf-3:     rgba(255,255,255,.11);
    --d-solid:      #1b2038;
    --d-line:       rgba(255,255,255,.12);
    --d-line-soft:  rgba(255,255,255,.07);
}

html[data-theme="dark"] body{
    background:
        radial-gradient(circle at 15% 10%, #1e2a55 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, #1a2348 0%, transparent 40%),
        radial-gradient(circle at 50% 100%, #182046 0%, transparent 55%),
        linear-gradient(160deg, #10142a 0%, #0b0e1d 100%);
    background-attachment: fixed;
}

/* ---------- متن‌های پیش‌فرض ---------- */
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] button{ color: var(--text); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{ color: rgba(154,163,184,.7); }
html[data-theme="dark"] select option{ background: #1b2038; color: var(--text); }

/* ---------- لوگو و تصاویر ---------- */
html[data-theme="dark"] .topbar img[src*="logo"]{ filter: brightness(1.08) drop-shadow(0 0 6px rgba(255,255,255,.18)); }

/* ---------- ورودی‌ها و فیلدها ---------- */
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .glass-select-box,
html[data-theme="dark"] .se-line-price, html[data-theme="dark"] .pe-line-price,
html[data-theme="dark"] .table-toolbar input,
html[data-theme="dark"] .cheque-image-field input[type="file"],
html[data-theme="dark"] .higloss-add-row input,
html[data-theme="dark"] #cff-call-minutes,
html[data-theme="dark"] #cff-notes,
html[data-theme="dark"] .cfr-sort-wrap select,
html[data-theme="dark"] .bank-inline input,
html[data-theme="dark"] .bank-inline input.bank-in,
html[data-theme="dark"] table.ct-table td input[type="text"],
html[data-theme="dark"] .fu-ta,
html[data-theme="dark"] #sms-customer-text, html[data-theme="dark"] #sms-invoice-text,
html[data-theme="dark"] #sms-cp-text, html[data-theme="dark"] #bulk-text{
    background-color: var(--d-field) !important;
    border-color: var(--d-line) !important;
    color: var(--text);
}
html[data-theme="dark"] .field select:hover,
html[data-theme="dark"] .glass-select-box:hover{ background-color: var(--d-field-hov) !important; }
html[data-theme="dark"] .higloss-brand-row input[type="text"]:focus{ background: var(--d-field-hov); }
html[data-theme="dark"] table.ct-table td input[type="text"]:disabled{ background: var(--d-surf-2) !important; }
html[data-theme="dark"] .ct-head .field input[readonly],
html[data-theme="dark"] .cp-table input.cp-date-locked,
html[data-theme="dark"] .fu-ta.fu-locked { background: var(--d-surf-2) !important; }

html[data-theme="dark"] select{ background-color: rgba(255,255,255,.09); }
html[data-theme="dark"] select:hover{ background-color: rgba(255,255,255,.15); }

html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .field textarea:focus,
html[data-theme="dark"] .field select:focus,
html[data-theme="dark"] .glass-select-box:focus,
html[data-theme="dark"] .table-toolbar input:focus{ box-shadow: 0 0 0 3px rgba(109,139,240,.28); }

/* چک‌باکس‌ها */
html[data-theme="dark"] table.ct-table input[type="checkbox"],
html[data-theme="dark"] input.row-pick, html[data-theme="dark"] input.pick-all{
    background: var(--d-field) !important;
    border-color: rgba(255,255,255,.3) !important;
}
html[data-theme="dark"] table.ct-table input[type="checkbox"]:checked,
html[data-theme="dark"] input.row-pick:checked, html[data-theme="dark"] input.pick-all:checked{
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}

/* ---------- دکمه‌ها ---------- */
html[data-theme="dark"] .btn-ghost{ background: rgba(255,255,255,.09); color: var(--text); }
html[data-theme="dark"] .btn-ghost:hover{ background: rgba(255,255,255,.16); }
html[data-theme="dark"] .nav-btn:hover{ background: rgba(109,139,240,.14); }
html[data-theme="dark"] .nav-btn .badge{ background: rgba(255,255,255,.12); }
html[data-theme="dark"] .return-badge{ background: #2a2030; }
html[data-theme="dark"] button.btn-glass-add{
    border-color: rgba(109,139,240,.4);
    background: linear-gradient(135deg, rgba(77,110,230,.28), rgba(109,139,240,.16));
    color: var(--text);
}
html[data-theme="dark"] button.btn-glass-add:hover{
    background: linear-gradient(135deg, rgba(77,110,230,.42), rgba(109,139,240,.26));
}
html[data-theme="dark"] .btn.btn-saved-forms{ color: #6fe0a9; background: linear-gradient(180deg, rgba(76,196,143,.22), rgba(34,160,107,.14)); }
html[data-theme="dark"] .btn.btn-saved-forms:hover{ background: linear-gradient(180deg, rgba(76,196,143,.34), rgba(34,160,107,.24)); }
html[data-theme="dark"] .cf-customer-hint.is-active{ color: #6fe0a9; }

/* ---------- لیست‌های بازشو / منوها ---------- */
html[data-theme="dark"] .glass-select-panel,
html[data-theme="dark"] .export-menu-dropdown,
html[data-theme="dark"] .pn-ctx-menu {
    background: #1b2038;
    border-color: var(--d-line);
    box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
html[data-theme="dark"] .glass-select-option:hover,
html[data-theme="dark"] .suggest-item:hover, html[data-theme="dark"] .suggest-item.highlighted,
html[data-theme="dark"] .export-menu-dropdown button:hover,
html[data-theme="dark"] .customer-autocomplete-item:hover,
html[data-theme="dark"] .customer-autocomplete-item.active,
html[data-theme="dark"] .pn-ctx-item:hover{ background: rgba(109,139,240,.20); }
html[data-theme="dark"] .glass-select-option.active{ background: rgba(109,139,240,.28); }
html[data-theme="dark"] .suggest-item,
html[data-theme="dark"] .customer-autocomplete-item,
html[data-theme="dark"] .pn-ctx-react-row{ border-bottom-color: var(--d-line-soft); }

/* ---------- جدول‌ها ---------- */
html[data-theme="dark"] table.data-table{ background: rgba(255,255,255,.03); }
html[data-theme="dark"] table.data-table thead th{ background: linear-gradient(135deg, #3b57c4, #2c438f); }
html[data-theme="dark"] table.data-table tbody td{
    border-left-color: var(--d-line-soft);
    border-bottom-color: var(--d-line-soft);
}
html[data-theme="dark"] table.data-table tbody tr:nth-child(even){ background: rgba(109,139,240,.07); }
html[data-theme="dark"] table.data-table tbody tr:hover{ background: rgba(109,139,240,.16); }
html[data-theme="dark"] table.data-table tbody tr.selected{ background: rgba(109,139,240,.28) !important; }
html[data-theme="dark"] tr.row-picked td{ background: rgba(109,139,240,.14); }
html[data-theme="dark"] .pick-count{ background: rgba(109,139,240,.18); color: var(--primary-dark); }
html[data-theme="dark"] .table-wrap{ border-color: var(--d-line-soft); }
html[data-theme="dark"] table.ct-table tr.ct-returned td{ background: rgba(239,90,95,.14); }
html[data-theme="dark"] table.ct-table tr.ct-late-row td{ background: rgba(239,90,95,.16); }

/* ---------- مودال ---------- */
html[data-theme="dark"] .modal-overlay{ background: rgba(4, 6, 16, 0.6); }
html[data-theme="dark"] .modal-box{ box-shadow: 0 20px 50px rgba(0,0,0,.6); }

/* ---------- نشان‌ها و رنگ‌های وضعیت ---------- */
html[data-theme="dark"] .badge-ok{ background: rgba(52,194,107,.18); }
html[data-theme="dark"] .badge-warn{ background: rgba(239,90,95,.2); }
html[data-theme="dark"] .badge-info{ background: rgba(109,139,240,.2); }
html[data-theme="dark"] .level-badge.level-overdue{ background: rgba(239,90,95,.2); }
html[data-theme="dark"] .level-badge.level-today{ background: rgba(245,158,11,.2); color: #fbbf5c; }
html[data-theme="dark"] .level-badge.level-soon{ background: rgba(109,139,240,.2); }
html[data-theme="dark"] .notif-item.level-today{ border-inline-start-color: #f59e0b; }
html[data-theme="dark"] .notif-item.level-today .notif-item-title{ color: #fbbf5c; }
html[data-theme="dark"] .note-box{ background: rgba(239,90,95,.12); border-color: rgba(239,90,95,.4); }
html[data-theme="dark"] .ct-late-note{ color: #ff8a8e; }
html[data-theme="dark"] .ct-late-legend{ background: rgba(239,90,95,.12); }
html[data-theme="dark"] .ct-log-item{ background: var(--d-surf-2); }
html[data-theme="dark"] .ct-log-item.bad{ background: rgba(239,90,95,.14); }
html[data-theme="dark"] .cff-prev-dir{ background: rgba(255,255,255,.1); }
html[data-theme="dark"] .cff-prev-dir.in{ background: rgba(31,157,138,.25); color: #6fe0c3; }
html[data-theme="dark"] .cff-prev-dir.out{ background: rgba(217,130,43,.25); color: #f5b46a; }
html[data-theme="dark"] .cff-prev-dir.fail{ background: rgba(200,50,50,.28); color: #ff9a9a; }
html[data-theme="dark"] .cff-mark { background: rgba(255,214,0,.35); color: #fff; }
html[data-theme="dark"] .online-user-dot{ background: #4b5470; }

/* ---------- کارت‌ها و پنل‌ها (سطح‌های سفیدِ نیمه‌شفاف) ---------- */
html[data-theme="dark"] .notif-item,
html[data-theme="dark"] .perm-item,
html[data-theme="dark"] .higloss-panel,
html[data-theme="dark"] .higloss-brand-row,
html[data-theme="dark"] .cfr-summary-card,
html[data-theme="dark"] .cfr-chart-card,
html[data-theme="dark"] .cfr-cat-chip,
html[data-theme="dark"] .cf-form-box,
html[data-theme="dark"] .cf-form-row.cf-form-notes,
html[data-theme="dark"] .cf-folder-head,
html[data-theme="dark"] .call-direction-option,
html[data-theme="dark"] .pn-target-item,
html[data-theme="dark"] .cff-prev-item,
html[data-theme="dark"] .cff-hit,
html[data-theme="dark"] .bank-cat,
html[data-theme="dark"] .pf-image-box,
html[data-theme="dark"] .pn-pending-item,
html[data-theme="dark"] .nav-order-item,
html[data-theme="dark"] .ct-role-btn {
    background: var(--d-surf-2);
    border-color: var(--d-line);
}
html[data-theme="dark"] .ct-sheet{ background: var(--d-surf-2); border-color: var(--d-line); }
html[data-theme="dark"] .bank-card{ background: #1d2340; border-color: var(--d-line); box-shadow: 0 2px 10px rgba(0,0,0,.35); }
html[data-theme="dark"] .notif-item:hover,
html[data-theme="dark"] .pn-thread-item:hover{ background: var(--d-surf-3); }
html[data-theme="dark"] .cff-float-win,
html[data-theme="dark"] .cff-prev-day{ background: rgba(26,31,54,.96); border-color: var(--d-line); }
html[data-theme="dark"] .cff-float-win{ box-shadow: 0 12px 32px rgba(0,0,0,.6); }
html[data-theme="dark"] .cff-float-head button:hover{ background: rgba(255,255,255,.12); }
html[data-theme="dark"] .cff-rz-br::after,
html[data-theme="dark"] .cff-rz-bl::after{ border-color: rgba(255,255,255,.4); }
html[data-theme="dark"] .cff-kind-tag, html[data-theme="dark"] .cf-brand-chip{ color: var(--primary-dark); }

html[data-theme="dark"] .bank-copy-one{ background: rgba(255,255,255,.06); border-color: var(--d-line); }
html[data-theme="dark"] .bank-card-add { color: var(--primary-dark); }
html[data-theme="dark"] .bank-card-add{ border-color: rgba(109,139,240,.5); }
html[data-theme="dark"] .bank-card-foot{ border-top-color: var(--d-line); }

/* انتخاب‌شده‌ها */
html[data-theme="dark"] .higloss-brand-row.is-checked,
html[data-theme="dark"] .call-direction-option:has(input:checked),
html[data-theme="dark"] .pn-target-item.checked,
html[data-theme="dark"] .cfr-cat-chip:has(input:checked),
html[data-theme="dark"] .pn-thread-item.active,
html[data-theme="dark"] .cf-folder-icon,
html[data-theme="dark"] .cff-float-head{ background: rgba(109,139,240,.2); }
html[data-theme="dark"] .cff-prev-item:hover,
html[data-theme="dark"] .cff-hit:hover,
html[data-theme="dark"] .cf-folder-head:hover,
html[data-theme="dark"] .bank-copy-one:hover,
html[data-theme="dark"] .cfr-col:hover, html[data-theme="dark"] .cfr-col:focus-visible{ background: rgba(109,139,240,.18); }
html[data-theme="dark"] .cfr-col.is-selected{ background: rgba(109,139,240,.28); }
html[data-theme="dark"] .cfr-statement,
html[data-theme="dark"] .call-chat-editing-banner,
html[data-theme="dark"] .product-group-create{ background: rgba(109,139,240,.12); border-color: rgba(109,139,240,.3); }
html[data-theme="dark"] .date-sep-label{ background: rgba(109,139,240,.22); }

/* ---------- نمودارها ---------- */
html[data-theme="dark"] .cfr-gridline{ border-top-color: rgba(255,255,255,.14); }
html[data-theme="dark"] .cfr-gridline.is-base{ border-top-color: rgba(255,255,255,.34); }
html[data-theme="dark"] .cfr-col.is-zero .cfr-bar{ background: rgba(255,255,255,.2); }
html[data-theme="dark"] .cfr-col.is-removed .cfr-bar{ background: repeating-linear-gradient(45deg, #4a5270 0 6px, #5a6385 6px 12px); }
html[data-theme="dark"] .cfr-col.is-selected .cfr-bar{ box-shadow: 0 0 0 2px rgba(255,255,255,.5), 0 0 0 4px var(--cfr-bar); }

/* ---------- چت (تماس / اعلانات) ---------- */
html[data-theme="dark"] .pn-msg-in{ background: rgba(255,255,255,.09); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
html[data-theme="dark"] .pn-msg-in .call-msg-action-btn{ background: rgba(255,255,255,.12); }
html[data-theme="dark"] .pn-msg-in .call-msg-action-btn:hover{ background: rgba(255,255,255,.22); }
html[data-theme="dark"] .pn-msg-in .pn-quote{ background: rgba(109,139,240,.16); }
html[data-theme="dark"] .pn-msg-in .pn-react-chip{ background: rgba(109,139,240,.12); border-color: rgba(109,139,240,.35); }
html[data-theme="dark"] .pn-msg-in .pn-react-chip:hover{ background: rgba(109,139,240,.24); }
html[data-theme="dark"] .pn-msg-in .pn-react-chip.mine{ background: rgba(109,139,240,.32); border-color: rgba(109,139,240,.6); }
html[data-theme="dark"] .pn-msg-in .pn-att-file{ background: rgba(255,255,255,.07); border-color: var(--d-line); }
html[data-theme="dark"] .pn-ctx-react.on{ background: rgba(109,139,240,.25); }
html[data-theme="dark"] .pn-att-img{ background: rgba(255,255,255,.06); }

/* ---------- اسکرول‌بار ---------- */
html[data-theme="dark"] ::-webkit-scrollbar-thumb{ background: rgba(154,163,184,.35); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover{ background: rgba(154,163,184,.6); }

/* ---------- استایل‌های inline داخل index.html ---------- */
html[data-theme="dark"] hr[style]{ border-top-color: var(--d-line) !important; }
html[data-theme="dark"] #sms-preview, html[data-theme="dark"] #sms-invoice-preview,
html[data-theme="dark"] #sms-cp-preview, html[data-theme="dark"] #bulk-preview{ background: rgba(109,139,240,.14) !important; }
html[data-theme="dark"] [style*="#c0392b"]{ color: #ff8a8e !important; }

/* ---------- دکمه‌ی تعویض تم ---------- */
.theme-toggle{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--primary);
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, color .2s ease;
}
.theme-toggle:hover{ transform: rotate(18deg) scale(1.06); background: var(--glass-bg-strong); }
.theme-toggle svg{ width: 18px; height: 18px; display: block; }
.theme-toggle .ico-sun{ display: none; }
html[data-theme="dark"] .theme-toggle{ color: #ffd36b; }
html[data-theme="dark"] .theme-toggle .ico-sun{ display: block; }
html[data-theme="dark"] .theme-toggle .ico-moon{ display: none; }

/* تعویض نرم رنگ‌ها هنگام تغییر تم (فقط لحظه‌ی کلیک) */
html.theme-anim body, html.theme-anim .glass-card, html.theme-anim .topbar,
html.theme-anim .modal-box, html.theme-anim input,
html.theme-anim textarea, html.theme-anim table.data-table {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* چاپ همیشه با تم روشن */
@media print{
    html[data-theme="dark"]{ color-scheme: light; }
}

/* لیست قیمت‌ها */
html[data-theme="dark"] .pl-in{ background: var(--d-surf-2); border-color: var(--d-line); color: inherit; }
html[data-theme="dark"] .pl-in[readonly]{ background: transparent; border-color: transparent; }
html[data-theme="dark"] .pl-table td{ border-bottom-color: var(--d-line); }
html[data-theme="dark"] .pl-group-box{ background: rgba(120,140,255,.14); border-color: var(--d-line); }
html[data-theme="dark"] .pl-group-in{ color: #aebcff; }

/* Fix158 — زبانه‌های پنل اعلان‌ها */
html[data-theme="dark"] .notif-tab{ background: rgba(255,255,255,.06); color: var(--d-text, #e6e9f2); border-color: var(--d-line); }
html[data-theme="dark"] .notif-tab:hover{ background: rgba(255,255,255,.12); }
html[data-theme="dark"] .notif-tab.active{ background: var(--primary); color: #fff; border-color: var(--primary); }
html[data-theme="dark"] .notif-tab-count{ background: rgba(255,255,255,.12); color: #c7d2fe; }
html[data-theme="dark"] .notif-group-collect .notif-group-title{ color: #5eead4; }

/* Fix161 */
html[data-theme="dark"] .ras-remaining.owe .value, html[data-theme="dark"] .ras-remaining.owe .label{ color:#fca5a5; }
html[data-theme="dark"] .ras-remaining.settled .value, html[data-theme="dark"] .ras-remaining.settled .label{ color:#86efac; }
html[data-theme="dark"] .ras-remaining.over .value, html[data-theme="dark"] .ras-remaining.over .label{ color:#a5b4fc; }

/* Fix163 */
html[data-theme="dark"] .cut-tag-system{ color:#fbbf5c; background:rgba(245,158,11,.16); }
html[data-theme="dark"] .cut-tag-physical{ color:#86efac; background:rgba(34,197,94,.14); }

/* Fix166 — موبایل */
@media (max-width: 860px){
    html[data-theme="dark"] #m-menu-btn{ background: rgba(255,255,255,.06); color: var(--d-text, #e6e9f2); border-color: var(--d-line); }
    html[data-theme="dark"] #m-page-title{ color: #a5b4fc; }
    html[data-theme="dark"] .nav{ background: rgba(22,27,48,.96) !important; }
}
@media (max-width: 640px){
    html[data-theme="dark"] table.m-cards tbody tr{ background: rgba(255,255,255,.05) !important; border-color: var(--d-line); }
    html[data-theme="dark"] table.m-cards tbody td{ border-bottom-color: var(--d-line-soft) !important; }
    html[data-theme="dark"] table.m-cards thead th input.col-filter{ background: rgba(255,255,255,.06) !important; color: #e6e9f2 !important; border-color: var(--d-line) !important; }
}

/* Fix175 */
html[data-theme="dark"] .file-pick,
html[data-theme="dark"] .bulk-box input[type="text"],
html[data-theme="dark"] #bulk-text{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: var(--text); }
html[data-theme="dark"] .bulk-list{ background: rgba(255,255,255,.04) !important; border-color: rgba(255,255,255,.1) !important; }
html[data-theme="dark"] .bulk-row{ border-bottom-color: rgba(255,255,255,.06) !important; }

/* Fix176 — زبانه‌ی «سررسید گذشته» زنگوله */
html[data-theme="dark"] .notif-overdue-days{ background: rgba(248,113,113,.18); color: #fca5a5; }
html[data-theme="dark"] .notif-group-overdue_collect .notif-group-title{ color: #fca5a5; }

/* Fix181 */
html[data-theme="dark"] tr.cp-done td{ background: rgba(34,197,94,.10); }
html[data-theme="dark"] tr.cp-done .cp-done-tick span{ color:#4ade80; }

/* Fix182 — ربات پاسخگو */
html[data-theme="dark"] .hb-panel{ background:rgba(23,29,52,.96); border-color:var(--d-line, rgba(255,255,255,.08)); box-shadow:0 24px 60px rgba(0,0,0,.5); }
html[data-theme="dark"] .hb-head, html[data-theme="dark"] .hb-input{ border-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .hb-head-title{ color:var(--d-text, #e6e9f2); }
html[data-theme="dark"] .hb-bot{ background:rgba(255,255,255,.05); color:var(--d-text, #e6e9f2); border-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .hb-topic-title{ color:#a5b8ff; }
html[data-theme="dark"] .hb-chip{ background:rgba(110,140,255,.12); border-color:rgba(110,140,255,.3); color:#c7d2fe; }
html[data-theme="dark"] .hb-chip:hover{ background:rgba(110,140,255,.22); }
html[data-theme="dark"] .hb-perm{ background:rgba(245,158,11,.14); color:#fcd34d; }
html[data-theme="dark"] .hb-maybe{ color:#fbbf5c; }
html[data-theme="dark"] .hb-input textarea{ background:rgba(255,255,255,.05); border-color:rgba(255,255,255,.12); color:var(--d-text, #e6e9f2); }
html[data-theme="dark"] .hb-alts-title, html[data-theme="dark"] .hb-fb, html[data-theme="dark"] .hb-miss-meta{ color:#9aa4bf; }
