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

/* Main container - responsive height */
.container {
    display: grid;
    grid-template-columns: 280px 1fr 250px;
    grid-template-rows: 1fr;
    height: 100vh;
    gap: 10px;
    padding: 10px;
    max-width: 100%;
}

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

@media (min-height: 501px) {
    .container {
        height: 90vh;
    }
}

/* Left panel: Controls */
.controls-panel {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow-y: auto;
    border: 2px solid #e1e8ed;
}

.control-section {
    margin-bottom: 20px;
}

.control-section h3 {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 5px;
    border-bottom: 2px solid #3498db;
}

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

.control-group label {
    font-size: 12px;
    font-weight: 500;
    color: #34495e;
    cursor: help;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    transition: all 0.3s ease;
}

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

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

.value-display {
    font-size: 11px;
    color: #7f8c8d;
    text-align: center;
    font-weight: 500;
}

/* Button styles */
.button-group {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: #e74c3c;
    color: white;
}

.btn-primary:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

/* Center panel: Graph */
.graph-panel {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid #e1e8ed;
}

#economicGraph {
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    background: #fafafa;
    max-width: 100%;
    height: auto;
}

.explanation-box {
    margin-top: 10px;
    padding: 10px;
    background: #ecf0f1;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    width: 100%;
}

.explanation-box p {
    font-size: 12px;
    color: #2c3e50;
    line-height: 1.4;
    margin: 0;
}

/* Right panel: Data */
.data-panel {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 2px solid #e1e8ed;
    overflow-y: auto;
}

.data-panel h3 {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 5px;
    border-bottom: 2px solid #e74c3c;
}

.comparison-table {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 15px;
}

.data-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px;
    padding: 6px;
    border-radius: 4px;
    font-size: 10px;
    align-items: center;
}

.header-row {
    background: #34495e;
    color: white;
    font-weight: 600;
}

.data-row:not(.header-row) {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.data-row:not(.header-row):nth-child(even) {
    background: #ffffff;
}

.equilibrium-points {
    margin-top: 10px;
}

.point-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    margin-bottom: 4px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 11px;
}

.point-label {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    color: white;
}

.point-label.e1 {
    background: #7f8c8d;
}

.point-label.e2 {
    background: #e67e22;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        height: 100vh;
        gap: 5px;
        padding: 5px;
    }
    
    .controls-panel {
        padding: 10px;
    }
    
    .control-section {
        margin-bottom: 15px;
    }
    
    .button-group {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .btn {
        flex: 1;
        min-width: 80px;
    }
    
    #economicGraph {
        width: 100%;
        height: 200px;
    }
    
    .data-row {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2px;
    }
    
    .data-row span {
        padding: 2px;
    }
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .slider {
        height: 8px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 12px;
        min-height: 44px;
    }
}

/* Tooltip styles */
[title] {
    position: relative;
    cursor: help;
}

/* Animation classes for smooth transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}