/* 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;
    /* Responsive height - 450px in iframe, 90vh in new tab */
    height: 450px;
    min-height: 450px;
}

/* Check if opened in new tab (larger viewport) */
@media (min-height: 600px) {
    body {
        height: 90vh;
        min-height: 90vh;
    }
}

#main-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Control Panel Styles */
#control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(90deg, #f8f9fa, #e9ecef);
    border-bottom: 2px solid #dee2e6;
    align-items: center;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px; /* Touch-friendly height */
}

.control-group label {
    font-weight: 600;
    font-size: 14px;
    color: #495057;
    white-space: nowrap;
}

/* Slider Styles */
input[type="range"] {
    width: 120px;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

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

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

/* Select Styles */
select {
    padding: 8px 12px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    min-width: 120px;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Button Styles */
button {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: #007bff;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Touch-friendly */
    min-width: 80px;
}

button:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

#reset-btn {
    background: #28a745;
}

#reset-btn:hover {
    background: #1e7e34;
}

#toggle-analytics {
    background: #6f42c1;
}

#toggle-analytics:hover {
    background: #5a32a3;
}

/* Value Display */
#incident-value {
    font-weight: bold;
    color: #007bff;
    font-size: 16px;
    min-width: 40px;
}

/* Simulation Area */
#simulation-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

#reflection-canvas {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    height: auto;
}

/* Information Panel */
#info-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    justify-content: center;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 100px;
}

.info-item .label {
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
}

.info-item span:last-child {
    font-size: 16px;
    font-weight: bold;
    color: #007bff;
}

#law-status {
    color: #28a745 !important;
}

/* Analytics Panel */
#analytics-panel {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    transition: all 0.3s ease;
    overflow: hidden;
}

#analytics-panel.collapsed {
    height: 0;
    padding: 0;
}

#analytics-panel:not(.collapsed) {
    height: 150px;
    padding: 15px;
}

#analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#analytics-header h3 {
    font-size: 16px;
    color: #495057;
}

#clear-log {
    background: #dc3545;
    font-size: 12px;
    padding: 6px 12px;
    min-height: 32px;
}

#clear-log:hover {
    background: #c82333;
}

#analytics-content {
    height: calc(100% - 40px);
    overflow-y: auto;
}

#action-log {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    color: #495057;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #e9ecef;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: #6c757d;
    font-weight: bold;
}

.log-action {
    color: #007bff;
}

.log-value {
    color: #28a745;
    font-weight: bold;
}

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

.tooltip.show {
    opacity: 1;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    #control-panel {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    
    .control-group {
        width: 100%;
        justify-content: space-between;
    }
    
    input[type="range"] {
        width: 150px;
    }
    
    #simulation-area {
        padding: 10px;
    }
    
    #reflection-canvas {
        width: 100%;
        max-width: 350px;
    }
    
    #info-panel {
        flex-direction: column;
        gap: 10px;
    }
    
    .info-item {
        flex-direction: row;
        justify-content: space-between;
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    #control-panel {
        padding: 8px;
    }
    
    .control-group label {
        font-size: 13px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    #reflection-canvas {
        max-width: 300px;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    button {
        min-height: 48px;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}