/* ============================================================================
   AMI Theme Settings Panel
   ========================================================================== */

.ami-theme-panel {
    --panel-w: min(420px, calc(100vw - 2rem));
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--ami-base) var(--ami-ease),
                visibility var(--ami-base) var(--ami-ease);
}

.ami-theme-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ami-theme-panel__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ami-theme-panel__dialog {
    position: relative;
    width: var(--panel-w);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--ami-surface);
    border: 1px solid var(--ami-border);
    border-radius: var(--ami-r-lg);
    box-shadow: var(--ami-sh-lg);
    transform: translateY(12px) scale(0.98);
    transition: transform var(--ami-base) var(--ami-ease);
}

.ami-theme-panel.is-open .ami-theme-panel__dialog {
    transform: translateY(0) scale(1);
}

.ami-theme-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.35rem 0.75rem;
    border-bottom: 1px solid var(--ami-divider);
}

.ami-theme-panel__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ami-text);
}

.ami-theme-panel__subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.78rem;
    color: var(--ami-text-muted);
}

.ami-theme-panel__close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--ami-r-sm);
    background: transparent;
    color: var(--ami-text-muted);
    cursor: pointer;
    transition: background var(--ami-fast), color var(--ami-fast);
}

.ami-theme-panel__close:hover {
    background: rgba(var(--ami-brand-rgb), 0.08);
    color: var(--ami-text);
}

.ami-theme-panel__body {
    padding: 1rem 1.35rem 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.ami-theme-section__label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ami-text-muted);
    margin-bottom: 0.55rem;
}

.ami-theme-preset-groups {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.ami-theme-preset-group__label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--ami-text-faint);
    margin-bottom: 0.4rem;
    padding-inline-start: 0.1rem;
}

.ami-theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.55rem;
}

.ami-theme-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.35rem;
    border: 2px solid transparent;
    border-radius: var(--ami-r-md);
    background: var(--ami-surface-2);
    cursor: pointer;
    transition: border-color var(--ami-fast), transform var(--ami-fast);
}

.ami-theme-preset:hover {
    transform: translateY(-1px);
}

.ami-theme-preset.is-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px rgba(var(--ami-brand-rgb), 0.15);
}

.ami-theme-preset__swatch {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    box-shadow: var(--ami-sh-sm);
}

.ami-theme-preset__name {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ami-text-muted);
    text-align: center;
}

.ami-theme-colors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.ami-theme-color-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ami-theme-color-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ami-text-2);
}

.ami-theme-color-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--ami-border);
    border-radius: var(--ami-r-sm);
    background: var(--ami-surface-2);
}

.ami-theme-color-input-wrap input[type="color"] {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.ami-theme-color-input-wrap input[type="text"] {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.78rem;
    font-family: monospace;
    color: var(--ami-text);
    outline: none;
}

.ami-theme-mode {
    display: flex;
    gap: 0.45rem;
}

.ami-theme-mode-btn {
    flex: 1;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--ami-border);
    border-radius: var(--ami-r-sm);
    background: var(--ami-surface-2);
    color: var(--ami-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ami-fast);
}

.ami-theme-mode-btn:hover {
    border-color: rgba(var(--ami-brand-rgb), 0.3);
    color: var(--ami-text);
}

.ami-theme-mode-btn.is-active {
    border-color: var(--primary-color);
    background: rgba(var(--ami-brand-rgb), 0.08);
    color: var(--primary-color);
}

.ami-theme-preview {
    border-radius: var(--ami-r-md);
    overflow: hidden;
    border: 1px solid var(--ami-border);
    box-shadow: var(--ami-sh-sm);
}

.ami-theme-preview__bar {
    height: 2.5rem;
    background: var(--ami-grad-sidebar);
}

.ami-theme-preview__content {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem;
    background: var(--ami-canvas);
}

.ami-theme-preview__card {
    flex: 1;
    height: 2.5rem;
    border-radius: var(--ami-r-sm);
    background: var(--ami-surface);
    border: 1px solid var(--ami-border);
}

.ami-theme-preview__accent {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--ami-r-sm);
    background: var(--ami-grad-brand);
}

.ami-theme-panel__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.ami-theme-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--ami-r-sm);
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--ami-fast);
}

.ami-theme-btn--ghost {
    background: transparent;
    color: var(--ami-text-muted);
    border: 1px solid var(--ami-border);
}

.ami-theme-btn--ghost:hover {
    color: var(--ami-text);
    border-color: var(--ami-border-strong);
}

.ami-theme-btn--primary {
    background: var(--ami-grad-brand);
    color: var(--ami-on-brand);
    box-shadow: var(--ami-sh-brand);
}

.ami-theme-btn--primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}
