@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;700;900&display=swap');

:root {
    --bg-dark: #05050c;
    --panel-bg: rgba(8, 8, 20, 0.55);
    --panel-border: rgba(255, 255, 255, 0.07);
    --glow-color: rgba(0, 240, 255, 0.6);
    --glow-color-alt: rgba(255, 0, 127, 0.6);
    --accent-cyan: #00f0ff;
    --accent-pink: #ff007f;
    --accent-purple: #9d4edd;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0ba;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    z-index: 10;
    transition: transform var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1), 
                opacity var(--transition-speed) ease,
                visibility var(--transition-speed) ease;
}

/* Control Panel (Sidebar) */
#control-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 340px;
    max-height: calc(100vh - 40px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

#control-panel::-webkit-scrollbar {
    width: 6px;
}
#control-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Header Info */
.header h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.header p {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* Collapsible toggle button */
#toggle-panel-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    z-index: 11;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 25, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    transform: scale(0); /* starts hidden, will show when panel is closed */
}

#toggle-panel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.close-btn {
    align-self: flex-end;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color 0.2s ease;
}
.close-btn:hover {
    color: var(--accent-pink);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Control Groups */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-left: 2px solid var(--accent-pink);
    padding-left: 8px;
    margin-bottom: 4px;
}

/* Inputs & Labels */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-primary);
}

.slider-val {
    color: var(--accent-cyan);
    font-family: monospace;
    font-size: 11px;
}

/* Custom Range Input styling */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 15px var(--accent-cyan);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent-cyan);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 15px var(--accent-cyan);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: var(--accent-cyan);
}

/* Select Styling */
.select-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.select-container label {
    font-size: 12px;
    color: var(--text-primary);
}

select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

select:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background-color: rgba(255, 255, 255, 0.08);
}

select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

/* Preset & Button grids */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

button {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(1px);
}

button.preset-btn.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.15);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Action Buttons (Action bar) */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn-main {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
    border: none;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(255, 0, 127, 0.2);
    color: #05050c;
}

.action-btn-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.3), 0 0 12px rgba(255, 0, 127, 0.2);
    background: linear-gradient(135deg, #00ffff, #ff00a2);
}

.action-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
}

/* Audio Status & Audio Reactive Settings */
.audio-reactive-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.audio-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audio-title {
    font-size: 13px;
    font-weight: 600;
}

.audio-desc {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.slider-switch:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

input:checked + .slider-switch {
    background-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

input:checked + .slider-switch:before {
    transform: translateX(20px);
}

/* Bottom status info overlay */
#bottom-overlay {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 12px;
    z-index: 10;
}

.status-tag {
    padding: 8px 12px;
    font-size: 11px;
    letter-spacing: 0.5px;
    background: rgba(10, 10, 25, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    animation: pulse 2s infinite;
}

.pulse-dot.pulse-audio {
    background-color: var(--accent-pink);
    box-shadow: 0 0 8px var(--accent-pink);
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

/* Quick instructions top right */
#shortcut-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.kbd {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
    color: var(--text-primary);
}

/* Modal Overlay for Audio permission prompt */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 3, 10, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    max-width: 440px;
    padding: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-radius: 24px;
}

.modal-icon {
    font-size: 48px;
    animation: float 4s ease-in-out infinite;
}

.modal-content h2 {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-content p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* UI Hide utility class */
.ui-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden;
}

/* CSS Toast notifications */
#toast-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
}

.toast {
    background: rgba(10, 10, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: translateY(20px);
    opacity: 0;
    animation: toast-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes toast-in {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #control-panel {
        width: calc(100% - 40px);
        max-height: 60vh;
        top: auto;
        bottom: 20px;
    }
    
    #shortcut-overlay {
        display: none;
    }
}
