/**
 * Developed by: GrounnyDev.com
 * Custom theme FX + admin panel
 */

.custom-theme-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.custom-fx-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(65px);
    opacity: 0.45;
    width: clamp(140px, 28vw, 280px);
    height: clamp(140px, 28vw, 280px);
    animation: custom-orb-float 18s ease-in-out infinite;
    animation-delay: calc(var(--i, 0) * -4s);
    background: var(--ct-primary, #2563eb);
}

.custom-fx-orb:nth-child(1) { top: -8%; right: -5%; background: var(--ct-primary, #2563eb); }
.custom-fx-orb:nth-child(2) { bottom: 5%; left: -8%; background: var(--ct-secondary, #7c3aed); }
.custom-fx-orb:nth-child(3) { top: 40%; left: 35%; background: var(--ct-accent, #06b6d4); width: 180px; height: 180px; }

@keyframes custom-orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(16px, -12px) scale(1.05); }
}

.custom-fx-particle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--ct-accent, #06b6d4);
    opacity: 0.6;
    animation: custom-particle-rise linear infinite;
}

.custom-fx-particle:nth-child(1) { left: 10%; animation-duration: 11s; }
.custom-fx-particle:nth-child(2) { left: 30%; animation-duration: 14s; animation-delay: -3s; }
.custom-fx-particle:nth-child(3) { left: 55%; animation-duration: 10s; animation-delay: -5s; }
.custom-fx-particle:nth-child(4) { left: 75%; animation-duration: 13s; animation-delay: -2s; }
.custom-fx-particle:nth-child(5) { left: 90%; animation-duration: 16s; animation-delay: -7s; }

@keyframes custom-particle-rise {
    0% { transform: translateY(100vh); opacity: 0; }
    15% { opacity: 0.75; }
    100% { transform: translateY(-10vh); opacity: 0; }
}

.custom-fx-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 40%,
        rgba(6, 182, 212, 0.15) 50%,
        transparent 60%
    );
    background-size: 200% 100%;
    animation: theme-shimmer-slide 5s linear infinite;
    opacity: 0.5;
}

/* Admin panel */
.themes-custom-panel {
    border-top: 1px solid #e5e7eb;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

.dark .themes-custom-panel {
    border-color: #374151;
}

.themes-custom-panel.is-hidden {
    display: none;
}

.themes-custom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.themes-custom-preview-bar {
    height: 7px;
    border-radius: 9999px;
    width: 85%;
    opacity: 0.45;
    background: linear-gradient(90deg, var(--ct-primary, #2563eb), var(--ct-accent, #06b6d4));
}

.themes-custom-preview-btn {
    display: block;
    height: 32px;
    border-radius: 0.75rem;
    width: 100%;
    margin-top: 0.15rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.themes-custom-preview-chip {
    display: none;
}

.unlock-theme-preview-custom {
    background: linear-gradient(135deg, var(--ct-primary, #2563eb), var(--ct-secondary, #7c3aed));
}

.unlock-theme-preview-custom .unlock-theme-picker-btn {
    background: linear-gradient(135deg, var(--ct-primary, #2563eb), var(--ct-accent, #06b6d4));
}

.custom-theme-fx-intensity-soft .custom-fx-orb { opacity: 0.28; filter: blur(50px); }
.custom-theme-fx-intensity-vivid .custom-fx-orb { opacity: 0.65; filter: blur(80px); }

.custom-fx-rain {
    position: absolute;
    width: 2px;
    height: 40px;
    background: linear-gradient(180deg, transparent, var(--ct-accent, #06b6d4));
    opacity: 0.35;
    animation: custom-rain-fall linear infinite;
}

.custom-fx-rain:nth-child(1) { left: 12%; animation-duration: 1.1s; }
.custom-fx-rain:nth-child(2) { left: 28%; animation-duration: 0.9s; animation-delay: -0.3s; }
.custom-fx-rain:nth-child(3) { left: 52%; animation-duration: 1.2s; animation-delay: -0.6s; }
.custom-fx-rain:nth-child(4) { left: 70%; animation-duration: 1s; animation-delay: -0.2s; }
.custom-fx-rain:nth-child(5) { left: 88%; animation-duration: 1.15s; animation-delay: -0.5s; }

@keyframes custom-rain-fall {
    0% { transform: translateY(-60px); opacity: 0; }
    15% { opacity: 0.5; }
    100% { transform: translateY(110vh); opacity: 0; }
}

.custom-fx-aurora {
    position: absolute;
    inset: -20% -10%;
    background: linear-gradient(
        120deg,
        transparent,
        color-mix(in srgb, var(--ct-primary) 35%, transparent),
        color-mix(in srgb, var(--ct-accent) 30%, transparent),
        transparent
    );
    animation: custom-aurora-shift 12s ease-in-out infinite;
    opacity: 0.5;
}

@keyframes custom-aurora-shift {
    0%, 100% { transform: translateX(-5%) skewY(-3deg); }
    50% { transform: translateX(8%) skewY(3deg); }
}

.home-theme-custom.custom-pattern-dots::before,
.unlock-theme-custom.custom-pattern-dots::before,
.maintenance-theme-custom.custom-pattern-dots::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, rgba(128, 128, 128, 0.12) 1px, transparent 1px);
    background-size: 22px 22px;
}

.home-theme-custom.custom-pattern-grid::before,
.unlock-theme-custom.custom-pattern-grid::before,
.maintenance-theme-custom.custom-pattern-grid::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(128, 128, 128, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(128, 128, 128, 0.08) 1px, transparent 1px);
    background-size: 28px 28px;
}

.home-theme-custom.custom-pattern-waves::before,
.unlock-theme-custom.custom-pattern-waves::before,
.maintenance-theme-custom.custom-pattern-waves::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: repeating-linear-gradient(
        -8deg,
        transparent,
        transparent 20px,
        rgba(128, 128, 128, 0.06) 20px,
        rgba(128, 128, 128, 0.06) 22px
    );
}

.home-theme-custom.custom-card-glass .home-card,
.unlock-theme-custom.custom-card-glass .glass-card,
.maintenance-theme-custom.custom-card-glass .maintenance-card {
    backdrop-filter: blur(12px);
}

.home-theme-custom.custom-card-outline .home-card,
.unlock-theme-custom.custom-card-outline .glass-card,
.maintenance-theme-custom.custom-card-outline .maintenance-card {
    background: transparent !important;
    border-width: 2px !important;
    border-color: var(--ct-primary) !important;
}

.home-theme-custom.custom-card-glow .home-card,
.unlock-theme-custom.custom-card-glow .glass-card,
.maintenance-theme-custom.custom-card-glow .maintenance-card {
    box-shadow: 0 0 28px color-mix(in srgb, var(--ct-primary) 35%, transparent) !important;
}

.home-theme-custom.custom-btn-pill .home-btn-primary,
.unlock-theme-custom.custom-btn-pill .unlock-btn-primary,
.unlock-theme-custom.custom-btn-pill .unlock-btn-gradient {
    border-radius: 9999px !important;
}

.home-theme-custom.custom-btn-square .home-btn-primary,
.unlock-theme-custom.custom-btn-square .unlock-btn-primary,
.unlock-theme-custom.custom-btn-square .unlock-btn-gradient {
    border-radius: 0.35rem !important;
}

/* Modal + FAB — panel nítido, sin blur sobre el contenido */
#themes-custom-modal.bubble-modal-backdrop {
    z-index: 70;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(15, 23, 42, 0.72);
}

#themes-custom-modal.bubble-modal-backdrop.hidden {
    display: none !important;
}

#themes-custom-modal .themes-custom-modal-split {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 1rem;
    width: min(96vw, 56rem);
    max-height: min(92vh, 760px);
    position: relative;
    z-index: 2;
}

#themes-custom-modal .themes-custom-modal-editor {
    position: relative;
    flex: 1 1 58%;
    min-width: 0;
    max-height: min(92vh, 760px);
    isolation: isolate;
    background-color: #ffffff;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(0, 0, 0, 0.06);
    animation: bubbleModalIn 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.dark #themes-custom-modal .themes-custom-modal-editor {
    background-color: #1e293b;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}

#themes-custom-modal .themes-custom-modal-editor .bubble-modal-bubbles {
    z-index: 0;
    opacity: 0.3;
}

#themes-custom-modal .themes-custom-modal-form {
    z-index: 3;
    position: relative;
    max-height: min(92vh, 760px);
    overflow-y: auto;
}

#themes-custom-modal .bubble-modal-close {
    z-index: 5;
}

/* Burbuja de vista previa (lateral) */
.themes-custom-preview-bubble {
    flex: 0 0 min(300px, 38vw);
    max-width: 320px;
    display: flex;
    flex-direction: column;
    animation: bubbleModalIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.06s both;
}

.themes-custom-preview-bubble-card {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 1.5rem;
    padding: 1.15rem;
    overflow: hidden;
    isolation: isolate;
    background-color: #ffffff;
    border: 1px solid rgba(124, 58, 237, 0.25);
    box-shadow:
        0 20px 45px -12px rgba(124, 58, 237, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.06);
}

.dark .themes-custom-preview-bubble-card {
    background-color: #1e293b;
    border-color: rgba(167, 139, 250, 0.35);
}

.themes-custom-preview-bubble-glow {
    position: absolute;
    inset: -30% -20%;
    background: radial-gradient(circle at 50% 30%, var(--ct-primary, #7c3aed) 0%, transparent 55%);
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
}

.themes-custom-preview-bubble-title {
    position: relative;
    z-index: 1;
    font-size: 0.875rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #7c3aed;
}

.dark .themes-custom-preview-bubble-title {
    color: #c4b5fd;
}

.themes-custom-preview-bubble-hint {
    position: relative;
    z-index: 1;
    font-size: 0.7rem;
    color: #6b7280;
    margin: 0 0 0.85rem;
    line-height: 1.35;
}

.themes-custom-preview-device {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 220px;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 0.75rem;
}

.themes-custom-preview-device-chrome {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.65rem;
    background: rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.dark .themes-custom-preview-device-chrome {
    background: rgba(255, 255, 255, 0.06);
}

.themes-custom-preview-device-chrome span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #cbd5e1;
}

.themes-custom-preview-device-chrome span:nth-child(1) { background: #f87171; }
.themes-custom-preview-device-chrome span:nth-child(2) { background: #fbbf24; }
.themes-custom-preview-device-chrome span:nth-child(3) { background: #4ade80; }

.themes-custom-preview-inner {
    position: relative;
    min-height: 180px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    justify-content: flex-end;
}

.themes-custom-preview-mock-header {
    height: 10px;
    width: 45%;
    border-radius: 9999px;
    opacity: 0.35;
    background: currentColor;
}

.themes-custom-preview-mock-card {
    padding: 0.65rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.dark .themes-custom-preview-mock-card {
    background: rgba(15, 23, 42, 0.65);
    border-color: rgba(255, 255, 255, 0.08);
}

.themes-custom-preview-bar--short {
    width: 55% !important;
}

.themes-custom-preview-swatches {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.themes-custom-preview-swatches span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

body.themes-custom-modal-open {
    overflow: hidden;
}

.themes-custom-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 55;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.15rem;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.45);
    animation: theme-btn-glow 2.5s ease-in-out infinite;
}

.themes-custom-fab.hidden {
    display: none !important;
}

.themes-custom-fab:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
}

.themes-custom-section {
    margin-bottom: 1.1rem;
}

.themes-custom-section.themes-custom-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.themes-custom-color-input {
    width: 100%;
    height: 2.75rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    padding: 0.2rem;
}

.dark .themes-custom-color-input {
    border-color: #475569;
}

.themes-custom-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.themes-custom-chip {
    cursor: pointer;
}

.themes-custom-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.themes-custom-chip span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #334155;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.dark .themes-custom-chip span {
    border-color: #475569;
    background: #0f172a;
    color: #cbd5e1;
}

.themes-custom-chip input:checked + span {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.15);
    color: #6d28d9;
}

.dark .themes-custom-chip input:checked + span {
    color: #c4b5fd;
}

.themes-custom-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.themes-custom-preset {
    display: flex;
    gap: 3px;
    padding: 0.35rem;
    border-radius: 0.65rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
}

.dark .themes-custom-preset {
    border-color: #475569;
    background: #1e293b;
}

.themes-custom-preset span {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

.themes-custom-preset:hover {
    border-color: #7c3aed;
}

@media (max-width: 900px) {
    #themes-custom-modal .themes-custom-modal-split {
        flex-direction: column;
        width: min(96vw, 28rem);
        max-height: min(94vh, 900px);
        overflow-y: auto;
    }

    #themes-custom-modal .themes-custom-modal-editor {
        flex: 0 0 auto;
        max-height: none;
    }

    #themes-custom-modal .themes-custom-modal-form {
        max-height: none;
    }

    .themes-custom-preview-bubble {
        flex: 0 0 auto;
        max-width: none;
        order: -1;
    }

    .themes-custom-preview-device {
        min-height: 160px;
    }
}

.theme-custom-card-cta {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: #7c3aed;
    text-align: center;
}

.unlock-theme-picker-card.is-active .theme-custom-card-cta {
    color: #fff;
}

@media (max-width: 520px) {
    .themes-custom-section.themes-custom-grid {
        grid-template-columns: 1fr;
    }
    .themes-custom-fab span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .custom-fx-orb,
    .custom-fx-particle,
    .custom-fx-shimmer,
    .custom-fx-rain,
    .custom-fx-aurora,
    .themes-custom-fab {
        animation: none !important;
    }
}
