/* 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;
    line-height: 1.6;
    /* Responsive height based on environment */
    height: 450px;
    overflow-y: auto;
}

/* Check if running in new tab vs iframe */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main container */
.container {
    width: 100%;
    height: 100%;
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 15px;
    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);
}

/* Controls panel styling */
.controls-panel {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

/* Dropdown styling */
.dropdown {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 44px; /* Touch-friendly size */
}

.dropdown:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.dropdown:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Checkbox styling */
.checkbox-group {
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.checkbox-label:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    margin-right: 12px;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background-color: #667eea;
    border-color: #667eea;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 14px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Reset button styling */
.reset-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(238, 90, 82, 0.3);
    min-height: 44px;
    margin-top: auto;
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 82, 0.4);
}

.reset-button:active {
    transform: translateY(0);
}

/* Scenario panel */
.scenario-panel {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background: #e3f2fd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.scenario-info h3 {
    color: #1565c0;
    margin-bottom: 15px;
    font-size: 18px;
}

.scenario-info p {
    margin-bottom: 8px;
    font-size: 14px;
    color: #424242;
}

/* Results panel */
.results-panel {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    background: #f1f8e9;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.results-panel h3 {
    color: #2e7d32;
    margin-bottom: 20px;
    font-size: 18px;
    text-align: center;
}

.method-section {
    margin-bottom: 25px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.method-section h4 {
    color: #1b5e20;
    margin-bottom: 10px;
    font-size: 16px;
}

.formula-tooltip {
    margin-bottom: 15px;
    cursor: help;
}

.formula {
    font-size: 12px;
    color: #666;
    font-style: italic;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.year-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #4caf50;
}

.year {
    font-weight: 600;
    color: #2e7d32;
}

.amount {
    font-weight: 700;
    color: #1b5e20;
    font-size: 16px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        gap: 10px;
        padding: 10px;
    }
    
    .controls-panel {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        padding: 15px;
    }
    
    .scenario-panel {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
        padding: 15px;
    }
    
    .results-panel {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
        padding: 15px;
    }
    
    .dropdown, .reset-button {
        min-height: 48px; /* Larger touch targets on mobile */
    }
}

/* Tooltip styling */
[title] {
    position: relative;
}

/* Animation for value changes */
.amount {
    transition: all 0.3s ease;
}

.amount.updated {
    animation: highlight 0.6s ease;
}

@keyframes highlight {
    0% { background-color: #ffeb3b; }
    100% { background-color: transparent; }
}