/* ===== صفحه‌های «ویرایش لیستی» (برند، دسته‌بندی، گارانتی‌کننده، کاربران) و مودالِ مشترکشون =====
   کلاس‌ها با پیشوندِ qx- هستن تا با استایل‌های scoped صفحه‌ی محصولات (qe-) قاطی نشن. */

.qx-back {
    display: block;
    font-size: 0.76rem;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 0.2rem;
}

.qx-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.qx-head__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qx-toolbar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.qx-search {
    max-width: 320px;
    border-radius: 4px;
}

.qx-filter {
    width: auto;
    min-width: 150px;
    max-width: 220px;
    border-radius: 4px;
}

.qx-count {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ----- جدول ----- */
.qx-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg, #fff);
}

.qx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

    .qx-table th {
        text-align: right;
        font-size: 0.72rem;
        color: var(--text-muted);
        font-weight: 700;
        padding: 0.6rem 0.6rem;
        background: var(--bg-secondary, #f7f6f2);
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
    }

    .qx-table td {
        padding: 0.45rem 0.6rem;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
    }

    .qx-table tbody tr:last-child td {
        border-bottom: 0;
    }

.qx-row:hover {
    background: color-mix(in srgb, var(--primary) 4%, transparent);
}

.qx-row--inactive td:not(.qx-cell-actions) {
    opacity: 0.55;
}

.qx-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0 !important;
}

.qx-name {
    font-weight: 600;
}

.qx-muted {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.qx-ltr {
    direction: ltr;
    text-align: left;
}

.qx-ellipsis {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qx-cell-thumb {
    width: 56px;
}

.qx-cell-actions {
    width: 80px;
    text-align: left;
    white-space: nowrap;
}

.qx-thumb {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg, #fff);
}

.qx-thumb--empty {
    background: var(--bg-secondary, #f7f6f2);
}

.qx-badge {
    display: inline-block;
    font-size: 0.7rem;
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    white-space: nowrap;
}

.qx-badge--on {
    background: color-mix(in srgb, #2e9d5b 14%, transparent);
    color: #1f7a44;
}

.qx-badge--off {
    background: var(--bg-secondary, #f7f6f2);
    color: var(--text-muted);
}

.qx-tree-mark {
    color: var(--text-muted);
    margin-inline-end: 0.3rem;
}

.qx-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}

.qx-pager {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ----- مودال ----- */
.qx-overlay {
    position: fixed;
    inset: 0;
    /* هم‌لایه‌ی مودالِ فرمِ کاملِ محصول (بالاتر از سایدبار و نوارِ ادمین)؛ Toast (9999) روشه و پنجره‌ی MediaPicker (1050) روی این مودال می‌شینه */
    z-index: 1045;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.5);
    outline: none;
    animation: qx-fade 0.15s ease-out;
}

/* عمداً transform/filter/backdrop-filter نداریم: باعث می‌شن پنجره‌های position:fixed داخلِ مودال (مثل MediaPicker) نسبت به این قاب چیده بشن، نه صفحه */
.qx-dialog {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: 100%;
    background: var(--surface, #fff);
    color: var(--text);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.25));
    overflow: hidden;
}

.qx-dialog--wide {
    width: min(760px, 100%);
}

.qx-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.qx-dialog__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.qx-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

    .qx-close:hover:not(:disabled) {
        background: var(--bg-secondary, #f7f6f2);
        color: var(--text);
    }

.qx-dialog__body {
    padding: 1.2rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.qx-dialog__foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary, #f7f6f2);
}

/* ----- فرم داخلِ مودال ----- */
.qx-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.qx-field {
    margin-bottom: 0.9rem;
}

.qx-field--full {
    grid-column: 1 / -1;
}

.qx-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.qx-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.qx-alert {
    background: color-mix(in srgb, #c0392b 10%, transparent);
    border: 1px solid color-mix(in srgb, #c0392b 35%, transparent);
    color: #a5281b;
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    margin-bottom: 0.9rem;
}

    .qx-alert ul {
        margin: 0;
        padding-inline-start: 1.1rem;
    }

.qx-logo {
    position: relative;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.qx-logo__img {
    display: block;
    width: 84px;
    height: 84px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg, #fff);
}

.qx-logo__remove {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}

@keyframes qx-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qx-overlay {
        animation: none;
    }
}

@media (max-width: 700px) {
    .qx-form-grid {
        grid-template-columns: 1fr;
    }

    .qx-overlay {
        padding: 0;
    }

    .qx-dialog,
    .qx-dialog--wide {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .qx-dialog__body {
        flex: 1;
    }
}
