/* ==========================================================================
   Theme gallery — the skin chooser in Business settings.

   Styled after a desktop skin gallery: grouped bands of preview cards with the
   selected one highlighted. Reads the shell tokens so it looks right under
   whichever theme is currently active.
   ========================================================================== */

.theme-gallery {
    margin-top: 8px;
    border: 1px solid var(--line, #d5dbe5);
    border-radius: var(--r-sm, 6px);
    background: var(--surface-1, #fff);
    overflow: hidden;
}

/* Collapsed state: one row showing what is selected. */
.theme-gallery .tg-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
}

.theme-gallery .tg-summary:hover { background: var(--fill-1, rgba(15, 23, 42, .035)); }

.theme-gallery .tg-summary-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.theme-gallery .tg-summary-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1, #0f172a);
}

.theme-gallery .tg-summary-hint {
    font-size: 11px;
    color: var(--text-3, #64748b);
}

.theme-gallery .tg-summary-action {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent, #2563eb);
}

/* Expanded panel scrolls instead of pushing the rest of the form down. */
.theme-gallery .tg-panel {
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid var(--line, #d5dbe5);
}

.theme-gallery .tg-panel[hidden] { display: none; }

.theme-gallery .tg-group + .tg-group {
    border-top: 1px solid var(--line, #d5dbe5);
}

.theme-gallery .tg-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--text-2, #4b5563);
    background: var(--surface-3, #f4f6f9);
    border-bottom: 1px solid var(--line, #d5dbe5);
}

.theme-gallery .tg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    gap: 6px;
    padding: 8px;
}

.theme-gallery .tg-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm, 6px);
    cursor: pointer;
    text-align: center;
    transition: background-color .12s ease, border-color .12s ease;
}

.theme-gallery .tg-card:hover {
    background: var(--fill-1, rgba(15, 23, 42, .035));
    border-color: var(--line, #d5dbe5);
}

.theme-gallery .tg-card:focus-visible {
    outline: none;
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 3px var(--accent-soft, rgba(37, 99, 235, .15));
}

/* Selected card: the amber highlight a skin gallery uses. */
.theme-gallery .tg-card.is-selected {
    background: linear-gradient(180deg, #FFF7E0 0%, #FFE7A8 100%);
    border-color: #E0A526;
    box-shadow: inset 0 1px 0 #fff;
}

.theme-gallery .tg-card.is-selected .tg-label {
    color: #7A5306;
    font-weight: 600;
}

/* Miniature window: title bar, canvas, accent and selection chips. */
.theme-gallery .tg-preview {
    position: relative;
    display: block;
    width: 46px;
    height: 32px;
    flex: 0 0 auto;
    border: 1px solid;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .18);
}

.theme-gallery .tg-preview-bar {
    position: absolute;
    inset: 0 0 auto 0;
    height: 9px;
    display: block;
    border-bottom: 1px solid rgba(0, 0, 0, .12);
}

.theme-gallery .tg-preview-dot {
    position: absolute;
    left: 6px;
    bottom: 7px;
    width: 14px;
    height: 8px;
    display: block;
    border-radius: 2px;
}

.theme-gallery .tg-preview-sel {
    position: absolute;
    right: 6px;
    bottom: 7px;
    width: 20px;
    height: 8px;
    display: block;
    border-radius: 2px;
}

.theme-gallery .tg-label {
    font-size: 11px;
    line-height: 1.25;
    color: var(--text-2, #4b5563);
    word-break: break-word;
}

@media (max-width: 767px) {
    .theme-gallery .tg-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
        gap: 6px;
        padding: 8px;
    }

    .theme-gallery .tg-preview { width: 48px; height: 34px; }
}
