/* ═══════════════════════════════════════════════════════════════════════
   The update file picker

   The "Update file" dropdown in every Add to Updates popup. It lives in a
   global sheet because the popup renders outside each page's own container,
   so the design tokens a page defines on that container never reach it -
   a picker styled from them came out with no border and no background.
   The picker therefore carries its own tokens.

   Markup:
     <div class="amx-update-file">
       <label class="amx-update-file-label" for="…">Update file</label>
       <select id="…" class="amx-update-file-select" required …>…</select>
       <small class="amx-update-file-help">…</small>
     </div>
   ═══════════════════════════════════════════════════════════════════════ */

.amx-update-file {
    --uf-fg: #18181b;
    --uf-muted: #71717a;
    --uf-label: #52525b;
    --uf-border: #d4d4d8;
    --uf-border-hover: #a1a1aa;
    --uf-surface: #ffffff;
    --uf-accent: #15803d;
    --uf-ring: rgba(37, 99, 235, 0.18);
    --uf-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2371717a' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");

    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

[data-theme="dark"] .amx-update-file {
    --uf-fg: #e6e9f2;
    --uf-muted: #98a2b8;
    --uf-label: #b4bccd;
    --uf-border: #34405c;
    --uf-border-hover: #56627e;
    --uf-surface: #0f1524;
    --uf-accent: #22c55e;
    --uf-ring: rgba(59, 130, 246, 0.25);
    --uf-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2398a2b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

.amx-update-file-label {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--uf-label);
}

.amx-update-file-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--uf-fg);
    background-color: var(--uf-surface);
    background-image: var(--uf-chevron);
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px 14px;
    border: 1px solid var(--uf-border);
    border-radius: 8px;
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.05);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* A text input that sits under the same label style as the picker - the optional SQL filter on
   Copy Data to Updates. Same box as the select, without the chevron. */
.amx-update-file-input {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--uf-fg);
    background-color: var(--uf-surface);
    border: 1px solid var(--uf-border);
    border-radius: 8px;
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.amx-update-file-input::placeholder {
    color: var(--uf-muted);
}

.amx-update-file-input:hover {
    border-color: var(--uf-border-hover);
}

.amx-update-file-input:focus,
.amx-update-file-input:focus-visible {
    border-color: var(--uf-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--uf-ring);
}

.amx-update-file-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--uf-fg);
}

.amx-update-file-check input {
    margin-top: 0.2rem;
    accent-color: var(--uf-accent);
}

.amx-update-file-select:hover {
    border-color: var(--uf-border-hover);
}

.amx-update-file-select:focus,
.amx-update-file-select:focus-visible {
    border-color: var(--uf-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--uf-ring);
}

/* "select file" is the empty value, which fails `required` - muted, so an
   unchosen picker reads as unchosen. */
.amx-update-file-select:invalid {
    color: var(--uf-muted);
}

.amx-update-file-select option {
    color: var(--uf-fg);
    background-color: var(--uf-surface);
}

.amx-update-file-help {
    font-size: 0.75rem;
    color: var(--uf-muted);
}

@media (forced-colors: active) {
    .amx-update-file-select {
        appearance: auto;
        -webkit-appearance: auto;
        background-image: none;
        border: 1px solid CanvasText;
    }

    .amx-update-file-select:focus {
        outline: 3px solid Highlight;
    }
}

@media (prefers-reduced-motion: reduce) {
    .amx-update-file-select {
        transition: none;
    }
}
