/* ============================================================
   UI KIT — کیتِ یکپارچهٔ کنترل‌های سفارشی سایت
   ------------------------------------------------------------
   • انتخاب‌گر سفارشی (select) با پشتیبانی تک/چندانتخابی
   • آپلود فایل با درگ‌اند‌دراپ و پیش‌نمایش
   • انتخاب‌گر ساعت و تاریخ بازشونده درون‌سایت
   • اصلاح جدول‌ها در موبایل (بدون شکستن کلمه)
   • هم‌رنگ‌سازی تگ‌ها و برچسب‌ها در حالت شب
   همهٔ رنگ/شعاع/سایه/انیمیشن از متغیرهای style.css می‌آید.
   ============================================================ */

:root {
    --ui-radius: 12px;
    --ui-radius-sm: 10px;
    --ui-radius-lg: 18px;
    --ui-control-h: 46px;
    --ui-ring: 0 0 0 4px rgba(13, 148, 136, .14);
    --ui-shadow-pop: 0 18px 44px -14px rgba(15, 23, 42, .3), 0 2px 10px rgba(15, 23, 42, .06);
    --ui-ease: cubic-bezier(.16, 1, .3, 1);
    --ui-dur: .2s;
    --ui-border: 1.5px solid var(--border-input, #E5E7EB);
    --ui-chip-bg: rgba(148, 163, 184, .12);
}

[data-theme="dark"] {
    --ui-ring: 0 0 0 4px rgba(45, 212, 191, .18);
    --ui-shadow-pop: 0 22px 52px -14px rgba(0, 0, 0, .72), 0 2px 10px rgba(0, 0, 0, .35);
    --ui-chip-bg: rgba(148, 163, 184, .16);
}

/* ── ۱) امنیت متن: هیچ کلمه‌ای در وسط قطع نشود ── */
body,
p, li, span, td, th, label, div, a, button,
h1, h2, h3, h4, h5, h6,
input, select, textarea {
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

/* جای‌هایی که واقعاً به شکستن امن نیاز دارند (نشانی/کد) */
code, pre, .url-box code, [dir="ltr"].mono, .mono {
    word-break: break-word;
    overflow-wrap: anywhere;
}

h1, h2, h3, h4, h5, h6,
.section-title, .card-title, .welcome-title,
.program-name, .program-title, .hero-featured-title,
.class-banner-name, .class-card-title, .top-name, .item-title {
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
}

.btn, button, .btn-primary, .btn-secondary, .btn-danger, .btn-outline,
input[type="submit"], input[type="button"] {
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
    min-width: 0;
}

/* متن‌های فشرده‌شونده باید اجازهٔ کوچک‌شدن داشته باشند تا کلمه نشکند */
.stat-value, .item-title, .top-info, .program-info, .user-name-sm,
.dashboard-content :is(h1, h2, h3, h4) { min-width: 0; }

/* ── ۲) انتخاب‌گر سفارشی (ui-select) ── */
.ui-select {
    position: relative;
    width: 100%;
    display: block;
    font-family: var(--font-body, inherit);
}

select.ui-native-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.ui-select-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: var(--ui-control-h);
    padding: 10px 14px;
    font-family: inherit;
    font-size: .93rem;
    font-weight: 500;
    line-height: 1.6;
    text-align: right;
    color: var(--text-primary, #374151);
    background: var(--bg-muted, #F9FAFB);
    border: var(--ui-border);
    border-radius: var(--ui-radius);
    cursor: pointer;
    transition: border-color var(--ui-dur) ease, box-shadow var(--ui-dur) ease,
        background var(--ui-dur) ease, transform var(--ui-dur) var(--ui-ease);
}

.ui-select-btn:hover {
    border-color: color-mix(in srgb, var(--color-primary, #0D9488) 45%, transparent);
    background: var(--bg-surface, #fff);
}

.ui-select-btn:focus-visible,
.ui-select.is-open .ui-select-btn {
    outline: none;
    border-color: var(--color-primary, #0D9488);
    background: var(--bg-surface, #fff);
    box-shadow: var(--ui-ring);
}

.ui-select-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-select.is-placeholder .ui-select-value {
    color: var(--text-muted, #9CA3AF);
    font-weight: 400;
}

.ui-select-arrow {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--text-muted, #9CA3AF);
    transition: transform .25s var(--ui-ease), color var(--ui-dur) ease;
}

.ui-select.is-open .ui-select-arrow {
    transform: rotate(180deg);
    color: var(--color-primary, #0D9488);
}

.ui-select-count {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--color-primary, #0D9488);
    background: color-mix(in srgb, var(--color-primary, #0D9488) 12%, transparent);
}

.ui-select-menu[hidden] { display: none !important; }

/* منو در بدنهٔ سند و در بالاترین لایه قرار می‌گیرد تا هرگز زیر
   جدول، کارت، منوی دیگر یا مودال نرود. مکان آن با JS محاسبه می‌شود. */
.ui-select-menu {
    position: fixed;
    z-index: 2147483000;
    top: 0;
    left: 0;
    right: auto;
    max-height: min(300px, 48vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, rgba(229, 231, 235, .6));
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-pop);
    transform-origin: top center;
    animation: ui-pop .18s var(--ui-ease) both;
    scrollbar-width: thin;
}

.ui-select-menu.is-up {
    transform-origin: bottom center;
    animation-name: ui-pop-up;
}

.ui-select-menu::-webkit-scrollbar { width: 8px; }
.ui-select-menu::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #C1C1C1);
    border-radius: 8px;
}

.ui-select-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: var(--ui-radius-sm);
    background: transparent;
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.7;
    text-align: right;
    color: var(--text-primary, #374151);
    cursor: pointer;
    transition: background var(--ui-dur) ease, color var(--ui-dur) ease;
}

.ui-select-opt .ui-select-tick {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    opacity: 0;
    color: var(--color-primary, #0D9488);
    transform: scale(.7);
    transition: opacity var(--ui-dur) ease, transform var(--ui-dur) var(--ui-ease);
}

.ui-select-opt .ui-select-label {
    flex: 1 1 auto;
    min-width: 0;
}

.ui-select-opt:hover,
.ui-select-opt.is-focus {
    background: color-mix(in srgb, var(--color-primary, #0D9488) 9%, transparent);
}

.ui-select-opt[aria-selected="true"] {
    background: color-mix(in srgb, var(--color-primary, #0D9488) 13%, transparent);
    color: var(--color-primary, #0D9488);
    font-weight: 700;
}

.ui-select-opt[aria-selected="true"] .ui-select-tick {
    opacity: 1;
    transform: scale(1);
}

.ui-select-opt[aria-disabled="true"] {
    opacity: .45;
    cursor: not-allowed;
}

.ui-select-empty {
    padding: 12px;
    text-align: center;
    font-size: .85rem;
    color: var(--text-muted, #9CA3AF);
}

.ui-select.is-disabled .ui-select-btn {
    opacity: .6;
    cursor: not-allowed;
}

@keyframes ui-pop {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: none; }
}
@keyframes ui-pop-up {
    from { opacity: 0; transform: translateY(6px) scale(.98); }
    to { opacity: 1; transform: none; }
}

/* چندانتخابی: چک‌باکس سفارشی داخل گزینه */
.ui-select-box {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1.5px solid var(--border-input, #E5E7EB);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all var(--ui-dur) ease;
}

.ui-select-opt[aria-selected="true"] .ui-select-box {
    background: var(--color-primary, #0D9488);
    border-color: var(--color-primary, #0D9488);
}

.ui-select-opt[aria-selected="true"] .ui-select-box svg {
    opacity: 1;
}

.ui-select-box svg {
    width: 12px;
    height: 12px;
    opacity: 0;
}

/* ── ۳) آپلود فایل سفارشی (ui-file) ── */
.ui-file {
    position: relative;
    width: 100%;
}

.ui-file > input[type="file"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
}

.ui-file-zone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 18px;
    font-family: inherit;
    text-align: right;
    cursor: pointer;
    overflow: hidden;
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--color-primary, #0D9488) 5%, transparent),
            transparent 62%),
        var(--bg-muted, #F9FAFB);
    border: 1.5px dashed color-mix(in srgb, var(--color-primary, #0D9488) 34%, var(--border-input, #E5E7EB));
    border-radius: var(--ui-radius-lg);
    transition: border-color var(--ui-dur) ease, box-shadow var(--ui-dur) ease,
        background var(--ui-dur) ease, transform var(--ui-dur) var(--ui-ease);
}

.ui-file-zone::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 20%,
        color-mix(in srgb, var(--color-primary, #0D9488) 14%, transparent) 46%,
        transparent 72%);
    background-size: 220% 100%;
    background-position: 180% 0;
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}

.ui-file-zone:hover,
.ui-file-zone:focus-visible {
    outline: none;
    border-color: var(--color-primary, #0D9488);
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--color-primary, #0D9488) 9%, transparent),
            transparent 66%),
        var(--bg-surface, #fff);
    box-shadow: var(--ui-ring);
    transform: translateY(-1px);
}

.ui-file-zone:hover::after {
    opacity: 1;
    animation: ui-sheen 1.2s ease;
}

.ui-file.is-drag .ui-file-zone {
    border-color: var(--color-primary, #0D9488);
    border-style: solid;
    background: color-mix(in srgb, var(--color-primary, #0D9488) 12%, var(--bg-surface, #fff));
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-primary, #0D9488) 12%, transparent);
    transform: scale(1.01);
}

.ui-file.is-filled .ui-file-zone {
    border-style: solid;
    border-color: color-mix(in srgb, var(--color-primary, #0D9488) 45%, transparent);
    background: var(--bg-surface, #fff);
}

.ui-file-icon {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--color-primary, #0D9488), var(--color-primary-light, #14B8A6));
    box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--color-primary, #0D9488) 85%, transparent);
    transition: transform .3s var(--ui-ease);
}

.ui-file-zone:hover .ui-file-icon {
    transform: translateY(-2px) rotate(-4deg);
}

.ui-file-icon svg { width: 22px; height: 22px; }

.ui-file-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ui-file-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text-primary, #374151);
    line-height: 1.7;
}

.ui-file-hint {
    font-size: .78rem;
    color: var(--text-muted, #9CA3AF);
    line-height: 1.7;
}

.ui-file-action {
    flex: 0 0 auto;
    padding: 8px 16px;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    color: var(--color-primary, #0D9488);
    background: color-mix(in srgb, var(--color-primary, #0D9488) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary, #0D9488) 26%, transparent);
    border-radius: 999px;
    pointer-events: none;
    white-space: nowrap;
}

.ui-file-preview[hidden],
.ui-time-popup[hidden],
.jdate-popup[hidden],
.ui-modal[hidden] { display: none !important; }

.ui-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, rgba(229, 231, 235, .6));
    border-radius: var(--ui-radius);
    animation: ui-pop .22s var(--ui-ease) both;
}

.ui-file-thumb {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--bg-muted, #F9FAFB);
    display: grid;
    place-items: center;
    color: var(--color-primary, #0D9488);
    overflow: hidden;
}

.ui-file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ui-file-meta {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ui-file-name {
    font-size: .84rem;
    font-weight: 700;
    color: var(--text-primary, #374151);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-file-size {
    font-size: .76rem;
    color: var(--text-muted, #9CA3AF);
}

.ui-file-clear {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted, #9CA3AF);
    cursor: pointer;
    transition: all var(--ui-dur) ease;
}

.ui-file-clear:hover {
    color: var(--color-error, #DC2626);
    background: color-mix(in srgb, var(--color-error, #DC2626) 12%, transparent);
}

.ui-file-error {
    margin-top: 8px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--color-error, #DC2626);
}

.ui-file > input[type="file"]:invalid ~ .ui-file-error { display: block; }

@keyframes ui-sheen {
    from { background-position: 180% 0; }
    to { background-position: -60% 0; }
}

/* ── ۴) انتخاب‌گر ساعت سفارشی (ui-time) ── */
.ui-time {
    position: relative;
    display: block;
    width: 100%;
}

.ui-time-input {
    cursor: pointer;
    text-align: center;
    letter-spacing: .5px;
}

.ui-time-popup {
    position: fixed;
    z-index: 10050;
    width: 216px;
    padding: 10px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, rgba(229, 231, 235, .6));
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-pop);
    animation: ui-pop .18s var(--ui-ease) both;
    font-family: var(--font-body, inherit);
}

.ui-time-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ui-time-col {
    max-height: 190px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px;
    border-radius: 10px;
    scrollbar-width: thin;
}

.ui-time-col::-webkit-scrollbar { width: 6px; }
.ui-time-col::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #C1C1C1);
    border-radius: 6px;
}

.ui-time-cell {
    padding: 7px 4px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary, #374151);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--ui-dur) ease, color var(--ui-dur) ease;
}

.ui-time-cell:hover { background: color-mix(in srgb, var(--color-primary, #0D9488) 10%, transparent); }

.ui-time-cell.is-on {
    background: var(--color-primary, #0D9488);
    color: #fff;
}

.ui-time-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 2px 4px 8px;
    border-bottom: 1px dashed var(--border-color, #E5E7EB);
    margin-bottom: 8px;
}

.ui-time-head span {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted, #9CA3AF);
}

.ui-time-now {
    padding: 4px 10px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-primary, #0D9488);
    background: color-mix(in srgb, var(--color-primary, #0D9488) 10%, transparent);
    border: none;
    border-radius: 999px;
    cursor: pointer;
}

/* ── ۵) جدول‌های ریسپانسیو ── */
.table-scroll {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--ui-radius);
    scrollbar-width: thin;
}

.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #C1C1C1);
    border-radius: 8px;
}

.table-scroll > table { margin-bottom: 0; }

table th,
table td {
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
    vertical-align: middle;
}

@media (max-width: 900px) {
    .table-scroll {
        /* سایهٔ ظریف برای اینکه معلوم شود جدول قابل کشیدن است */
        background:
            linear-gradient(to left, var(--bg-card, #fff) 30%, transparent) left center / 28px 100% no-repeat,
            linear-gradient(to right, var(--bg-card, #fff) 30%, transparent) right center / 28px 100% no-repeat,
            radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .14), transparent) left center / 14px 100% no-repeat,
            radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .14), transparent) right center / 14px 100% no-repeat;
        background-attachment: local, local, scroll, scroll;
    }

    .table-scroll > table,
    .table-responsive > table {
        /* عرض هر ستون = عرض بزرگ‌ترین محتوای ممکن؛ نه فشرده‌سازی و نه شکستن کلمه */
        width: max-content;
        min-width: 100%;
    }

    .table-scroll > table th,
    .table-scroll > table td,
    .table-responsive > table th,
    .table-responsive > table td {
        white-space: normal;
        overflow-wrap: normal;
        word-break: normal;
    }

    /* متن‌های خیلی بلند فقط از محل فاصله به خط بعد می‌روند (بدون قطع کلمه) */
    .table-scroll > table td,
    .table-responsive > table td {
        max-width: 34ch;
    }

    .table-scroll > table td.wrap-any,
    .table-scroll > table th.wrap-any {
        max-width: 26ch;
        overflow-wrap: break-word;
    }
}

/* ── ۶) اصلاح حالت شب برای تگ‌ها و برچسب‌ها ── */
/* تگ‌های درون‌خطی سایت (نوع برنامه، وضعیت، نقش، سطح، گروه…) */
[data-theme="dark"] :is(.tag, .badge, .type-badge, .status-badge, .role-badge,
    .media-badge, .q-type-badge, .pi-badge, .pg-tag, .ct-chip, .item-badge,
    .chip, .badge-pending, .badge-completed, .badge-type, .badge-qt) {
    border-color: var(--border-color, rgba(148, 163, 184, .2)) !important;
    box-shadow: none !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag, .badge, .badge-type,
    .badge-qt, .role-badge, .media-badge, .q-type-badge, .pi-badge, .ct-chip) {
    background: var(--ui-chip-bg) !important;
    color: var(--text-secondary, #94A3B8) !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag, .role-badge, .q-type-badge).course,
[data-theme="dark"] :is(.type-badge, .status-badge, .tag).active,
[data-theme="dark"] .badge-completed,
[data-theme="dark"] :is(.type-badge, .status-badge).completed {
    background: rgba(52, 211, 153, .14) !important;
    color: #6EE7B7 !important;
    border-color: rgba(52, 211, 153, .28) !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag).camp,
[data-theme="dark"] .badge-pending,
[data-theme="dark"] :is(.type-badge, .status-badge).wait {
    background: rgba(251, 191, 36, .14) !important;
    color: #FCD34D !important;
    border-color: rgba(251, 191, 36, .28) !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag).annual,
[data-theme="dark"] :is(.type-badge, .status-badge).badge-info {
    background: rgba(96, 165, 250, .14) !important;
    color: #93C5FD !important;
    border-color: rgba(96, 165, 250, .28) !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag).event {
    background: rgba(167, 139, 250, .16) !important;
    color: #C4B5FD !important;
    border-color: rgba(167, 139, 250, .3) !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag).workshop {
    background: rgba(244, 114, 182, .16) !important;
    color: #F9A8D4 !important;
    border-color: rgba(244, 114, 182, .3) !important;
}

[data-theme="dark"] :is(.type-badge, .status-badge, .tag).inactive,
[data-theme="dark"] .chip {
    background: var(--ui-chip-bg) !important;
    color: var(--text-secondary, #94A3B8) !important;
}

/* برچسب‌هایی که با رنگ درون‌خطی (inline style) رنگ گرفته‌اند */
[data-theme="dark"] [style*="background:#ECFDF5"], [data-theme="dark"] [style*="background: #ECFDF5"],
[data-theme="dark"] [style*="background:#DCFCE7"], [data-theme="dark"] [style*="background: #DCFCE7"],
[data-theme="dark"] [style*="background:#D1FAE5"], [data-theme="dark"] [style*="background: #D1FAE5"],
[data-theme="dark"] [style*="background:#CCFBF1"], [data-theme="dark"] [style*="background: #CCFBF1"],
[data-theme="dark"] [style*="background:#F0FDF4"], [data-theme="dark"] [style*="background: #F0FDF4"] {
    background: rgba(52, 211, 153, .14) !important;
    border-color: rgba(52, 211, 153, .28) !important;
}

[data-theme="dark"] [style*="background:#FEF3C7"], [data-theme="dark"] [style*="background: #FEF3C7"],
[data-theme="dark"] [style*="background:#FDE68A"], [data-theme="dark"] [style*="background: #FDE68A"],
[data-theme="dark"] [style*="background:#FEF9C3"], [data-theme="dark"] [style*="background: #FEF9C3"],
[data-theme="dark"] [style*="background:#FFFBEB"], [data-theme="dark"] [style*="background: #FFFBEB"] {
    background: rgba(251, 191, 36, .14) !important;
    border-color: rgba(251, 191, 36, .28) !important;
}

[data-theme="dark"] [style*="background:#DBEAFE"], [data-theme="dark"] [style*="background: #DBEAFE"],
[data-theme="dark"] [style*="background:#E0F2FE"], [data-theme="dark"] [style*="background: #E0F2FE"],
[data-theme="dark"] [style*="background:#EFF6FF"], [data-theme="dark"] [style*="background: #EFF6FF"],
[data-theme="dark"] [style*="background:#BFDBFE"], [data-theme="dark"] [style*="background: #BFDBFE"] {
    background: rgba(96, 165, 250, .14) !important;
    border-color: rgba(96, 165, 250, .28) !important;
}

[data-theme="dark"] [style*="background:#F3E8FF"], [data-theme="dark"] [style*="background: #F3E8FF"],
[data-theme="dark"] [style*="background:#EDE9FE"], [data-theme="dark"] [style*="background: #EDE9FE"],
[data-theme="dark"] [style*="background:#E0E7FF"], [data-theme="dark"] [style*="background: #E0E7FF"] {
    background: rgba(167, 139, 250, .16) !important;
    border-color: rgba(167, 139, 250, .3) !important;
}

[data-theme="dark"] [style*="background:#FFE4E6"], [data-theme="dark"] [style*="background: #FFE4E6"],
[data-theme="dark"] [style*="background:#FCE7F3"], [data-theme="dark"] [style*="background: #FCE7F3"],
[data-theme="dark"] [style*="background:#FEE2E2"], [data-theme="dark"] [style*="background: #FEE2E2"],
[data-theme="dark"] [style*="background:#FEF2F2"], [data-theme="dark"] [style*="background: #FEF2F2"],
[data-theme="dark"] [style*="background:#FECACA"], [data-theme="dark"] [style*="background: #FECACA"] {
    background: rgba(248, 113, 113, .15) !important;
    border-color: rgba(248, 113, 113, .3) !important;
}

[data-theme="dark"] [style*="background:#F1F5F9"], [data-theme="dark"] [style*="background: #F1F5F9"],
[data-theme="dark"] [style*="background:#F3F4F6"], [data-theme="dark"] [style*="background: #F3F4F6"],
[data-theme="dark"] [style*="background:#F8FAFC"], [data-theme="dark"] [style*="background: #F8FAFC"],
[data-theme="dark"] [style*="background:#E5E7EB"], [data-theme="dark"] [style*="background: #E5E7EB"] {
    background: rgba(148, 163, 184, .16) !important;
    border-color: rgba(148, 163, 184, .26) !important;
}

/* رنگ متن برچسب‌های تیره در حالت شب */
[data-theme="dark"] [style*="color:#059669"], [data-theme="dark"] [style*="color: #059669"],
[data-theme="dark"] [style*="color:#0F766E"], [data-theme="dark"] [style*="color: #0F766E"],
[data-theme="dark"] [style*="color:#16A34A"], [data-theme="dark"] [style*="color: #16A34A"] {
    color: #6EE7B7 !important;
}

[data-theme="dark"] [style*="color:#D97706"], [data-theme="dark"] [style*="color: #D97706"],
[data-theme="dark"] [style*="color:#B45309"], [data-theme="dark"] [style*="color: #B45309"],
[data-theme="dark"] [style*="color:#92400E"], [data-theme="dark"] [style*="color: #92400E"] {
    color: #FCD34D !important;
}

[data-theme="dark"] [style*="color:#2563EB"], [data-theme="dark"] [style*="color: #2563EB"],
[data-theme="dark"] [style*="color:#0284C7"], [data-theme="dark"] [style*="color: #0284C7"],
[data-theme="dark"] [style*="color:#0369A1"], [data-theme="dark"] [style*="color: #0369A1"],
[data-theme="dark"] [style*="color:#3B82F6"], [data-theme="dark"] [style*="color: #3B82F6"] {
    color: #93C5FD !important;
}

[data-theme="dark"] [style*="color:#7C3AED"], [data-theme="dark"] [style*="color: #7C3AED"],
[data-theme="dark"] [style*="color:#8B5CF6"], [data-theme="dark"] [style*="color: #8B5CF6"],
[data-theme="dark"] [style*="color:#9333EA"], [data-theme="dark"] [style*="color: #9333EA"],
[data-theme="dark"] [style*="color:#4338CA"], [data-theme="dark"] [style*="color: #4338CA"] {
    color: #C4B5FD !important;
}

[data-theme="dark"] [style*="color:#BE185D"], [data-theme="dark"] [style*="color: #BE185D"],
[data-theme="dark"] [style*="color:#E11D48"], [data-theme="dark"] [style*="color: #E11D48"],
[data-theme="dark"] [style*="color:#DC2626"], [data-theme="dark"] [style*="color: #DC2626"] {
    color: #FCA5A5 !important;
}

[data-theme="dark"] [style*="color:#475569"], [data-theme="dark"] [style*="color: #475569"],
[data-theme="dark"] [style*="color:#64748B"], [data-theme="dark"] [style*="color: #64748B"],
[data-theme="dark"] [style*="color:#6B7280"], [data-theme="dark"] [style*="color: #6B7280"] {
    color: #CBD5E1 !important;
}

/* پس‌زمینه‌های روشن درون‌خطی (کارت/باکس) در حالت شب */
[data-theme="dark"] [style*="background:#fff"], [data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"], [data-theme="dark"] [style*="background:#FFFFFF"],
[data-theme="dark"] [style*="background:white"], [data-theme="dark"] [style*="background: white"] {
    background: var(--bg-card, #1E293B) !important;
}

/* ── ۶.۵) برچسب نوع برنامه: یک پالت واحد برای همهٔ سبک‌ها ── */
.program-type {
    --pt-h: 174;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 13px;
    border-radius: var(--radius-full, 9999px);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.9;
    white-space: nowrap;
    border: 1px solid hsl(var(--pt-h) 55% 82%);
    background: hsl(var(--pt-h) 72% 95%) !important;
    color: hsl(var(--pt-h) 64% 30%) !important;
}

.program-type.resane { --pt-h: 199; }
.program-type.heyat { --pt-h: 172; }
.program-type.rozeh_khaneghi { --pt-h: 265; }
.program-type.elmi { --pt-h: 217; }
.program-type.maharati { --pt-h: 152; }
.program-type.farhangi { --pt-h: 342; }
.program-type.siasi { --pt-h: 285; }
.program-type.tafrihi { --pt-h: 35; }
.program-type.foghe_barname { --pt-h: 250; }
.program-type.ekhtetamiye { --pt-h: 18; }
.program-type.emtehan { --pt-h: 0; }
.program-type.jalse_gruhi { --pt-h: 188; }
.program-type.masouliat { --pt-h: 25; }
.program-type.course { --pt-h: 160; }
.program-type.camp { --pt-h: 35; }
.program-type.annual { --pt-h: 217; }
.program-type.event { --pt-h: 265; }
.program-type.workshop { --pt-h: 342; }
.program-type.general { --pt-h: 215; }

[data-theme="dark"] .program-type {
    border-color: hsl(var(--pt-h) 45% 34%);
    background: hsl(var(--pt-h) 46% 20% / .85) !important;
    color: hsl(var(--pt-h) 82% 76%) !important;
}

/* ── ۷) مودال کارت برنامه (صفحهٔ اصلی) ── */
.ui-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 32px);
    background: rgba(2, 6, 23, .62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: ui-fade .2s ease both;
    overscroll-behavior: contain;
}

.ui-modal[hidden] { display: none; }

.ui-modal-card {
    position: relative;
    width: min(720px, 100%);
    max-height: calc(100dvh - 2 * clamp(12px, 3vw, 32px));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, rgba(229, 231, 235, .6));
    border-radius: 26px;
    box-shadow: 0 40px 90px -30px rgba(2, 6, 23, .6);
    animation: ui-modal-in .3s var(--ui-ease) both;
}

.ui-modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 12px;
    background: rgba(15, 23, 42, .42);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all var(--ui-dur) ease;
}

.ui-modal-close:hover {
    background: rgba(15, 23, 42, .68);
    transform: rotate(90deg);
}

.ui-modal-media {
    position: relative;
    width: 100%;
    background-color: rgba(15, 23, 42, .9);
    background-size: cover;
    background-position: center;
    display: grid;
    place-items: center;
    min-height: 200px;
    overflow: hidden;
    isolation: isolate;
}

.ui-modal-media::before {
    content: '';
    position: absolute;
    inset: -20px;
    z-index: 0;
    background-image: inherit;
    background-size: cover;
    background-position: center;
    filter: blur(22px) saturate(1.15);
    opacity: .55;
    transform: scale(1.08);
}

.ui-modal-media > img,
.ui-modal-media > svg {
    position: relative;
    z-index: 1;
}

.ui-modal-media img {
    width: 100%;
    max-height: min(58dvh, 520px);
    object-fit: contain;
    display: block;
    background: rgba(15, 23, 42, .06);
}

.ui-modal-media.is-empty { padding: 46px 20px; color: var(--color-primary, #0D9488); }

.ui-modal-body {
    padding: 22px clamp(18px, 3vw, 28px) 26px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ui-modal-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    color: var(--text-muted, #9CA3AF);
}

.ui-modal-title {
    font-size: clamp(1.15rem, 2.6vw, 1.5rem);
    font-weight: 800;
    line-height: 1.6;
    color: var(--text-foreground, #134E4A);
}

.ui-modal-desc {
    font-size: .94rem;
    line-height: 2.05;
    color: var(--text-secondary, #6B7280);
    white-space: pre-wrap;
    overflow-wrap: normal;
}

.ui-modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

.ui-modal-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-primary, #374151);
    background: var(--bg-muted, #F9FAFB);
    border: 1px solid var(--border-color, rgba(229, 231, 235, .6));
    border-radius: 999px;
}

.ui-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

body.ui-modal-open { overflow: hidden; }

@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-modal-in {
    from { opacity: 0; transform: translateY(18px) scale(.97); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
    .ui-modal { align-items: flex-end; padding: 0; }
    .ui-modal-card {
        width: 100%;
        max-height: 92dvh;
        border-radius: 24px 24px 0 0;
        animation-name: ui-sheet-in;
    }
    .ui-modal-media img { max-height: 46dvh; }
    @keyframes ui-sheet-in {
        from { opacity: .6; transform: translateY(60px); }
        to { opacity: 1; transform: none; }
    }
}

/* ── ۸) ریسپانسیو تکمیلی برای کنترل‌ها ── */
@media (max-width: 640px) {
    .ui-select-btn { min-height: 44px; font-size: .9rem; }
    .ui-file-zone { padding: 14px; gap: 12px; border-radius: 16px; }
    .ui-file-icon { width: 40px; height: 40px; flex-basis: 40px; border-radius: 12px; }
    .ui-file-action { display: none; }
    .ui-file-hint { font-size: .74rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ui-select-menu, .ui-file-zone, .ui-modal, .ui-modal-card, .ui-time-popup {
        animation: none !important;
        transition: none !important;
    }
}
