/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    height: 100vh;
    overflow: hidden;
}

/* ========================================
   LAYOUT STRUCTURE
   ======================================== */
.app-container {
    display: flex;
    height: 100vh;
}

/* ========================================
   CONTROL PANEL
   ======================================== */
.control-panel {
    width: 350px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 1001;
}

.panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.panel-header h1 {
    font-size: 20px;
    margin-bottom: 5px;
}

.panel-header p {
    font-size: 12px;
    opacity: 0.9;
}

/* ========================================
   CONTROL SECTIONS
   ======================================== */
.control-section {
    border-bottom: 1px solid #eee;
}

.section-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.section-header:hover {
    background: #e9ecef;
}

.section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.section-toggle {
    font-size: 12px;
    color: #6c757d;
}

.section-content {
    padding: 20px;
    display: none;
}

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

.section-content.dimmed {
    opacity: 0.5;
}

/* ========================================
   FORM CONTROLS
   ======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select,
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

input[type="checkbox"] {
    margin: 0;
}

/* ========================================
   RANGE SLIDERS
   ======================================== */
.slider-container {
    margin-bottom: 20px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.slider-value {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    background: #f8f9ff;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 50px;
    text-align: center;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-block {
    width: 100%;
}

/* ========================================
   LIGHT DIRECTIONS GRID
   ======================================== */
.light-directions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.light-direction-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.light-direction-item label {
    font-size: 11px;
    margin-bottom: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.light-direction-item input[type="range"] {
    height: 4px;
    margin: 2px 0;
}

.weight-value {
    color: #667eea;
    font-weight: 600;
    min-width: 25px;
    text-align: center;
}

/* ========================================
   COLOR CONTROLS
   ======================================== */
.color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.color-preview {
    flex-grow: 1;
    height: 40px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #6c757d;
}

/* ========================================
   MAP CONTAINER
   ======================================== */
.map-container {
    flex-grow: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* ========================================
   STATUS BAR
   ======================================== */
.status-bar {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.status-item {
    text-align: center;
}

.status-label {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.status-value {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

/* ========================================
   LOADING & MESSAGES
   ======================================== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message {
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.message.info {
    background: #e7f3ff;
    color: #0f5132;
    border: 1px solid #b6d7ff;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* ========================================
   RENDERING STATUS INDICATOR
   ======================================== */
.rendering-status-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    border: 2px solid rgba(255,255,255,0.8);
    cursor: pointer;
}

.rendering-status-indicator.ready {
    background: linear-gradient(135deg, #28a745, #20c997);
    animation: none;
}

.rendering-status-indicator.busy {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    animation: pulse-busy 1.5s ease-in-out infinite;
}

.rendering-status-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    transition: all 0.3s ease;
}

.rendering-status-indicator.busy::before {
    animation: inner-pulse 1.5s ease-in-out infinite;
}

.rendering-status-indicator:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.rendering-status-indicator[title] {
    cursor: help;
}

@keyframes pulse-busy {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

@keyframes inner-pulse {
    0%, 100% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
.mobile-toggle {
    display: none;
}

@media (max-width: 768px) {
    .control-panel {
        width: 300px;
        position: absolute;
        left: -300px;
        transition: left 0.3s ease-in-out;
        z-index: 1002;
    }

    .control-panel.open {
        left: 0;
    }

    .mobile-toggle {
        position: absolute;
        top: 20px;
        left: 20px;
        z-index: 1001;
        background: white;
        border: none;
        padding: 10px;
        border-radius: 6px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        cursor: pointer;
        display: block !important;
    }
}