/* ============================================================
   components.css — اجزای قابل‌استفاده در همه‌ی صفحات
   شامل: مودال‌ها، دکمه‌ها، فیلدهای ورودی عمومی، توست، اسپینر،
   لایت‌باکس، کلید روشن/خاموش (toggle) و پیام‌های هشدار (alert)
   ============================================================ */

/* ── دکمه‌های عمومی ───────────────────────────────────────── */
.btn-p {
    padding: 8px 16px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    border: none;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: .83rem;
    cursor: pointer;
    transition: .2s;
}
.btn-p:hover { filter: brightness(1.08); }

.btn-g {
    padding: 8px 16px;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 600;
    font-size: .83rem;
    cursor: pointer;
    transition: .2s;
    text-decoration: none;
    display: inline-block;
}
.btn-g:hover { background: var(--surface-alt); }

.btn-d {
    padding: 8px 16px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    border: none;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: .83rem;
    cursor: pointer;
    transition: .2s;
}
.btn-d:hover { filter: brightness(1.05); }

.btn-s {
    padding: 8px 16px;
    border-radius: 9px;
    background: var(--success);
    color: #fff;
    border: none;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: .83rem;
    cursor: pointer;
    transition: .2s;
}
.btn-s:hover { filter: brightness(1.05); }

.btn-sm        { padding: 6px 13px; border-radius: 8px; border: none; font-family: 'Vazirmatn', sans-serif; font-size: .78rem; font-weight: 600; cursor: pointer; transition: .2s; white-space: nowrap; }
.btn-primary-sm{ background: var(--accent); color: #fff; }
.btn-danger-sm { background: var(--danger);  color: #fff; }

.btn-save {
    width: 100%;
    padding: 12px;
    border-radius: 11px;
    background: var(--accent);
    color: #fff;
    border: none;
    font-family: 'Vazirmatn', sans-serif;
    font-size: .93rem;
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
    margin-top: 4px;
}
.btn-save:hover { filter: brightness(1.08); }

/* ── فیلدهای ورودی عمومی ──────────────────────────────────── */
.m-inp, .inp {
    width: 100%;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1.5px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    font-size: .88rem;
    outline: none;
    transition: .2s;
    box-sizing: border-box;
    margin-bottom: 0;
}
.m-inp:focus, .inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-faint); }

.m-sel {
    width: 100%;
    padding: 9px 11px;
    border-radius: 9px;
    border: 1.5px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    font-size: .88rem;
    outline: none;
    cursor: pointer;
}

.fg  { margin-bottom: 16px; }
.lbl { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }

.row-inline { display: flex; gap: 8px; align-items: flex-end; }

