/* UI/UX polish, RTL precision, and compact mobile-first refinements */

/* 1. Unified custom select styling (eliminates duplicate native arrows) */
.field select,
.filter select,
.account-popover select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-inline-end: 34px;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23536175' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
}

.field select::picker-icon,
.filter select::picker-icon,
.account-popover select::picker-icon {
    display: none;
}

html[dir="rtl"] .field select,
html[dir="rtl"] .filter select,
html[dir="rtl"] .account-popover select {
    background-position: left 10px center;
}

/* 2. Refined input focus states & form alignment */
.field {
    text-align: start;
}

.field input,
.field select,
.field textarea,
.search,
.filter select {
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        background-color 140ms ease;
}

.field input:hover:not(:disabled),
.field select:hover:not(:disabled),
.field textarea:hover:not(:disabled),
.search:hover,
.filter select:hover {
    border-color: #b8c4d6;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search:focus,
.filter select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(40, 93, 169, 0.14);
}

/* 3. Equalized grid card heights & subtle elevation */
.dashboard-grid,
.manager-overview,
.dashboard-analytics {
    align-items: stretch;
}

.dashboard-grid > .panel,
.manager-overview > .panel,
.dashboard-analytics > .panel {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

.dashboard-grid {
    margin-bottom: 16px;
}

.workspace .stat {
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease,
        transform 150ms ease;
}

.workspace .stat:hover {
    border-color: #c2cfe0;
    box-shadow: 0 4px 12px rgba(24, 35, 52, 0.06);
    transform: translateY(-1px);
}

/* 4. Strict RTL/LTR table alignment & inline table controls */
table,
th,
td {
    text-align: start;
}

.table-person {
    justify-content: flex-start;
}

td .text-btn {
    padding: 4px 10px;
    border-radius: 6px;
    transition: background-color 120ms ease, color 120ms ease;
}

td .text-btn:hover {
    background: var(--active-surface);
    color: var(--active-ink);
    text-decoration: none;
}

td .tag + .text-btn,
td .text-btn + .tag {
    margin-inline-start: 8px;
}

/* 5. Thaana pill breathing room & distinct schedule category tags */
html[lang="dv"] .tag,
html[lang="dv"] .live-pill {
    padding: 4px 10px;
    line-height: 1.62;
}

.slide-categories {
    gap: 6px;
    margin-block-start: 8px;
}

.slide-categories .tag {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 3px 9px;
}

/* 6. Range slider fill direction matches dir="ltr" (0 on left -> max on right) */
html[dir="rtl"] .score-range {
    --range-track: linear-gradient(
        to right,
        var(--score-color, var(--brand)) 0 var(--fill),
        #dce3ed var(--fill) 100%
    );
}

/* 7. Sidebar ergonomics & Account Popover polish */
.sidebar .brand {
    padding: 4px 7px 11px;
    margin-bottom: 8px;
}

.sidebar-section {
    margin-block-start: 14px;
}

.side-bottom {
    padding-top: 14px;
    padding-bottom: 4px;
}

.account-popover {
    max-height: calc(100dvh - 80px);
    min-width: 268px;
    padding: 12px 14px;
}

.account-popover:popover-open {
    gap: 10px;
}

.account-popover .btn,
.account-popover .account-footer .btn {
    width: 100%;
    justify-content: center;
}

.account-popover .account-menu {
    display: grid;
    gap: 8px;
}

/* 8. Compact empty states */
.panel .empty {
    padding: 20px 16px;
}

/* 9. Drawer & Modal sticky footer + clean single scroll */
dialog {
    overflow: hidden;
    flex-direction: column;
}

dialog[open] {
    display: flex;
}

.dialog-body {
    overflow-y: auto;
    flex: 1 1 auto;
}

dialog .form-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-block-start: 1px solid var(--line);
    padding-block: 12px 4px;
    margin-block: 12px -4px;
    z-index: 2;
}

/* 10. Equal-height action buttons & compact mobile-first layout */
.page-head .actions > .btn {
    align-self: stretch;
}

@media (max-width: 650px) {
    dialog:not(.drawer) {
        width: 95vw;
        max-width: 95vw;
        max-height: 90dvh;
        border-radius: 14px;
    }

    dialog.drawer {
        width: 100vw;
        max-width: 100vw;
    }

    .dialog-head {
        padding: 12px 14px;
        min-height: 52px;
    }

    .dialog-body {
        padding: 12px 14px 16px;
    }

    .main {
        padding: 16px 12px 32px;
    }

    .panel-head {
        padding: 12px 14px;
    }

    .panel-body {
        padding: 12px 14px;
    }

    .page-head {
        margin-block-end: 14px;
        gap: 10px;
    }

    .page-head .actions {
        gap: 8px;
        align-items: stretch;
    }

    .page-head .actions > .btn {
        height: 100%;
        padding: 8px 10px;
    }

    .stat {
        padding: 11px 12px;
        min-height: 92px;
    }

    .operations-table tbody tr {
        padding: 12px;
        gap: 8px 12px;
    }

    .operations-table tbody td[data-label] {
        justify-items: start;
        align-items: start;
        text-align: start;
    }

    .operations-table tbody td:last-child {
        padding-block-start: 8px;
        border-block-start: 1px dashed var(--line);
    }

    .operations-table tbody td:last-child .text-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 40px;
        padding: 7px 12px;
        background: var(--subtle);
        border: 1px solid var(--line);
        border-radius: 8px;
        color: var(--ink);
    }

    html[lang="en"] .operations-table tbody td::before {
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-size: 0.7rem;
    }
}

/* 11. Live performance timer pill */
.live-timer {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.live-timer svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.public-live-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

/* 12. Quick filter chips (Registrations status & Public schedule days) */
.quick-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 11px 15px 0;
}

.quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 4px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 600;
    transition:
        background-color 130ms ease,
        border-color 130ms ease,
        color 130ms ease;
}

.quick-chip:hover {
    background: var(--subtle);
    color: var(--ink);
    border-color: #c2cfe0;
}

.quick-chip.active {
    background: var(--active-surface);
    border-color: #9bb8e3;
    color: var(--active-ink);
}

/* 13. Public schedule highlights strip */
.public-highlights {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-block: 0 18px;
}

.highlight-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}

.highlight-card > div {
    min-width: 0;
}

.highlight-card strong {
    display: block;
    font-size: 1.02rem;
    line-height: 1.38;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.highlight-card small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.highlight-action {
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        transform 140ms ease;
}

.highlight-action:hover {
    border-color: #9bb8e3;
    box-shadow: 0 4px 12px rgba(24, 35, 52, 0.07);
    transform: translateY(-1px);
}

/* 14. Judge quick-mark preset chips */
.score-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-block-start: 8px;
}

.preset-chip {
    min-height: 30px;
    min-width: 44px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--subtle);
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 650;
    transition:
        background-color 120ms ease,
        border-color 120ms ease;
}

.preset-chip:hover {
    background: var(--hover);
    border-color: #b8c4d6;
}

.preset-chip.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

@media (max-width: 760px) {
    .public-highlights {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
        margin-block-end: 14px;
    }

    .highlight-card {
        padding: 10px 11px;
        gap: 9px;
    }

    .quick-chips {
        padding: 10px 12px 0;
    }
}

