/* Metatron Visualizer - Main Styles */

/* Base Styles */
body { 
    margin: 0; 
    overflow: hidden; 
    font-family: 'Rajdhani', 'Orbitron', sans-serif; 
    color: #fff; 
    background: #000; 
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Container */
#container { 
    position: relative; 
    width: 100vw; 
    height: 100vh; 
    background: #000; 
}

/* View Controls */
.view-controls { 
    position: absolute; 
    top: 20px; 
    left: 20px; 
    z-index: 1000; 
    display: flex; 
    gap: 10px; 
}

.icon-button { 
    background: rgba(45,45,77,0.7); 
    border: none; 
    color: white; 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    cursor: pointer; 
    transition: all 0.3s; 
    backdrop-filter: blur(10px); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.icon-button:hover { 
    background: rgba(61,61,109,0.7); 
    transform: translateY(-2px); 
}

.icon-button.active { 
    background: rgba(100, 255, 218, 0.3); 
    color: #64ffda; 
}

/* Control Panel */
#controls {
    position: fixed;
    left: 32px;
    top: 80px;
    background: rgba(20, 25, 40, 0.75);
    border-radius: 18px;
    backdrop-filter: blur(25px) saturate(1.4);
    box-shadow: 
        0 8px 32px rgba(0,0,0,0.4), 
        0 2px 12px rgba(78,205,196,0.15),
        inset 0 1px 0 rgba(255,255,255,0.1);
    border: 1.5px solid rgba(78,205,196,0.25);
    width: 350px;
    max-width: 98vw;
    box-sizing: border-box;
    max-height: 90vh;
    z-index: 2000;
    transition: box-shadow 0.3s ease, background 0.3s ease;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Changed from overflow-y: auto */
}

#controls.dragging {
    box-shadow: 
        0 15px 50px rgba(0,0,0,0.5), 
        0 5px 20px rgba(78,205,196,0.25),
        inset 0 1px 0 rgba(255,255,255,0.15);
    background: rgba(20, 25, 40, 0.85);
    cursor: grabbing;
    transform: scale(1.02);
    /* Disable all transitions during dragging for smooth performance */
    transition: none !important;
}

/* Panel Header - Fixed at top, always draggable with button styling */
.panel-header { 
    font-family: 'Orbitron', monospace;
    font-size: 1.1em;
    font-weight: 600;
    color: #64ffda;
    text-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
    margin: 18px 14px 18px 14px;
    padding: 12px 16px;
    text-align: left;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0; /* Don't shrink header */
    cursor: grab; /* Make header draggable */
    
    /* Button-like styling */
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    border: 1px solid rgba(78,205,196,0.3);
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    user-select: none;
}

.panel-header:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(78,205,196,0.15);
}

.panel-header:active {
    cursor: grabbing;
    transform: translateY(0);
    background: rgba(255,255,255,0.1);
}

/* Panel Content Area - Scrollable */
.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 18px 18px 18px; /* Adjusted to match header margins */
    /* Reserve space for scrollbar to prevent layout shift */
    scrollbar-gutter: stable;
    /* Allow text selection in content area */
    user-select: text;
    /* Hide scrollbar by default, show only when needed */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar completely by default but reserve space */
.panel-content::-webkit-scrollbar {
    width: 6px;
    background: transparent;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: transparent; /* Hidden by default */
    border-radius: 3px;
    transition: background 0.3s ease;
}

/* Show scrollbar only when scrolling or hovering */
.panel-content.scrolling::-webkit-scrollbar-thumb,
.panel-content:hover::-webkit-scrollbar-thumb {
    background: rgba(78,205,196,0.3);
}

.panel-content.scrolling::-webkit-scrollbar-thumb:hover,
.panel-content:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(78,205,196,0.5);
}

.section-header { 
    font-family: 'Orbitron', monospace;
    font-size: 1.1em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    letter-spacing: 0.8px;
    color: #b8e0e6;
    text-shadow: 0 0 10px rgba(184, 224, 230, 0.2);
}

/* Panel Sections */
.panel-section {
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid rgba(78,205,196,0.13);
}

.panel-section:last-child {
    border-bottom: none;
}

/* Control Groups */
.control-group {
    margin-bottom: 18px;
}

.control-group label {
    margin-bottom: 7px;
    color: #c8e8ee;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: 0.95em;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.collapsible-content {
    padding-left: 2px;
}

/* Collapsible Elements */
.collapsible { 
    background: none; 
    border: none; 
    color: #fff; 
    font-family: 'Orbitron', monospace;
    font-size: 1.05em; 
    width: 100%; 
    text-align: left; 
    padding: 12px 0; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: rgba(78,205,196,0.2);
    touch-action: manipulation;
}