/* ── کادر هشدار / پیام موفقیت و خطا ──────────────────────── */
.alert {
    padding: 11px 14px;
    border-radius: 11px;
    font-weight: 600;
    margin-bottom: 16px;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: 7px;
}
.alert-error   { background: #fff1f0; color: var(--danger);  border: 1px solid var(--danger); }
.alert-success { background: #f0fff4; color: var(--success); border: 1px solid var(--success); }
.alert-warn    { background: #fffbeb; color: #b7791f; border: 1px solid #f6e05e; }

/* ── کلید روشن/خاموش (toggle switch) ─────────────────────── */
.toggle-sw, .switch {
    position: relative;
    width: 42px; height: 24px;
    flex-shrink: 0;
}
.toggle-sw input, .switch input { opacity: 0; width: 0; height: 0; }
.toggle-sw .slider, .switch .slider {
    position: absolute; inset: 0;
    background: var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: .3s;
}
.toggle-sw .slider::before, .switch .slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    right: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-sw input:checked + .slider,
.switch input:checked + .slider { background: var(--accent); }
.toggle-sw input:checked + .slider::before,
.switch input:checked + .slider::before { transform: translateX(-18px); }

/* ── مودال‌ها ──────────────────────────────────────────────── */
.overlay {
    position: fixed; inset: 0;
    z-index: 300;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center; justify-content: center;
    padding: 16px;
}
.overlay.open { display: flex; animation: fadeIn .18s; }

.modal {
    background: var(--surface);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    border: 1.5px solid var(--border);
    animation: slideUp .2s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal.wide  { max-width: 480px; }
.modal.small { max-width: 360px; }

.mh {
    padding: 14px 18px 11px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.mt { font-size: .9rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.mc {
    width: 26px; height: 26px;
    border-radius: 7px;
    border: none;
    background: var(--surface-alt);
    cursor: pointer;
    font-size: .85rem;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.mc:hover { background: var(--accent-faint); color: var(--accent); }

.mb { padding: 14px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.mf {
    padding: 11px 18px 15px;
    display: flex; gap: 7px; justify-content: flex-end;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* محتوای متنیِ تأیید حذف داخل مودال */
.mb-confirm { text-align: center; padding: 18px; }
.mb-confirm .mb-confirm-icon { font-size: 2.2rem; margin-bottom: 8px; }
.mb-confirm .mb-confirm-title { font-weight: 700; margin-bottom: 4px; }
.mb-confirm .mb-confirm-note  { font-size: .78rem; color: var(--text-muted); }
.mb-confirm .mb-confirm-warn  { font-size: .72rem; color: var(--danger); margin-top: 4px; }

/* درخت پوشه‌ها داخل مودال انتقال/کپی فایل */
.dir-tree { max-height: 190px; overflow-y: auto; }
.dt-item {
    padding: 7px 11px;
    border-radius: 7px;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
    transition: .15s;
    display: flex; align-items: center; gap: 5px;
}
.dt-item:hover  { background: var(--surface-alt); color: var(--accent); }
.dt-item.sel    { background: var(--accent-faint); color: var(--accent); }

/* لیست‌های کوچک داخل مودال (اعضای گروه، جستجوی کاربر و ...) */
.modal-scroll-list {
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
}
.modal-section-label {
    font-size: .8rem;
    font-weight: 700;
    margin-top: 5px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.modal-section-label:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* ── توست (پیام کوتاه گوشه صفحه) ──────────────────────────── */
.toast-wrap {
    position: fixed;
    bottom: 16px; right: 16px;
    z-index: 600;
    display: flex; flex-direction: column; gap: 6px;
    pointer-events: none;
}
.toast {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    padding: 9px 13px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    font-size: .8rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    max-width: 260px;
    pointer-events: all;
    animation: toastIn .28s ease;
}
.toast.success  { border-color: var(--success); color: var(--success); }
.toast.error    { border-color: var(--danger);  color: var(--danger); }
.toast.removing { animation: toastOut .22s forwards; }

/* ── اسپینر بارگذاری ──────────────────────────────────────── */
.spinner {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: spin .7s linear infinite;
    margin: 24px auto;
    display: block;
}

/* ── لایت‌باکس نمایش تصویر/PDF ────────────────────────────── */
.lightbox {
    position: fixed; inset: 0;
    z-index: 500;
    background: rgba(0,0,0,.9);
    display: none;
    align-items: center; justify-content: center;
    flex-direction: column;
}
.lightbox.open { display: flex; animation: fadeIn .2s; }
.lb-img   { max-width: 90vw; max-height: 82vh; border-radius: 8px; object-fit: contain; }
.lb-pdf   { width: 90vw; height: 82vh; border-radius: 8px; border: none; background: #fff; }
.lb-close {
    position: absolute; top: 14px; right: 14px;
    background: rgba(255,255,255,.15);
    border: none; color: #fff;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.lb-close:hover { background: rgba(255,255,255,.28); }
.lb-name {
    color: rgba(255,255,255,.7);
    font-size: .78rem;
    margin-top: 10px;
    max-width: 80vw;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── کادر عمومی محتوا (کارت) ──────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: 22px;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    border: 1.5px solid var(--border);
}
.card-title {
    font-size: .77rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 18px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* دکمه گرد جابجایی تم (نسخه‌ی کوچک، در صفحات بدون نوار کامل) */
.theme-tog {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
}
