/* --- OS UI SYSTEM --- */
#desktop {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}
#windows-container {
    pointer-events: none; /* Pass clicks through empty space */
}

/* DOCK */
#dock {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 20, 30, 0.7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    padding: 8px 16px;
    display: flex;
    gap: 12px;
    pointer-events: auto;
    z-index: 1000;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dock-slogan {
    transition: all 0.2s ease;
    cursor: pointer;
}
.dock-slogan:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
}

.dock-item {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: #d0e0f0;
    position: relative;
}
.dock-item:hover {
    transform: scale(1.15) translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Specific fix for dock visualizer */
#dock-viz-container {
    overflow: hidden; /* Only hide for the viz container */
    padding: 0; 
}

#dock-visualizer {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.dock-item.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 5px;
    height: 5px;
    background: #50a0ff;
    border-radius: 50%;
    box-shadow: 0 0 8px #50a0ff;
}

/* WINDOWS */
.window {
    position: absolute;
    background: rgba(13, 17, 26, 0.9);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.1);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.25s;
    visibility: hidden;
}
.window.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
}

.window-header {
    height: 38px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    cursor: grab;
    user-select: none;
}
.window-header:active { cursor: grabbing; }

.window-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #c0d0e0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    pointer-events: none;
}

.window-controls {
    display: flex;
    gap: 8px;
}
.win-btn {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: transform 0.1s;
}
.win-btn:hover { transform: scale(1.1); }
.win-close { 
    background: #ff5f57; 
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2); 
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.win-close::after {
    content: '×';
    color: rgba(0,0,0,0.6);
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
    margin-top: -1px;
    transition: transform 0.2s ease, color 0.1s ease;
}
.win-close:hover {
    background: #ff7b72;
    transform: scale(1.15);
}
.win-close:hover::after {
    color: #fff;
    transform: rotate(90deg);
}
.win-close:active {
    transform: scale(0.95);
    background: #e04a43;
}
.win-min { background: #febc2e; box-shadow: inset 0 1px 2px rgba(0,0,0,0.2); }

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.window-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #8fa0b5;
}
.window-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.window-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ACCORDIONS */
.accordion {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 5px;
}
.accordion:last-child { border-bottom: none; }
.accordion-header {
    padding: 10px 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    color: #a0b0c0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color 0.2s, background 0.2s;
    border-radius: 6px;
}
.accordion-header:hover { color: #fff; background: rgba(255,255,255,0.03); }
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
    opacity: 0.8;
}
.accordion.open .accordion-content {
    max-height: 1200px; /* Arbitrary large height */
    opacity: 1;
    padding-bottom: 10px;
}
.accordion-icon {
    font-size: 0.7rem;
    transition: transform 0.3s;
    opacity: 0.5;
}
.accordion.open .accordion-icon { transform: rotate(180deg); }

/* CONTROLS (Adapted) */
.dock-item.mini {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    margin: 0 2px;
}
.control-group {
    margin-bottom: 12px;
    padding: 4px 6px;
}
.control-group.column {
    display: flex;
    flex-direction: column;
}
.section-title {
    display: none; /* Replaced by accordions */
}
label {
    font-size: 0.75rem;
    color: #8fa0b5;
    display: block;
    margin-bottom: 4px;
}
.value-display { float: right; color: #50a0ff; font-family: monospace; font-size: 0.75rem; }

input[type=range] {
    width: 100%; cursor: pointer; accent-color: #50a0ff;
    background: rgba(255,255,255,0.1); height: 4px; border-radius: 2px;
    appearance: none; display: block;
}
input[type=checkbox] { accent-color: #50a0ff; }

/* Presets Grid */
#preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}
.preset-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 5px;
    color: #aaa;
    cursor: pointer;
    font-size: 0.75rem;
    text-align: center;
    transition: all 0.2s;
    text-overflow: ellipsis; 
    overflow: hidden; 
    white-space: nowrap;
}
.preset-btn:hover {
    background: #50a0ff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(80, 160, 255, 0.3);
    border-color: #50a0ff;
}
.preset-btn.active {
    background: #50a0ff;
    color: white;
    border-color: #50a0ff;
    box-shadow: 0 0 12px rgba(80, 160, 255, 0.5);
}

.btn-full {
    width: 100%;
    background: linear-gradient(135deg, #204060, #102030);
    border: 1px solid rgba(80, 160, 255, 0.3);
    color: #c0d0e0;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
    font-weight: 600;
}
.btn-full:hover { filter: brightness(1.2); }

.kbd { background: #234; padding: 2px 6px; border-radius: 4px; font-weight: bold; border: 1px solid #345; }
ul.help-list { list-style: none; padding: 0; margin: 0; }
ul.help-list li { margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }

input[type=color] { border: none; width: 30px; height: 20px; background: none; cursor: pointer; }
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 20px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #50a0ff;
}
input:checked + .slider:before {
    transform: translateX(14px);
}

/* Header Controls */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.header-row h1 {
    border: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font-size: 1.0rem;
}
.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
#fps {
    font-family: monospace;
    font-size: 0.7rem;
    color: #50a0ff;
    margin-right: 10px;
}
.icon-btn {
    background: none;
    border: none;
    color: #8fa0b5;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
    line-height: 1;
}
.icon-btn:hover { color: #fff; }

/* Minimized State */
#ui.minimized {
    max-height: 50px; /* Header mostly */
    overflow: hidden;
    width: auto;
    min-width: 250px;
}
#ui.minimized > :not(.header-row):not(#preset-bar) {
    display: none;
}
/* MUSIC PLAYER */
#music-drop-zone.hover {
    background: rgba(80, 160, 255, 0.1);
    border-color: #50a0ff !important;
    box-shadow: inset 0 0 20px rgba(80, 160, 255, 0.2);
}
.player-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
}
.player-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.1);
}
.player-btn:active { transform: scale(0.95); }