.collapsible:hover, .collapsible:focus { 
    background: linear-gradient(135deg, rgba(78,205,196,0.15), rgba(68,160,141,0.15)); 
    border-radius: 6px;
    color: #4ecdc4;
    text-shadow: 0 0 10px rgba(78,205,196,0.3);
    transform: translateX(3px);
    padding-left: 4px;
    padding-right: 4px;
    margin-left: -4px;
    margin-right: -4px;
}

.collapsible:after { 
    content: '\25C0'; 
    font-size: 0.8em; 
    margin-left: auto; 
    transition: transform 0.2s; 
}

.collapsible.active:after { 
    transform: rotate(-90deg); 
}

.collapsible-content { 
    display: none; 
}

.collapsible-content.active { 
    display: block; 
}

/* Form Elements */
.shader-select { 
    width: 100%; 
    padding: 8px; 
    background: #2d2d4d; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
}

.shader-select option { 
    background: #2d2d4d; 
    color: white; 
}

.shader-select:hover, .shader-select:focus { 
    background: #3d3d6d; 
}

button { 
    background: #2d2d4d; 
    border: none; 
    color: white; 
    padding: 8px 16px; 
    border-radius: 4px; 
    cursor: pointer; 
    transition: all 0.3s; 
}

button:hover, button:focus { 
    background: #3d3d6d; 
    transform: translateY(-2px); 
}

input[type="range"] { 
    width: 100%; 
    background: #2d2d4d; 
    margin: 4px 0; 
}

input[type="color"] { 
    width: 50px; 
    height: 30px; 
    border: none; 
    background: none; 
}

/* Utility Classes */
.color-group { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}

.small-label { 
    font-size: 0.8em; 
    color: #888; 
    margin-top: 8px; 
}

.sub-controls { 
    margin-top: 8px; 
    padding-left: 10px; 
    border-left: 2px solid rgba(78,205,196,0.2); 
}

/* Back to Top Button */
#backToTopBtn {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 2000;
    background: #2d2d4d;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    font-size: 1.3em;
    cursor: pointer;
    transition: background 0.2s;
}

/* Radial Dial Styles */
.radial-dial {
    text-align: center;
    cursor: grab;
    user-select: none;
}

.radial-dial:active {
    cursor: grabbing;
}

.dial-progress {
    transition: stroke-dashoffset 0.1s ease;
}

.file-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4em 0.6em;
    border-radius: 4px;
    margin-bottom: 0.3em;
    background: #232323;
    transition: background 0.2s;
    min-height: 32px; /* Ensure consistent height */
}

.file-list-item .file-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0; /* Allow text to shrink */
    cursor: pointer;
}

.file-list-item .file-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.file-remove-btn {
    background: none;
    border: none;
    color: #ff6b6b;
    font-size: 1.1em;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 2px;
    transition: background 0.2s;
    flex-shrink: 0; /* Prevent button from shrinking */
    margin-left: 8px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-remove-btn:hover {
    background: #444;
    color: #ff8a8a;
}

/* Mobile Responsive Styles */
@media (max-width: 600px) {
    .view-controls {
        position: fixed;
        top: 0;
        left: 8px;
        z-index: 3000;
    }
    
    #controls {
        position: fixed;
        left: 8px;
        right: 8px;
        top: 64px;
        width: auto;
        border-radius: 18px;
        padding: 24px 6px 18px 6px;
        max-height: calc(100vh - 80px);
        height: auto;
        background: rgba(30, 30, 50, 0.85) !important;
        box-shadow: 0 8px 32px rgba(0,0,0,0.28);
        overflow-y: auto;
        z-index: 2000;
        transition: transform 0.3s ease-out, box-shadow 0.2s, background 0.2s;
    }
    
    #controls.hide-panel {
        transform: translateY(100vh) !important;
        transition: transform 0.3s ease-out;
    }
    
    .panel-section {
        margin-bottom: 16px;
        padding-bottom: 8px;
    }
    
    .control-group {
        margin-bottom: 12px;
    }
    
    .collapsible {
        font-size: 1em !important;
        padding: 12px 0 !important;
        min-height: 44px !important;
    }
}

/* Checkbox labels - allow text to wrap when panel is narrow */
#controls label {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure checkboxes and icons don't shrink */
#controls input[type="checkbox"],
#controls label i {
    flex-shrink: 0;
}

/* Prevent horizontal overflow */
#controls {
    overflow-x: hidden;
}

/* Mobile Panel Positioning */
@media (max-width: 768px) {
    #controls {
        left: 8px !important;
        top: 60px !important;
        width: calc(100vw - 16px) !important;
        max-width: 360px !important;
        right: auto !important;
    }
    
    .view-controls {
        top: 10px !important;
        left: 10px !important;
        gap: 8px !important;
    }
    
    .icon-button {
        width: 36px !important;
        height: 36px !important;
    }
}

/* Hidden Elements */
#videoInput { 
    display: none; 
}
