/*
 * The two collections of galleries (تسک ۱۴۰۵/۰۸/۱۲/۰۳). Loaded after the panel's
 * palette, and written from the same two classes on <body>, so it wins by order.
 */

/* ── The marks: the owner's files, square, readable when small ─────────────── */

.fi-gallery-origin-mark {
    border-radius: 0.3rem;
    object-fit: contain;
}

.fi-gallery-heading-origin {
    width: 2rem;
    height: 2rem;
    flex: none;
}

/* ── The old list: «عنوان گالری» and «بازی» read from the right ────────────── */

.fi-body.fi-panel-admin .fi-page-photoaman-galleries .fi-ta-header-cell.fi-ta-header-cell-name,
.fi-body.fi-panel-admin .fi-page-photoaman-galleries .fi-ta-header-cell.fi-ta-header-cell-teams {
    text-align: start;
}

.fi-body.fi-panel-admin .fi-page-photoaman-galleries .fi-ta-header-cell.fi-ta-header-cell-name > *,
.fi-body.fi-panel-admin .fi-page-photoaman-galleries .fi-ta-header-cell.fi-ta-header-cell-teams > * {
    justify-content: flex-start;
    text-align: start;
    margin-inline: 0;
}

.fi-body.fi-panel-admin .fi-page-photoaman-galleries .fi-ta-cell .fi-gallery-title-value,
.fi-body.fi-panel-admin .fi-page-photoaman-galleries .fi-ta-cell .fi-gallery-match-value {
    justify-content: flex-start;
    text-align: start;
}

/* ── The new galleries wear the reference's colours ─────────────────────────
   The palette reads these from <body>; the same names on the page turn its
   tables, buttons and titles back, and leave the panel's top bar alone. */

