/* 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;
    overflow-x: hidden;
}

/* Container setup for iframe/standalone detection */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Detect if running in new tab (not iframe) */
@media (min-height: 600px) {
    .container {
        height: 90vh;
        padding: 16px;
        gap: 12px;
    }
}

/* Control Panel */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: space-between;
}

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

.control-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

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

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

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

/* Dropdown styling */
.dropdown {
    padding: 6px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease;
    min-height: 44px; /* Touch target size */
}

.dropdown:focus {
    border-color: #4CAF50;
    outline: none;
}

/* Button styling */
.control-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #2196F3;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Touch target size */
    min-width: 80px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn.active {
    background: #4CAF50;
}

/* Simulation Area */
.simulation-area {
    flex: 1;
    display: flex;
    gap: 12px;
    min-height: 200px;
}

#reflectionCanvas {
    flex: 1;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: crosshair;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: auto;
}

/* Enhanced cursor states for draggable canvas */
#reflectionCanvas.dragging {
    cursor: grabbing !important;
}

#reflectionCanvas.hovering {
    cursor: grab !important;
}

/* Measurement Panel */
.measurement-panel {
    min-width: 140px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.measurement-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.measurement-item .label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

.measurement-item span:last-child {
    font-size: 16px;
    font-weight: 700;
    color: #2196F3;
}

.law-statement {
    margin-top: 8px;
    padding: 8px;
    background: #e8f5e8;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    color: #2e7d32;
    font-size: 12px;
}

/* Analytics Panel */
.analytics-panel {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.analytics-header {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    text-align: center;
    cursor: help;
}

.analytics-content {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 10px;
    color: #666;
}

.stat-item span:last-child {
    font-size: 14px;
    font-weight: 700;
    color: #FF5722;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 6px;
        gap: 6px;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    .control-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        min-width: 60px;
        font-size: 11px;
        padding: 10px 8px;
    }
    
    .simulation-area {
        flex-direction: column;
        gap: 8px;
    }
    
    .measurement-panel {
        min-width: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 8px;
    }
    
    .analytics-content {
        justify-content: space-between;
    }
    
    .stat-item {
        flex: 1;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
        font-size: 14px;
    }
    
    .slider {
        height: 8px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .dropdown {
        min-height: 48px;
        font-size: 14px;
    }
}