/* ========================================
   FRACTALLA - Custom Controls Panel
   Modern UI replacing dat.GUI
   ======================================== */

.controls-panel {
    position: fixed;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
    width: 280px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    z-index: 1000;
    font-family: 'Outfit', sans-serif;
    animation: fadeInRight 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* ========================================
   CONTROL SECTIONS - Collapsible Cards
   ======================================== */

.control-section {
    background: rgba(10, 10, 18, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 12px;
    margin-bottom: .3rem;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    transition: all 0.3s ease;
    overflow: hidden;
}

.control-section:hover {
    border-color: rgba(25, 242, 255, 0.3);
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    cursor: pointer;
    user-select: none;
    background: rgba(25, 242, 255, 0.05);
    border-bottom: 1px solid rgba(25, 242, 255, 0.15);
    transition: all 0.2s ease;
}

.section-header:hover {
    background: rgba(25, 242, 255, 0.1);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.section-header h3 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #e1dd8a;
    margin: 0;
}

.collapse-btn {
    background: none;
    border: none;
    color: #e1dd8a;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.control-section.collapsed .collapse-btn {
    transform: rotate(-90deg);
}

/* Section Content */
.section-content {
    padding: 16px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.control-section.collapsed .section-content {
    max-height: 0;
    padding: 0 16px;
}

/* ========================================
   CONTROL GROUPS - Individual Controls
   ======================================== */

.control-group {
    margin-bottom: 8px;
    position: relative;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

/* ========================================
   DROPDOWNS / SELECT
   ======================================== */

.control-group select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 8px;
    color: var(--divine-white);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.control-group select:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: var(--aurora-cyan);
    box-shadow: 0 0 10px rgba(25, 242, 255, 0.2);
}

.control-group select:focus {
    border-color: var(--aurora-cyan);
    box-shadow: 0 0 15px rgba(25, 242, 255, 0.3);
}

/* ========================================
   SLIDERS
   ======================================== */

.slider-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-control input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    position: relative;
}

/* Slider Track */
.slider-control input[type="range"]::-webkit-slider-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border-radius: 10px;
}

.slider-control input[type="range"]::-moz-range-track {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

/* Slider Thumb */
.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--aurora-cyan);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(25, 242, 255, 0.6);
    transition: all 0.2s ease;
    border: 2px solid rgba(10, 10, 18, 0.8);
}

.slider-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--aurora-cyan);
    cursor: pointer;
    border: 2px solid rgba(10, 10, 18, 0.8);
    box-shadow: 0 0 10px rgba(25, 242, 255, 0.6);
    transition: all 0.2s ease;
}

.slider-control input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(25, 242, 255, 0.8);
}

.slider-control input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(25, 242, 255, 0.8);
}

/* Value Display */
.value-display {
    font-family: 'Rajdhani', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--aurora-cyan);
    min-width: 50px;
    text-align: right;
    text-shadow: 0 0 8px rgba(25, 242, 255, 0.4);
}

/* ========================================
   TOGGLE SWITCHES
   ======================================== */

.toggle-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch.active {
    background: var(--aurora-cyan);
    border-color: var(--aurora-cyan);
    box-shadow: 0 0 15px rgba(25, 242, 255, 0.4);
}

.toggle-switch.active::before {
    left: 26px;
    background: var(--divine-white);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.toggle-switch:hover {
    border-color: var(--aurora-cyan);
}

/* ========================================
   ACTION BUTTONS
   ======================================== */

.action-btn {
    width: 100%;
    padding: 10px 16px;
    background: rgba(25, 242, 255, 0.1);
    border: 1px solid rgba(25, 242, 255, 0.3);
    border-radius: 8px;
    color: var(--aurora-cyan);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn-share {
    background: rgb(4, 139, 168) !important;
    color: #fff;
}

.action-btn:last-child {
    margin-bottom: 0;
}

.action-btn:hover {
    background: rgba(25, 242, 255, 0.15);
    border-color: var(--aurora-cyan);
    transform: translateX(2px);
    box-shadow: 0 0 15px rgba(25, 242, 255, 0.2);
}

.action-btn:active {
    transform: translateX(0) scale(0.98);
}

/* Primary action button variant */
.action-btn.primary {
    background: linear-gradient(135deg, rgba(25, 242, 255, 0.15), rgba(167, 139, 250, 0.15));
    border-color: var(--spirit-purple);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, rgba(25, 242, 255, 0.2), rgba(167, 139, 250, 0.2));
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.3);
}

/* ========================================
   COLOR PICKERS
   ======================================== */

.color-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-control label {
    min-width: 60px;
    margin-bottom: 0;
    white-space: nowrap;
}

.color-control input[type="color"] {
    width: 50px;
    height: 32px;
    border: 2px solid rgba(167, 139, 250, 0.3);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-control input[type="color"]:hover {
    border-color: var(--aurora-cyan);
    box-shadow: 0 0 10px rgba(25, 242, 255, 0.3);
}

.color-control input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-control input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

/* JSColor text input styling */
.color-control input[type="text"] {
    width: 70px;
    height: 32px;
    padding: 6px 8px;
    border: 2px solid rgba(167, 139, 250, 0.3);
    border-radius: 8px;
    color: var(--divine-white);
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}

.color-control input[type="text"]:hover,
.color-control input[type="text"]:focus {
    border-color: var(--aurora-cyan);
    box-shadow: 0 0 10px rgba(25, 242, 255, 0.3);
}

.color-control .color-value {
    font-family: monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    min-width: 70px;
    text-align: left;
    flex-shrink: 0;
}

/* Hide jscolor's default button/swatch if it appears */
.color-control .jscolor-btn,
.color-control button[class*="jscolor"] {
    display: none !important;
}

/* Ensure no extra borders or elements from jscolor */
.color-control .jscolor-wrap {
    border: none !important;
}

/* ========================================
   SCROLLBAR (for controls panel)
   ======================================== */

.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(25, 242, 255, 0.3);
    border-radius: 3px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(25, 242, 255, 0.5);
}

/* ========================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .controls-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .controls-panel.collapsed {
        transform: translateY(calc(100% - 60px));
    }
}