.fi-body.fi-panel-admin .fi-page-new-photoaman-galleries,
.fi-body.fi-panel-admin .fi-page-manual-galleries-create,
.fi-body.fi-panel-admin .fi-page-manual-galleries-edit {
    --pa-red: #C2A64F;
    --pa-red-hover: #B2963F;
    --pa-red-pressed: #A08636;
    --pa-red-disabled: #8C7C4A;
    --pa-white: #242424;
    --pa-title: var(--warning-600, #d97706);
    /* Their row titles were never red: they keep the reference's amber
       (تسک ۱۴۰۵/۰۸/۲۱/۰۴ changes only red ones). */
    --pa-row-title: var(--pa-title);
    --std-combo-table-header-text: #242424;
    --std-combo-table-header-background: #C2A64F;
    --std-combo-table-header-text-dark: #242424;
    --std-combo-table-header-background-dark: #C2A64F;
    --std-combo-button-primary-text: #242424;
    --std-combo-button-primary-background: #C2A64F;
    --std-combo-button-primary-text-dark: #242424;
    --std-combo-button-primary-background-dark: #C2A64F;
    --agency-management-name-colour: #C2A64F;
}

.dark .fi-body.fi-panel-admin .fi-page-new-photoaman-galleries,
.dark .fi-body.fi-panel-admin .fi-page-manual-galleries-create,
.dark .fi-body.fi-panel-admin .fi-page-manual-galleries-edit,
.fi-body.fi-panel-admin:where(.dark) .fi-page-new-photoaman-galleries,
.fi-body.fi-panel-admin:where(.dark) .fi-page-manual-galleries-create,
.fi-body.fi-panel-admin:where(.dark) .fi-page-manual-galleries-edit {
    --pa-title: var(--warning-400, #fbbf24);
}

/* ── The old gallery's page: the pinned card and the tabs under it ─────────── */

.fi-page-old-gallery-edit {
    --pa-gallery-card-h: 13rem;
    --pa-gallery-pin-top: var(--fi-panel-topbar-h, 4rem);
}

/* Fields reached by keyboard or by a validation error stop below the card and the tabs. */
html:has(.fi-page-old-gallery-edit) {
    scroll-padding-top: calc(var(--fi-panel-topbar-h, 4rem) + 17rem);
}

/* Flush under the top bar, with the page's ground filling the gap above the card,
   so nothing scrolling away shows between the two. */
.fi-page-old-gallery-edit .fi-grid-col:has(> .fi-sc-component > .fi-gallery-header) {
    top: var(--pa-gallery-pin-top);
    z-index: 12;
    padding-top: 0.5rem;
    background-color: var(--gray-50, #f9fafb);
}

:where(.dark) .fi-page-old-gallery-edit .fi-grid-col:has(> .fi-sc-component > .fi-gallery-header) {
    background-color: var(--gray-950, #09090b);
}

/* By day the card is dark… */
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header {
    --pa-card-ink: #F4F4F5;
    --pa-card-soft: #C4C7CE;
    --pa-card-missing: #FCA5A5;
    --pa-card-badge: rgba(255, 255, 255, 0.08);
    --pa-card-badge-edge: rgba(255, 255, 255, 0.28);
    --pa-card-amber: #FCD34D;
    --pa-card-green: #86EFAC;
    --pa-card-blue: #93C5FD;
    border-color: #3A3D44;
    background: #1E2025;
    color: var(--pa-card-ink);
}

/* …and by night a soft light one, never the page's white. */
.dark .fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header,
.fi-body.fi-panel-admin:where(.dark *) .fi-page-old-gallery-edit .fi-gallery-header {
    --pa-card-ink: #1F2125;
    --pa-card-soft: #4B4F57;
    --pa-card-missing: #B3261E;
    --pa-card-badge: rgba(0, 0, 0, 0.05);
    --pa-card-badge-edge: rgba(0, 0, 0, 0.3);
    --pa-card-amber: #854D0E;
    --pa-card-green: #166534;
    --pa-card-blue: #1D4ED8;
    border-color: #C6C3BA;
    background: #E3E1DA;
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-title,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-title-text,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header a.fi-gallery-header-title-link {
    color: var(--pa-card-ink);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-code,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-info,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-result {
    color: var(--pa-card-soft);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-missing {
    color: var(--pa-card-missing);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge {
    border-color: var(--pa-card-badge-edge);
    background: var(--pa-card-badge);
    color: var(--pa-card-ink);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-photos {
    color: var(--pa-card-blue);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-photographers,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-photographers .fi-photographer-option-name,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-photographers .fi-photographer-option-code,
.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-photographers .fi-photographer-option-photos {
    color: var(--pa-card-amber);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-date {
    color: var(--pa-card-green);
}

.fi-body.fi-panel-admin .fi-page-old-gallery-edit .fi-gallery-header .fi-gallery-header-badge-empty {
    color: var(--pa-card-missing);
}

/* The tab titles stay readable: pinned straight under the card, across the page's
   width and on its ground, so nothing scrolling away shows beside them. */
.fi-page-old-gallery-edit .fi-gallery-main-tabs > .fi-tabs {
    width: 100%;
    max-width: none;
    margin-inline: 0;
    justify-content: center;
    border-radius: 0;
    position: sticky;
    top: calc(var(--pa-gallery-pin-top) + var(--pa-gallery-card-h));
    z-index: 11;
    background-color: var(--gray-50, #f9fafb);
}

:where(.dark) .fi-page-old-gallery-edit .fi-gallery-main-tabs > .fi-tabs {
    background-color: var(--gray-950, #09090b);
}

/* A short screen has no room for both to stay. */
@media (max-height: 640px), (max-width: 768px) {
    .fi-page-old-gallery-edit .fi-grid-col:has(> .fi-sc-component > .fi-gallery-header),
    .fi-page-old-gallery-edit .fi-gallery-main-tabs > .fi-tabs {
        position: static;
    }

    html:has(.fi-page-old-gallery-edit) {
        scroll-padding-top: calc(var(--fi-panel-topbar-h, 4rem) + 1rem);
    }
}

/* The indicator in the middle of the screen while a tab changes. */
.fi-gallery-tab-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.fi-gallery-tab-overlay .fi-gallery-saving-spinner {
    width: 3rem;
    height: 3rem;
    color: var(--pa-title, #E53935);
}

/* The heading's figures by day: the shared rule writes them white for the dark
   page, which leaves «همه» and every number unreadable on a light one. */
html:not(.dark) .fi-body.fi-panel-admin .fi-page-gallery-list .fi-gallery-stats-heading-count,
html:not(.dark) .fi-body.fi-panel-admin .fi-page-gallery-list .fi-gallery-stat-all .fi-gallery-stats-heading-label,
html:not(.dark) .fi-body.fi-panel-admin .fi-page-gallery-list .fi-gallery-stats-heading-sep {
    color: #1F2125;
}

/* ── تسک ۰۹ — home-page sections: sub-tabs, ten cover slots, the count by the code ── */

.fi-gallery-header-code-divider {
    margin-inline: 0.35rem;
    opacity: 0.7;
}

.fi-gallery-header-photo-count {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

a.fi-gallery-header-photo-count:hover,
a.fi-gallery-header-photo-count:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.fi-gallery-settings-tabs {
    margin-top: 0.5rem;
}

.fi-home-section-readout,
.fi-home-display-note {
    margin: 0;
    padding: 0.6rem 0.85rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.7;
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-800, #1f2937);
}

.fi-home-display-note ul {
    margin: 0.35rem 0 0;
    padding-inline-start: 1.1rem;
    list-style: disc;
}

.fi-home-section-readout-success {
    background: var(--success-50, #f0fdf4);
    color: var(--success-800, #166534);
}

.fi-home-section-readout-warning {
    background: var(--warning-50, #fffbeb);
    color: var(--warning-800, #92400e);
}

:where(.dark) .fi-home-section-readout,
:where(.dark) .fi-home-display-note {
    background: rgb(255 255 255 / 0.06);
    color: var(--gray-200, #e5e7eb);
}

:where(.dark) .fi-home-section-readout-success {
    background: rgb(34 197 94 / 0.14);
    color: var(--success-300, #86efac);
}

:where(.dark) .fi-home-section-readout-warning {
    background: rgb(245 158 11 / 0.14);
    color: var(--warning-300, #fcd34d);
}

.fi-home-cover-slots {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fi-home-cover-slots-note {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    padding: 0.6rem 0.85rem;
    border: 1px dashed var(--gray-300, #d1d5db);
    border-radius: 0.5rem;
    font-size: 0.85rem;
}

.fi-home-cover-slots-note strong {
    flex-basis: 100%;
}

.fi-home-cover-slots-wait {
    margin: 0;
    font-size: 0.85rem;
    color: var(--warning-700, #b45309);
}

.fi-home-cover-slots-error {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--danger-50, #fef2f2);
    color: var(--danger-700, #b91c1c);
    font-size: 0.875rem;
}

/* Two rows of five on a wide screen; fewer per row on a narrow one, same order. */
.fi-home-cover-slots-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.6rem;
    max-width: 46rem;
}

@media (max-width: 640px) {
    .fi-home-cover-slots-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 641px) and (max-width: 900px) {
    .fi-home-cover-slots-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.fi-home-cover-slot {
    position: relative;
    aspect-ratio: 1010 / 1200;
    border: 1px dashed var(--gray-300, #d1d5db);
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50, #f9fafb);
}

:where(.dark) .fi-home-cover-slot {
    border-color: rgb(255 255 255 / 0.2);
    background: rgb(255 255 255 / 0.04);
}

.fi-home-cover-slot.is-filled {
    border-style: solid;
}

.fi-home-cover-slot img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fi-home-cover-slot-number {
    position: absolute;
    top: 0.25rem;
    inset-inline-start: 0.35rem;
    z-index: 2;
    min-width: 1.4rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: rgb(0 0 0 / 0.55);
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
}

.fi-home-cover-slot-empty {
    font-size: 0.8rem;
    color: var(--gray-500, #6b7280);
}

.fi-home-cover-slot-busy {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(0 0 0 / 0.5);
    color: #fff;
    font-size: 0.8rem;
}

.fi-home-cover-slot-actions {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    padding: 0.3rem;
    background: linear-gradient(to top, rgb(0 0 0 / 0.6), transparent);
}

.fi-home-cover-slot.is-empty .fi-home-cover-slot-actions {
    background: none;
}

.fi-home-cover-slot-button {
    cursor: pointer;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    background: var(--primary-600, #2563eb);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1.6;
    white-space: nowrap;
}

.fi-home-cover-slot-remove {
    background: var(--danger-600, #dc2626);
}

/* The native file field is never drawn; its label is the button. */
.fi-home-cover-slot-button {
    position: relative;
    overflow: hidden;
}

.fi-home-cover-slot-file {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

/* تسک ۱۱، بند ۱۲: a slot's copy in the Dropbox archive */
.fi-home-cover-slot-archive {
    display: block;
    font-size: .75rem;
    line-height: 1.4;
    color: var(--gray-600, #4b5563);
    text-align: center;
    padding: .15rem .25rem;
}
