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

/* Container with responsive height */
.container {
    width: 100%;
    height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr 200px;
    grid-template-rows: 1fr auto;
    grid-template-areas: 
        "controls visualization values"
        "analytics analytics analytics";
    gap: 10px;
    padding: 10px;
}

/* Iframe-specific height adjustment */
@media (max-height: 500px) {
    .container {
        height: 450px;
    }
}

/* Control panel styling */
.control-panel {
    grid-area: controls;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

/* Slider styling */
#angleSlider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 10px;
}

#angleSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4ecdc4;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

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

/* Radio buttons and checkboxes */
input[type="radio"], input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

/* Angle buttons */
.angle-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.angle-btn {
    background: #4ecdc4;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 44px;
}

.angle-btn:hover {
    background: #45b7b8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

/* Reset button */
.reset-btn {
    width: 100%;
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
}

.reset-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Visualization area */
.visualization {
    grid-area: visualization;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

#unitCircle {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* Values panel */
.values-panel {
    grid-area: values;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.value-item {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #4ecdc4;
}

.label {
    font-weight: 600;
    color: #666;
    display: block;
    margin-bottom: 5px;
}

.value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

/* Analytics panel */
.analytics-panel {
    grid-area: analytics;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-height: 100px;
}

.analytics-header {
    font-weight: 700;
    margin-bottom: 10px;
    color: #333;
    font-size: 14px;
}

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

.analytics-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.analytics-label {
    color: #666;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    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;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto auto;
        grid-template-areas: 
            "controls"
            "visualization"
            "values"
            "analytics";
        height: 90vh;
    }
    
    .control-panel {
        padding: 10px;
    }
    
    .angle-buttons {
        justify-content: center;
    }
    
    .angle-btn {
        flex: 1;
        min-width: 50px;
    }
    
    .analytics-content {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .values-panel {
        display: flex;
        justify-content: space-around;
        padding: 10px;
    }
    
    .value-item {
        margin-bottom: 0;
        flex: 1;
        margin-right: 10px;
        text-align: center;
    }
    
    .value-item:last-child {
        margin-right: 0;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .angle-btn, .reset-btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    #angleSlider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    #angleSlider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}

/* Animation classes */
.highlight {
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}