/* 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%);
    height: 100vh;
    overflow: hidden;
}

/* Main container - responsive height */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Adjust height when not in iframe */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Simulation area */
.simulation-area {
    flex: 1;
    position: relative;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
    border-bottom: 2px solid #ddd;
}

#simulationCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

/* Angle display overlay */
.angle-display {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-weight: bold;
    min-width: 120px;
}

.angle-value {
    color: #2196F3;
    font-size: 1.2em;
    margin: 0 5px;
}

.angle-type {
    color: #4CAF50;
    font-size: 0.9em;
}

/* Control panel */
.control-panel {
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.control-label {
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
    white-space: nowrap;
}

/* Button groups */
.button-group {
    display: flex;
    gap: 5px;
}

.control-btn {
    padding: 8px 12px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 36px;
}

.control-btn:hover {
    background: #f0f0f0;
    border-color: #2196F3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.control-btn.active {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

/* Slider controls */
.slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.position-slider {
    width: 150px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.position-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #2196F3;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.move-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.move-btn:hover {
    background: #f0f0f0;
    border-color: #2196F3;
}

.move-btn:active {
    transform: scale(0.95);
}

.distance-display {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

/* Action buttons */
.action-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    min-height: 40px;
}

.reset-btn {
    background: #FF5722;
    color: white;
}

.reset-btn:hover {
    background: #E64A19;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255,87,34,0.3);
}

.help-btn {
    background: #4CAF50;
    color: white;
}

.help-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

/* Results panel */
.results-panel {
    background: #f8f9fa;
    padding: 12px 15px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid #ddd;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.result-label {
    font-size: 0.8em;
    color: #666;
    font-weight: 500;
}

.result-value {
    font-size: 1em;
    font-weight: bold;
    color: #333;
    margin-top: 2px;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content ul {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Feedback overlay */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: bold;
    display: none;
    z-index: 100;
    text-align: center;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .control-group {
        justify-content: space-between;
        width: 100%;
    }
    
    .button-group {
        flex: 1;
        justify-content: space-around;
    }
    
    .control-btn {
        flex: 1;
        min-width: 0;
        font-size: 0.8em;
        padding: 6px 8px;
    }
    
    .position-slider {
        width: 120px;
    }
    
    .results-panel {
        padding: 8px 10px;
    }
    
    .result-item {
        min-width: 70px;
    }
    
    .result-label {
        font-size: 0.75em;
    }
    
    .result-value {
        font-size: 0.9em;
    }
}

/* Touch-friendly sizing */
@media (pointer: coarse) {
    .control-btn, .move-btn, .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .position-slider {
        height: 8px;
    }
    
    .position-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
}