/* Custom Themes UI */

/* ----- Section inside Themes page ----- */
.custom-theme-section {
    margin-top: 1.5rem;
    width: min(620px, 92vw);
    margin-left: auto;
    margin-right: auto;
}

.custom-theme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0 0.2rem;
}

.custom-theme-header h3 {
    margin: 0;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.8;
}

.custom-theme-new {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease,
                box-shadow 0.18s ease;
}

.custom-theme-new:hover,
.custom-theme-new:focus-visible {
    background: var(--primary);
    color: var(--background);
    transform: translateY(-1px);
    box-shadow: 0 0 16px var(--glow-color-40);
    outline: none;
}

.custom-theme-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.custom-theme-action {
    background: transparent;
    border: 1px solid var(--glow-color-40);
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    opacity: 0.9;
}

.custom-theme-action:hover,
.custom-theme-action:focus-visible {
    background: var(--glow-color-40);
    border-color: var(--primary);
    color: var(--background);
    transform: translateY(-1px);
    box-shadow: 0 0 12px var(--glow-color-40);
    outline: none;
    opacity: 1;
}

.custom-theme-action[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 600px) {
    .custom-theme-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .custom-theme-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

.custom-theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.custom-theme-empty {
    margin: 0.6rem 0 0;
    color: var(--text);
    opacity: 0.6;
    font-size: 0.85rem;
    text-align: center;
}

/* ----- Custom theme chip button ----- */
.custom-theme-chip {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.7rem 0.45rem 0.5rem !important;
    position: relative;
}

.custom-theme-chip-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    flex: 0 0 auto;
}

.custom-theme-chip-label {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-theme-chip-edit {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    cursor: pointer;
    font-size: 0.65rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.custom-theme-chip-edit:hover {
    background: var(--secondary);
    color: var(--background);
    transform: scale(1.06);
}

/* ----- Editor overlay ----- */
.custom-theme-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
    z-index: 2300;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.custom-theme-overlay.visible {
    display: flex;
    opacity: 1;
}

.custom-theme-editor {
    width: min(520px, 94vw);
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(160deg, rgba(0, 0, 0, 0.97), rgba(15, 15, 22, 0.97));
    border: 1px solid var(--primary);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), 0 0 30px var(--glow-color-40);
    color: var(--text);
}

.custom-theme-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.custom-theme-editor-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.custom-theme-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--primary);
    background: rgba(0, 0, 0, 0.6);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.custom-theme-close:hover,
.custom-theme-close:focus-visible {
    background: var(--primary);
    color: var(--background);
    outline: none;
    transform: rotate(90deg);
}

.custom-theme-body {
    padding: 1rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

.custom-theme-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.custom-theme-field > span {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.7;
}

.custom-theme-field input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    padding: 0.55rem 0.8rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-theme-field input[type="text"]:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px var(--glow-color-40);
}

/* Color picker grid */
.custom-theme-color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
}

.custom-theme-color {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
}

.custom-theme-color-label {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.7;
}

.custom-theme-color-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-theme-color input[type="color"] {
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    flex: 0 0 auto;
}

.custom-theme-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border: 0; }
.custom-theme-color input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--primary);
    border-radius: 50%;
}
.custom-theme-color input[type="color"]::-moz-color-swatch {
    border: 1px solid var(--primary);
    border-radius: 50%;
}

.custom-theme-color input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    padding: 0.35rem 0.55rem;
    text-transform: lowercase;
    font-variant-numeric: tabular-nums;
}

.custom-theme-color input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* Live preview tile */
.custom-theme-preview {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    background: var(--cp-background, #0d0d12);
    color: var(--cp-text, #ddd);
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.custom-theme-preview-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cp-primary, #C0C0C0);
    text-shadow: 0 0 12px var(--cp-primary, rgba(192, 192, 192, 0.5));
}

.custom-theme-preview-row {
    display: flex;
    gap: 0.5rem;
}

.custom-theme-preview-chip {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--cp-primary, #999);
    background: var(--cp-primary, #999);
    color: var(--cp-background, #000);
    font-size: 0.8rem;
    font-weight: 600;
}

.custom-theme-preview-chip.secondary {
    background: var(--cp-secondary, #ccc);
    border-color: var(--cp-secondary, #ccc);
    color: var(--cp-background, #000);
}

.custom-theme-preview-text {
    font-size: 0.85rem;
    line-height: 1.45;
    opacity: 0.9;
}

/* Action row */
.custom-theme-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.custom-theme-actions-spacer {
    flex: 1 1 auto;
}

.custom-theme-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    padding: 0.55rem 0.95rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.custom-theme-btn:hover,
.custom-theme-btn:focus-visible {
    background: var(--primary);
    color: var(--background);
    transform: translateY(-1px);
    outline: none;
}

.custom-theme-btn-primary {
    background: var(--primary);
    color: var(--background);
    border-color: var(--secondary);
}

.custom-theme-btn-primary:hover,
.custom-theme-btn-primary:focus-visible {
    background: var(--secondary);
}

.custom-theme-btn-danger {
    border-color: #b94747;
    color: #ffbcbc;
}

.custom-theme-btn-danger:hover,
.custom-theme-btn-danger:focus-visible {
    background: #b94747;
    color: #fff;
}

/* Mobile tuning */
@media (max-width: 600px) {
    .custom-theme-color-grid { grid-template-columns: 1fr; }
}