.playlist-item {
    font-size: 0.7rem;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.playlist-item:hover { background: rgba(255,255,255,0.08); }
.playlist-item.active {
    background: rgba(80, 160, 255, 0.15);
    color: #50a0ff;
    border-left: 2px solid #50a0ff;
}
.playlist-item .remove-track {
    color: #ff4444;
    opacity: 0.5;
    padding: 0 4px;
}
.playlist-item .remove-track:hover { opacity: 1; }

/* MODULATORS */
.mod-link {
    background: none;
    border: none;
    color: #8fa0b5;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 5px;
    opacity: 0.3;
    transition: all 0.2s;
    float: right;
}
.mod-link:hover { opacity: 1; color: #7c3aed; transform: scale(1.2); }
.mod-link.active {
    opacity: 1;
    color: #7c3aed;
    text-shadow: 0 0 8px #7c3aed;
    animation: mod-pulse 2s infinite ease-in-out;
}

@keyframes mod-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

.control-group label {
    display: inline-block;
    width: auto;
}

/* Dock Slider (Mic Gain) */
.dock-slider-container {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 120px;
    background: rgba(16, 20, 30, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    transition-delay: 2.0s; /* Keep visible longer (2s) */
    /* pointer-events handled by visibility, but let's be safe */
}

#mic-toggle:hover .dock-slider-container,
.dock-slider-container:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    bottom: 60px;
    transition-delay: 0s; /* Appear immediately */
}

#mic-gain-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 8px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

/* Expanded Visualizer */
.vu-meters {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    padding: 5px;
    border: 1px solid rgba(255,255,255,0.05);
}

/* --- UI COMPONENTS --- */

/* Neon Buttons */
.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #c0d0e0;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(5px);
}
.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    box-shadow: 0 0 15px rgba(80, 160, 255, 0.3);
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(1px);
    box-shadow: 0 0 5px rgba(80, 160, 255, 0.2);
}
.btn.primary {
    background: rgba(80, 160, 255, 0.15);
    border-color: rgba(80, 160, 255, 0.4);
    color: #50a0ff;
}
.btn.primary:hover {
    background: rgba(80, 160, 255, 0.3);
    color: #fff;
    box-shadow: 0 0 20px rgba(80, 160, 255, 0.5);
}
.btn.danger {
    color: #ff5f57;
    border-color: rgba(255, 95, 87, 0.3);
}
.btn.danger:hover {
    background: rgba(255, 95, 87, 0.2);
    box-shadow: 0 0 15px rgba(255, 95, 87, 0.4);
    color: #fff;
}

/* Custom Modals */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
#modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: rgba(16, 20, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    min-width: 320px;
    max-width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#modal-overlay.visible .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 5px;
}
.modal-content {
    font-size: 0.9rem;
    color: #a0b0c0;
    line-height: 1.5;
}
.modal-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px; 
    color: #fff;
    width: 100%;
    margin-top: 10px;
}
.modal-input:focus {
    outline: none;
    border-color: #50a0ff;
    background: rgba(0, 0, 0, 0.5);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}
