/*
 * «مشتریان» — the list, a customer's four tabs, the window that changes a
 * balance and «تغییرات اعتبار مشتریان» (تسک ۱۴۰۵/۰۷/۲۰/۰۱).
 *
 * Every rule is scoped to one of those pages' own classes or to a class this
 * task's own markup carries, and no colour is written as a bare literal: the
 * panel's `--std-color-*` tokens decide them, with the literal only as the
 * fallback for a panel whose palette has not loaded. (The one exception is
 * five of the twelve month colours, which the palette has no token for — see
 * «ماه» below.) A table cell's own text
 * colour is not decided here at all — the yellow of a mobile number and the
 * green of a name are the column's own `color()`, and the size of a page's
 * heading is a row of «استانداردسازی نمای پنل» written by a migration.
 */

/* ——— Zebra rows and the column strip (بند ۴، ۱۶، ۱۷ و ۳۳) ——————————————————
 *
 * The pair «آمار فروش» already uses, by name, so the panel has one idea of a
 * striped table. The strip of column titles is a third, stronger wash: unlike
 * either row and unlike the black of the page above the card.
 */
.fi-customers-list-page,
.fi-customer-edit-page,
.fi-credit-changes-page {
    /* Kept for anything outside the heading row that still names it. */
    --agency-customers-strip: color-mix(in oklab, var(--gray-400, #9ca3af) 26%, transparent);
}

.fi-customers-list-page .fi-ta-row,
.fi-customer-edit-page .fi-ta-row,
.fi-credit-changes-page .fi-ta-row {
    background-color: var(--agency-zebra-odd);
}

.fi-customers-list-page .fi-ta-row.fi-striped,
.fi-customer-edit-page .fi-ta-row.fi-striped,
.fi-credit-changes-page .fi-ta-row.fi-striped {
    background-color: var(--agency-zebra-even);
}

.fi-customers-list-page .fi-ta-row:hover,
.fi-customer-edit-page .fi-ta-row:hover,
.fi-credit-changes-page .fi-ta-row:hover {
    background-color: var(--agency-zebra-hover);
}

/* The strip of column titles is the panel-wide gold of «عنوان ستون جدول»
   since تسک ۲۸_۰۴; this page no longer paints one of its own. */

/* ——— A moment: «۲۰ مهر ۱۴۰۵ | ۰۰:۲۷» (بند ۵، ۱۳ و ۱۸) ————————————————————— */
.agency-moment {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    white-space: nowrap;
}

.agency-moment-date {
    color: var(--std-color-warning-600, #d97706);
}

.dark .agency-moment-date {
    color: var(--std-color-warning-400, #fbbf24);
}

.agency-moment-rule {
    opacity: 0.45;
}

/* ——— A kind of credit and a direction (بند ۱۶، ۲۵، ۲۶ و ۳۱) ————————————————
 *
 * Both kinds are named in green; what tells them apart is the mark — notes in
 * green for cash, a parcel in violet for a gift. A direction is its colour and
 * its sign together: green with a plus, red with a minus.
 */
.agency-credit-type,
.agency-credit-change {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    font-weight: 600;
}

.agency-credit-mark {
    display: inline-flex;
}

.agency-credit-mark svg {
    width: 1.15rem;
    height: 1.15rem;
}

.agency-credit-type .agency-credit-label,
.agency-credit-type-credit .agency-credit-mark,
.agency-credit-change-increase {
    color: var(--std-color-success-600, #16a34a);
}

.dark .agency-credit-type .agency-credit-label,
.dark .agency-credit-type-credit .agency-credit-mark,
.dark .agency-credit-change-increase {
    color: var(--std-color-success-400, #4ade80);
}

.agency-credit-type-gift .agency-credit-mark {
    color: var(--std-color-chart-purple, #9333ea);
}

.dark .agency-credit-type-gift .agency-credit-mark {
    color: var(--std-color-chart-violet, #a78bfa);
}

.agency-credit-change-decrease {
    color: var(--std-color-danger-600, #dc2626);
}

.dark .agency-credit-change-decrease {
    color: var(--std-color-danger-400, #f87171);
}

/* تسک ۱۴۰۵/۰۷/۲۰/۰۲، بند ۳.۲: the amount of a movement — figure and «ریال»
   as one piece of text — in the colour of its direction. «مانده پس از تغییر»
   is not drawn with this class and keeps the table's own colour. */
.agency-credit-amount {
    white-space: nowrap;
    font-weight: 600;
}

.agency-credit-amount-increase {
    color: var(--std-color-success-600, #16a34a);
}

.dark .agency-credit-amount-increase {
    color: var(--std-color-success-400, #4ade80);
}

.agency-credit-amount-decrease {
    color: var(--std-color-danger-600, #dc2626);
}

.dark .agency-credit-amount-decrease {
    color: var(--std-color-danger-400, #f87171);
}

/* ——— «ماه» (تسک ۱۴۰۵/۰۷/۲۰/۰۲، بخش پنجم) ————————————————————————————————————
 *
 * Twelve months, twelve fixed colours. Since تسک ۱۴۰۵/۰۸/۰۲/۰۶ (بند ۴ـ۷) they
 * are the whole agency's — `fi-month-N` in `agency-months.css`, which the span
 * also wears — so مهر here is مهر in «آمار فروش ماهیانه» and «جدول درآمدی».
 * Only the month's staying on one line is this page's own.
 */
.agency-month {
    white-space: nowrap;
}

/* ——— «اعطای اشتراک» (تسک ۱۴۰۵/۰۷/۲۰/۰۲، بخش سوم) ——————————————————————————
 *
 * The title in the middle of the window, the close button where it was. What
 * the customer holds is a list of rows — a mark, a title, a value — at about
 * twice the height the old lines had; under a rule, the notes, each beside an
 * information mark.
 */
.agency-grant-window .fi-modal-header {
    justify-content: center;
}

.agency-grant-window .fi-modal-header > div:not(.fi-modal-close-btn-ctn),
.agency-grant-window .fi-modal-heading {
    flex: 1 1 auto;
    text-align: center;
}

.agency-sub-state-rows {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin: 0;
}

.agency-sub-state-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    line-height: 1.6;
}

.agency-sub-state-row dt {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    opacity: 0.85;
}

.agency-sub-state-row dd {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.4rem;
    min-width: 0;
    margin: 0;
}

.agency-sub-state-mark {
    display: inline-flex;
    flex: 0 0 auto;
}

.agency-sub-state-mark svg {
    width: 1.2rem;
    height: 1.2rem;
}

.agency-sub-state-rule,
.agency-sub-state-note {
    opacity: 0.55;
}

/* بند ۴.۵: the colour is the title's and its mark's; the value beside it keeps
   the window's own text colour. */
.agency-sub-state-row-start dt {
    color: var(--std-color-success-600, #16a34a);
    opacity: 1;
}

.dark .agency-sub-state-row-start dt {
    color: var(--std-color-success-400, #4ade80);
}

.agency-sub-state-row-end dt {
    color: var(--std-color-danger-600, #dc2626);
    opacity: 1;
}

.dark .agency-sub-state-row-end dt {
    color: var(--std-color-danger-400, #f87171);
}

.agency-sub-state-row-remaining dt {
    color: var(--std-color-warning-600, #d97706);
    opacity: 1;
}

.dark .agency-sub-state-row-remaining dt {
    color: var(--std-color-warning-400, #fbbf24);
}

.agency-sub-state-divider {
    margin: 1.1rem 0;
    border: 0;
    border-top: 1px solid color-mix(in oklab, var(--gray-400, #9ca3af) 35%, transparent);
}

.agency-sub-state-notes {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.agency-sub-state-info {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.9;
}

.agency-sub-state-info .agency-sub-state-mark {
    margin-top: 0.3rem;
    color: var(--std-color-chart-sky, #38bdf8);
}

.agency-sub-state-info-strong .agency-sub-state-mark {
    color: var(--std-color-danger-600, #dc2626);
}

.dark .agency-sub-state-info-strong .agency-sub-state-mark {
    color: var(--std-color-danger-400, #f87171);
}

/* ——— «تأیید تغییر اعتبار مشتری» (بند ۲۸) ———————————————————————————————————— */
.agency-credit-confirm {
    display: flex;
    flex-direction: column;
    gap: 0;
    text-align: start;
    border: 1px solid color-mix(in oklab, var(--gray-400, #9ca3af) 30%, transparent);
    border-radius: 0.75rem;
    overflow: hidden;
}

.agency-credit-confirm-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0.9rem;
}

.agency-credit-confirm-row:nth-child(even) {
    background-color: var(--agency-zebra-even);
}

.agency-credit-confirm-row dt {
    flex: 0 0 auto;
    opacity: 0.7;
}

.agency-credit-confirm-row dd {
    min-width: 0;
    font-weight: 600;
    text-align: end;
    overflow-wrap: anywhere;
}

/* ——— «ویرایش مشتری | نام | موبایل» (بند ۹) ————————————————————————————————— */
.agency-customer-heading {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    max-width: 100%;
}

.agency-customer-heading-rule {
    opacity: 0.45;
}

.agency-customer-heading-name,
.agency-customer-heading-phone {
    font-size: 0.82em;
    overflow-wrap: anywhere;
}

/* تسک ۱۴۰۵/۰۷/۲۰/۰۲، بخش اول: the mobile number in the panel's yellow — the
   colour it already has in the list this page was opened from. Only the
   number: the title, the rule and a name keep the heading's own colour. */
.agency-customer-heading-phone {
    color: var(--std-color-warning-600, #d97706);
}

.dark .agency-customer-heading-phone {
    color: var(--std-color-warning-400, #fbbf24);
}

/* ——— One row for a tab's title and its column switch (بند ۱۲) ———————————————
 *
 * Filament draws a table's heading and its toolbar as two rows. On a
 * customer's tabs they share one: the title at the start, «اعطای اشتراک» where
 * there is one, and the column switch at the end.
 */
.fi-customer-edit-page .fi-ta-header-ctn {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.fi-customer-edit-page .fi-ta-header-ctn > .fi-ta-header {
    flex: 1 1 12rem;
    min-width: 0;
}

.fi-customer-edit-page .fi-ta-header-ctn > .fi-ta-header-toolbar {
    flex: 0 0 auto;
    border-width: 0;
}

/* ——— «خریدها» (بند ۱۹ تا ۲۳؛ تسک ۱۴۰۵/۰۷/۲۰/۰۲، بخش چهارم) ————————————————————
 *
 * One wide card to a row: the photograph at the start, the facts beside it in
 * two lines, the three downloads in a column at the end. The frame, a fact and
 * a mark are «مانیتور عکس‌های فروش رفته»'s own pieces and are styled by its
 * file; what is here is how a purchase arranges them. The same card is drawn
 * in the «جزئیات خرید» window, so everything below is scoped to the card and
 * not to the tab.
 */
.fi-ta-content-grid:has(.agency-purchase-card) {
    gap: 1rem;
    padding: 1rem;
}

.agency-purchase-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.agency-purchase-list > .agency-purchase-card {
    border: 1px solid color-mix(in oklab, var(--gray-400, #9ca3af) 25%, transparent);
    border-radius: 0.75rem;
}

.agency-purchase-card {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 1rem 1.25rem;
    padding: 1rem;
    min-width: 0;
}

.agency-purchase-photo {
    flex: 0 0 15rem;
    max-width: 100%;
    align-self: center;
}

.agency-purchase-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.9rem;
    flex: 1 1 22rem;
    min-width: 0;
}

.agency-purchase-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    margin: 0;
    min-width: 0;
}

/* The second line is set off from the first by a rule, so «what it is» and
   «what was bought» are two things at a glance. */
.agency-purchase-line[data-purchase-line="second"] {
    padding-top: 0.9rem;
    border-top: 1px solid color-mix(in oklab, var(--gray-400, #9ca3af) 22%, transparent);
}

/* بند ۵.۳: the gallery's title is the card's main text, and has the line to
   itself above the three facts that follow it. */
.agency-purchase-title {
    flex: 1 1 100%;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.agency-purchase-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    margin: 0;
    min-width: 0;
}

.agency-purchase-line[data-purchase-line="first"] > .agency-purchase-facts {
    /* Grows from nothing rather than from its own width, so the marks stay
       on this line and it is the facts that fold when the card is narrow. */
    flex: 1 1 0;
    min-width: min(14rem, 100%);
}

/* A fact here may be as long as it is: the card is wide, and a competition's
   name cut to three dots is a name nobody can read. */
.agency-purchase-card .fi-sold-photo-fact {
    flex: 0 1 auto;
    max-width: 100%;
}

.agency-purchase-card .fi-sold-photo-fact dd {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    font-weight: 600;
}

.agency-purchase-status {
    margin-inline-start: 0.4rem;
    font-size: 0.85em;
    font-weight: 400;
    opacity: 0.75;
}

/* تسک ۰۷، بند ۵: no title above the face and the name, so the fact is the
   two of them alone, without the gap a title kept. */
.agency-purchase-photographer-fact {
    gap: 0;
}

.agency-purchase-photographer-fact dd {
    margin: 0;
}

.agency-purchase-photographer {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* The mark that carries a face pushes itself to the far end of a row of marks
   in the monitor; beside a name it stays where it is. */
.agency-purchase-photographer .fi-sold-photo-mark-photographer {
    margin-inline-start: 0;
}

/* بند ۵.۳ و ۵.۶: the three marks close the first line — at its end, on the
   line itself, without the rule they had at the foot of the narrow card. */
.agency-purchase-links {
    flex: 0 0 auto;
    margin-inline-start: auto;
    padding-top: 0;
    border-top: 0;
}

/* بند ۵.۵: three buttons of one width, one under the other, each title on one
   line. The column is as wide as its longest title and no wider. */
.agency-purchase-downloads-ctn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 0 0 auto;
    max-width: 100%;
}

.agency-purchase-downloads {
    display: grid;
    grid-template-columns: max-content;
    /* تسک ۰۷: room for a tick that sits half above a button's frame. */
    gap: 0.75rem;
    padding-top: 0.5rem;
    padding-inline-start: 0.5rem;
}

.agency-purchase-download {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.35rem 0.9rem;
    border: 1px solid color-mix(in oklab, var(--std-color-warning-400, #fbbf24) 55%, transparent);
    border-radius: 0.5rem;
    background-color: color-mix(in oklab, var(--std-color-warning-400, #fbbf24) 12%, transparent);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.agency-purchase-download svg {
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
}

/* تسک ۰۷ (۱۴۰۵/۰۸/۰۱)، بند ۴: the size this customer bought — a green disc
   with a white tick on the button's top right corner, half on the frame and
   half outside it. Absolutely placed, so the button keeps its size and
   place, and the icon and the title keep theirs. */
.agency-purchase-download {
    position: relative;
}

.agency-purchase-bought-mark {
    position: absolute;
    top: -0.55rem;
    right: -0.55rem;
    width: 1.15rem;
    height: 1.15rem;
    pointer-events: none;
    line-height: 0;
}

.agency-purchase-bought-mark svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 1px rgb(0 0 0 / 0.45));
}

.agency-purchase-bought-mark circle {
    fill: var(--std-color-success-500, #22c55e);
}

.agency-purchase-bought-mark path {
    fill: none;
    stroke: #fff;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

a.agency-purchase-download:hover {
    background-color: color-mix(in oklab, var(--std-color-warning-400, #fbbf24) 26%, transparent);
}

.agency-purchase-download-off {
    border-color: color-mix(in oklab, var(--gray-400, #9ca3af) 40%, transparent);
    background-color: transparent;
    opacity: 0.5;
    cursor: not-allowed;
}

.agency-purchase-download-reason {
    max-width: 14rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    opacity: 0.75;
}

/* بند ۵.۸: on a phone the card folds — the photograph, then the facts, then
   the buttons at the full width of the card — and nothing is dropped. */
@media (max-width: 640px) {
    .agency-purchase-photo {
        flex: 1 1 100%;
    }

    .agency-purchase-downloads-ctn {
        flex: 1 1 100%;
    }

    .agency-purchase-downloads {
        grid-template-columns: 1fr;
    }

    .agency-purchase-download-reason {
        max-width: none;
    }

    .agency-purchase-links {
        margin-inline-start: 0;
    }
}

.agency-purchase-window-link {
    margin-top: 1rem;
}

.agency-purchase-window-link a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.agency-purchase-window-link svg {
    width: 1rem;
    height: 1rem;
}

.agency-purchase-empty {
    opacity: 0.75;
}

/* A phone: the two windows keep inside the screen, and a confirmation's rows
   fold rather than squeezing a long description into half a line. */
@media (max-width: 640px) {
    .agency-credit-confirm-row {
        flex-direction: column;
        gap: 0.15rem;
    }

    .agency-credit-confirm-row dd {
        text-align: start;
    }

    .fi-customer-edit-page .fi-ta-header-ctn > .fi-ta-header-toolbar {
        margin-inline-start: auto;
    }
}

/* ——— «خریده‌ها» and «اشتراک» on the list (تسک ۰۷ ۱۴۰۵/۰۸/۰۱، بند ۳) ————————————
 *
 * Both columns are centred by the column itself (`alignCenter()`); here the
 * subscription's badge and the line under it share that one centre line, in
 * every state — a subscription, «بدون اشتراک», a long plan name.
 */
.fi-customers-list-page .fi-customer-subscription,
.fi-customers-list-page .fi-customer-subscription .fi-ta-text-item,
.fi-customers-list-page .fi-customer-subscription .fi-ta-text {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.fi-customers-list-page .fi-customer-subscription .fi-ta-col-description,
.fi-customers-list-page .fi-customer-subscription p {
    text-align: center;
}

.fi-customers-list-page .fi-customer-photo-count {
    justify-content: center;
    text-align: center;
}

/* ——— The number on «ویرایش مشترک» leads to Baligpa (تسک ۰۷، بند ۶ و ۷) ——————— */
a.agency-customer-heading-phone {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 0.25em;
}

a.agency-customer-heading-phone:hover,
a.agency-customer-heading-phone:focus-visible {
    text-decoration-style: solid;
}
