/*
 * 版型／模板選擇 — the list of designs and the tag each one prints.
 *
 * Shared by the two screens that ask it: 標籤列表 (a new batch's type) and 編輯列表 (a batch's
 * settings). The behaviour is in `template_picker.js`; this file is what it looks like, and it is
 * loaded by both pages rather than copied into each page's stylesheet — a rule written twice is a
 * second chance to get it wrong.
 */

.tpl-picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--color-paper-white);
    color: var(--color-absolute-black);
    text-align: left;
    cursor: pointer;
}

.tpl-picker-trigger svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--color-graphite);
}

.tpl-picker-trigger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tpl-picker-trigger[aria-expanded="true"] {
    border-color: var(--color-primary);
}

/* Above the dialog's own overlay (1400): the list hangs over the dialog it belongs to. */
.tpl-picker-menu {
    position: fixed;
    z-index: 1450;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px;
    max-width: min(560px, calc(100vw - 20px));
    background: var(--color-paper-white);
    border: 1px solid var(--color-silver-mist);
    border-radius: var(--radius-inputs);
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.35);
}

.tpl-picker-menu[hidden] {
    display: none;
}

.tpl-picker-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 196px;
    max-height: 268px;
    overflow-y: auto;
    flex-shrink: 0;
}

.tpl-picker-option {
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.35;
    color: var(--color-absolute-black);
    cursor: pointer;
}

.tpl-picker-option.is-active {
    background: var(--color-light-gray);
}

.tpl-picker-option[aria-selected="true"] {
    font-weight: 700;
}

.tpl-picker-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}

/* A card is white, so it is shown on paper grey rather than on the dialog's own white. */
.tpl-picker-shot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 300px;
    height: 220px;
    padding: 6px;
    border-radius: 8px;
    background: var(--surface-muted);
    overflow: hidden;
}

.tpl-picker-shot img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tpl-picker-shot img[hidden],
.tpl-picker-note[hidden],
.tpl-picker-spinner[hidden] {
    display: none;
}

/* The line that says a picture is a copy rather than the design as it stands now. It sits under the
   picture and out of the shot, so a reader looking at a card always has the sentence beside it. */
.tpl-picker-saved {
    margin: 0;
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--color-sky-tint);
    color: var(--color-graphite);
    font-size: 0.74rem;
    line-height: 1.45;
    text-align: center;
}

.tpl-picker-saved[hidden] {
    display: none;
}

.tpl-picker-note {
    max-width: 190px;
    color: var(--color-graphite);
    font-size: 0.78rem;
    line-height: 1.5;
    text-align: center;
}

.tpl-picker-spinner {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid var(--color-silver-mist);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin var(--motion-spin) linear infinite;
}

.tpl-picker-preview figcaption {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-graphite);
    text-align: center;
    min-height: 1.2em;
}

/* A phone has no room for a list and a picture side by side, and no hover to reveal one: the picture
   is above the list, where choosing a name still shows what it prints. */
@media (max-width: 620px) {
    .tpl-picker-menu {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .tpl-picker-list {
        width: 100%;
        max-height: 200px;
    }

    .tpl-picker-shot {
        width: 100%;
        height: 160px;
    }
}
