/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    font-size: 14px;
    line-height: 1.4;
    height: 100vh;
    overflow: hidden;
}

/* Container setup for iframe/standalone modes */
.container {
    width: 100%;
    height: 450px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Main simulation area */
.simulation-area {
    flex: 1;
    display: flex;
    padding: 10px;
    gap: 10px;
    min-height: 0;
}

/* Controls panel */
.controls-panel {
    width: 180px;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group label {
    font-weight: 600;
    font-size: 12px;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Slider styling */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    touch-action: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4169E1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    background: #2E4BC6;
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4169E1;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Value display */
.control-group span {
    font-size: 11px;
    color: #6c757d;
    font-weight: 500;
    text-align: center;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Reset button */
.reset-button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    touch-action: manipulation;
}

.reset-button:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220,53,69,0.3);
}

.reset-button:active {
    transform: translateY(0);
}

/* Visualization container */
.visualization-container {
    flex: 1;
    background: white;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* SVG styling - Enhanced background for better shadow visibility */
#shadowSvg {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    /* Updated background with lighter floor area for better shadow contrast */
    background: linear-gradient(to bottom, #87CEEB 0%, #87CEEB 60%, #F5F5DC 60%, #F5F5DC 100%);
}

/* SVG elements */
.ground-line {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.light-source {
    filter: drop-shadow(0 0 8px #FFD700);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.light-rays {
    opacity: 0.3;
}

.shadow-object {
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
}

/* Enhanced shadow styling for much better visibility */
.shadow {
    transition: all 0.3s ease;
    /* Changed to darker color with higher opacity and added border for definition */
    fill: #1a1a1a;
    opacity: 0.85;
    stroke: #000000;
    stroke-width: 1;
    filter: blur(0.5px) drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.label {
    font-size: 10px;
    fill: #495057;
    font-weight: 600;
}

/* Measurements */
.measurements {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.measurement-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.measurement-label {
    font-size: 11px;
    font-weight: 600;
    color: #495057;
}

.measurement-item span:last-child {
    font-size: 11px;
    color: #007bff;
    font-weight: 700;
    background: #e3f2fd;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Insights panel */
.insights-panel {
    background: #fff3cd;
    border-top: 1px solid #ffeaa7;
    padding: 8px 12px;
}

.insights-header h3 {
    font-size: 12px;
    color: #856404;
    margin-bottom: 4px;
}

.insights-content {
    font-size: 11px;
    color: #856404;
    line-height: 1.3;
}

/* Analytics panel */
.analytics-panel {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.analytics-header {
    padding: 8px 12px;
    background: #e9ecef;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    user-select: none;
    transition: background-color 0.2s ease;
    min-height: 44px;
}

.analytics-header:hover {
    background: #dee2e6;
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.analytics-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.analytics-content {
    max-height: 120px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.analytics-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

.analytics-controls {
    padding: 8px 12px;
    border-bottom: 1px solid #dee2e6;
}

.clear-log-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-height: 32px;
}

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

.action-log {
    padding: 8px 12px;
    max-height: 80px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 10px;
    line-height: 1.3;
}

.timestamp {
    color: #6c757d;
    font-weight: 600;
    min-width: 35px;
}

.action {
    color: #495057;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .simulation-area {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    .controls-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
        gap: 8px;
    }
    
    .control-group {
        flex: 1;
        min-width: 120px;
    }
    
    .reset-button {
        width: 100%;
        margin-top: 8px;
    }
    
    .measurements {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .controls-panel {
        flex-direction: column;
    }
    
    .control-group {
        min-width: auto;
    }
    
    body {
        font-size: 12px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        border: 2px solid #000;
    }
    
    .slider::-webkit-slider-thumb {
        border: 2px solid #000;
    }
}