/* ==========================================================================
   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;
}

/* ==========================================================================
   Topbar theme picker (layouts/partials/header_theme_picker.blade.php)

   Chrome reads the shell tokens, so the panel matches whichever theme is on;
   the previews paint in each skin's own registry colours (--p-*).
   ========================================================================== */
.hp-picker {
    position: relative;
    display: inline-block;
}

.hp-trigger {
    gap: 8px;
    padding: 0 9px 0 7px;
}

.hp-trigger[aria-expanded="true"] {
    background: var(--fill-3);
    border-color: var(--accent-line);
    color: var(--text-1);
}

/* The live theme as a split disc: its canvas and its accent. */
.hp-trigger-swatch {
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sw-accent, var(--accent)) 0 50%, var(--sw-body, var(--app-bg)) 50% 100%);
    box-shadow: 0 0 0 1px var(--line-strong), inset 0 0 0 1px rgba(0, 0, 0, .06);
}

.hp-trigger-label {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-btn.hp-trigger .hp-trigger-chev {
    width: 14px;
    height: 14px;
    color: var(--text-3);
    transition: transform .2s ease;
}

.hp-trigger[aria-expanded="true"] .hp-trigger-chev { transform: rotate(180deg); }

.hp-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 45;
    display: flex;
    flex-direction: column;
    width: min(460px, calc(100vw - 24px));
    max-height: min(76vh, 640px);
    border-radius: var(--r-xl, 18px);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-3);
    overflow: hidden;
    text-align: left;
    animation: hp-pop .2s ease;
}

.hp-panel[hidden] { display: none; }

@keyframes hp-pop {
    from { opacity: 0; transform: translateY(-4px) scale(.985); }
}

.hp-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--line);
}

.hp-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-1);
}

.hp-hint {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-3);
}

.hp-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--r-sm, 8px);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}

.hp-close:hover { background: var(--fill-2); color: var(--text-1); }
.hp-close svg { width: 16px; height: 16px; }

.hp-scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px 16px;
}

.hp-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0 -16px;
    padding: 12px 16px 8px;
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent-hi, var(--accent));
}

.hp-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.hp-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-md, 10px);
    background: transparent;
    font: inherit;
    text-align: left;
    color: var(--text-2);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.hp-card:hover {
    background: var(--fill-1);
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.hp-card:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.hp-card.is-on {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

/* A miniature window in the skin's colours. */
.hp-prev {
    position: relative;
    display: block;
    height: 54px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--p-body);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
}

.hp-grid--stock .hp-prev { height: 64px; }

.hp-prev i { position: absolute; display: block; }
.hp-prev-bar  { left: 0; right: 0; top: 0; height: 11px; background: var(--p-top); }
.hp-prev-side { left: 0; top: 11px; bottom: 0; width: 22%; background: var(--p-top); opacity: .55; }
.hp-prev-line { left: 30%; right: 12%; top: 20px; height: 5px; border-radius: 3px; background: var(--p-sel); }
.hp-prev-line--short { right: 34%; top: 30px; opacity: .7; }
.hp-prev-btn  { right: 10%; bottom: 7px; width: 26%; height: 8px; border-radius: 4px; background: var(--p-accent); }

/* "Follow device": half light, half dark. */
.hp-prev--system { background: linear-gradient(135deg, #FCFDFD 0 50%, #0B111E 50% 100%); }
.hp-prev--system .hp-prev-bar,
.hp-prev--system .hp-prev-side { background: linear-gradient(135deg, #F1F3F6 0 50%, #2B3240 50% 100%); }
.hp-prev--system .hp-prev-btn { background: #6366F1; }

.hp-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0 2px 1px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.25;
}

.hp-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-1);
}

.hp-name em {
    margin-top: 2px;
    font-style: normal;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--accent-hi, var(--accent));
}

.hp-tick {
    position: absolute;
    top: 3px;
    right: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink, #fff);
    box-shadow: 0 3px 8px -2px var(--accent-glow);
    opacity: 0;
    transform: scale(.5);
    transition: opacity .15s ease, transform .2s cubic-bezier(.3, 1.5, .5, 1);
}

.hp-tick svg { width: 11px; height: 11px; }
.hp-card.is-on .hp-tick { opacity: 1; transform: scale(1); }

.hp-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    background: var(--surface-3);
    font-size: 12px;
    color: var(--text-3);
}

.hp-foot b { font-weight: 600; color: var(--text-1); }

.hp-foot-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.hp-link,
.hp-link:hover,
.hp-link:focus {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-decoration: none;
}

.hp-link:hover { color: var(--text-1); text-decoration: underline; }

.hp-reset {
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--accent-line);
    border-radius: 99px;
    background: var(--accent-soft);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-hi, var(--accent));
    cursor: pointer;
}

.hp-reset:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink, #fff);
}

@media (max-width: 575px) {
    .hp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hp-foot { flex-direction: column; align-items: stretch; text-align: center; }
    .hp-foot-actions { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .hp-panel { animation: none; }
    .hp-card,
    .hp-tick,
    .hp-trigger-chev { transition: none; }
}

@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; }
}
