/* 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%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
}

.app-header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* Main Content Layout */
.main-content {
    display: flex;
    padding: 20px;
    gap: 20px;
    min-height: 600px;
}

.left-panel {
    flex: 0 0 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Control Sections */
.control-section {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.control-section h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    font-size: 1.2rem;
}

/* Preset Buttons */
.preset-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.preset-btn {
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: white;
    color: #333;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
}

.preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.preset-btn[data-profile="untrained"] {
    border-color: #e74c3c;
    color: #e74c3c;
}

.preset-btn[data-profile="recreational"] {
    border-color: #3498db;
    color: #3498db;
}

.preset-btn[data-profile="trained"] {
    border-color: #2ecc71;
    color: #2ecc71;
}

.preset-btn[data-profile="elite"] {
    border-color: #9b59b6;
    color: #9b59b6;
}

/* Sliders */
.slider-item {
    margin-bottom: 15px;
}

.slider-item label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.slider-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.slider-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.slider-item input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.slider-value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #2196F3;
    font-size: 0.9rem;
    margin-top: 5px;
}

.param-note {
    font-size: 0.75rem;
    color: #666;
    display: block;
    margin-top: 2px;
    font-style: italic;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.button-group.vertical {
    flex-direction: column;
}

.action-btn {
    padding: 8px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.action-btn.secondary {
    background: #6c757d;
}

.action-btn.secondary:hover {
    background: #5a6268;
}

.action-btn.full-width {
    width: 100%;
}

/* Chart Container */
.chart-container {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    color: #2c3e50;
    font-size: 1.1rem;
}

.chart-legend {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
}

/* SVG Chart */
svg {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fafafa;
}

/* Results Panel */
.results-panel {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.result-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
    border-left: 4px solid #2196F3;
}

.result-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
}

.result-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2196F3;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.result-unit {
    font-size: 0.75rem;
    color: #999;
}

/* CSV Summary */
.csv-summary {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.csv-summary h4 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.summary-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.summary-label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 5px;
}

.summary-value {
    display: block;
    font-size: 1rem;
    font-weight: bold;
    color: #2196F3;
}

/* Info Text */
.info-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
}

/* References Panel */
.references-panel {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #2196F3;
}

.reference-item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.reference-item:last-child {
    border-bottom: none;
}

.reference-item .author {
    font-weight: bold;
    color: #2c3e50;
}

.reference-item .year {
    color: #666;
}

.reference-item .formula {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #666;
    margin-top: 3px;
    background: rgba(0,0,0,0.02);
    padding: 3px 6px;
    border-radius: 3px;
}

/* Training Zones */
.zones-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.zone-item {
    padding: 10px;
    border-radius: 6px;
    color: white;
}

.zone-low {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
}

.zone-moderate {
    background: linear-gradient(135deg, #FFC107, #FF8F00);
}

.zone-high {
    background: linear-gradient(135deg, #F44336, #C62828);
}

.zone-name {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 3px;
}

.zone-range {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 3px;
}

.zone-recommendation {
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.polarized-info {
    font-size: 0.8rem;
    color: #666;
    padding: 8px;
    background: #E3F2FD;
    border-radius: 4px;
    border-left: 3px solid #2196F3;
}

/* Dual Y-axis chart containers */
.dual-chart-container {
    position: relative;
    margin-bottom: 20px;
}

.chart-y-axis {
    position: absolute;
    top: 0;
    font-size: 0.8rem;
    color: #666;
}

.chart-y-axis.left {
    left: 10px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.chart-y-axis.right {
    right: 10px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* Additional chart legend */
.multi-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 15px;
    height: 3px;
    border-radius: 1px;
}

/* Ensure chart tabs are above everything */
.chart-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
    position: relative;
    z-index: 10;
}

.chart-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 11;
}

.chart-tab:hover {
    color: #2196F3;
    background-color: rgba(33, 150, 243, 0.05);
}

.chart-tab.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
    background-color: rgba(33, 150, 243, 0.1);
}

/* Ensure chart containers are properly layered */
.chart-content {
    position: relative;
    z-index: 1;
}

.chart-content .chart-container {
    display: none;
    position: relative;
    z-index: 2;
}

.chart-content .chart-container.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Model chart headers */
.model-info {
    font-size: 0.85rem;
    color: #666;
    font-family: 'Courier New', monospace;
    margin-top: 5px;
    padding: 5px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #2196F3;
}

/* Individual chart styling */
.chart-container .formula-display {
    background: rgba(33, 150, 243, 0.1);
    padding: 10px;
    margin: 10px 0;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #2c3e50;
}

/* Model-specific color coding */
.banister-chart .chart-header {
    border-left: 4px solid #4CAF50;
}

.itrimp-chart .chart-header {
    border-left: 4px solid #FF9800;
}

.pai-chart .chart-header {
    border-left: 4px solid #9C27B0;
}

/* Parameter display for each model */
.model-params {
    display: flex;
    justify-content: space-around;
    margin: 10px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.param-display {
    text-align: center;
}

.param-label {
    font-size: 0.8rem;
    color: #666;
    display: block;
}

.param-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2196F3;
    font-family: 'Courier New', monospace;
}

/* Ensure chart containers are visible */
.chart-content .chart-container.active {
    display: block;
}

/* Ensure SVG dimensions */
svg {
    width: 100%;
    height: 500px;
    max-width: 800px;
    display: block;
    margin: 0 auto;
}

/* Make sure chart tabs work */
.chart-tab {
    cursor: pointer;
    z-index: 100;
}

.chart-tab.active {
    position: relative;
    z-index: 101;
}

.chart-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    margin: 20px 0;
}

.chart-fallback h3 {
    color: #333;
    margin-bottom: 10px;
}

.chart-fallback p {
    margin: 5px 0;
}

/* Add to existing style section in index.html */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 10px 0;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 15px;
}

.collapsible-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.collapsible-header .toggle-icon {
    font-size: 1.2rem;
    color: #2196F3;
    transition: transform 0.3s ease;
}

.collapsible-header .toggle-icon.rotated {
    transform: rotate(180deg);
}

.collapsible-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.collapsible-content.expanded {
    max-height: 1000px;
    opacity: 1;
    margin-bottom: 15px;
}

#dailyChartContainer {
    min-height: 450px;
}

/* Ensure SVG has proper dimensions */
#dailyComparisonChart {
    width: 800px;
    height: 400px;
    display: block;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

/* Make sure the container is visible when active */
.chart-container.active {
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Scientific Validation Styles */
.validation-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    border-left: 4px solid #2196F3;
}

.validation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.validation-item {
    padding: 10px;
    border-radius: 6px;
    background: white;
    border: 1px solid #dee2e6;
    border-left: 4px solid #28a745;
}

.validation-item.warning {
    border-left-color: #ffc107;
}

.validation-item.error {
    border-left-color: #dc3545;
}

.validation-label {
    font-weight: bold;
    display: block;
    color: #2c3e50;
    font-size: 0.9em;
}

.validation-value {
    color: #2196F3;
    font-weight: bold;
    font-size: 1.1em;
}

.validation-note {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
    line-height: 1.4;
}

/* Validation Report Styles */
.validation-report {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.report-header {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.report-header h4 {
    margin: 0;
    color: #2c3e50;
}

.timestamp {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 5px;
}

.parameter-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.param-item {
    display: flex;
    flex-direction: column;
}

.param-label {
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 3px;
}

.param-value {
    font-weight: bold;
    color: #2196F3;
    font-size: 1.1em;
}

.validation-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.validation-section:last-child {
    border-bottom: none;
}

.validation-section h5 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.validation-details {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-top: 10px;
}

.validation-status {
    padding: 8px 12px;
    border-radius: 6px;
    margin: 10px 0;
    font-weight: bold;
}

.validation-status.valid {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.validation-status.warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.validation-status.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.model-comparison {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9em;
}

.model-comparison th {
    background: #e9ecef;
    padding: 10px;
    text-align: left;
    font-weight: bold;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.model-comparison td {
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
}

.model-comparison tr:hover {
    background: #f8f9fa;
}

.comparison-summary {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.scientific-notes {
    margin-top: 15px;
}

.note-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 4px solid #6c757d;
}

.note-topic {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.05em;
}

.note-content {
    color: #495057;
    line-height: 1.5;
    margin-bottom: 8px;
}

.note-validation {
    color: #28a745;
    font-size: 0.9em;
    margin: 5px 0;
}

.note-limitation {
    color: #dc3545;
    font-size: 0.9em;
    margin: 5px 0;
    padding-left: 20px;
    position: relative;
}

.note-limitation:before {
    content: "⚠️";
    position: absolute;
    left: 0;
}

.note-recommendation {
    color: #17a2b8;
    font-size: 0.9em;
    margin: 5px 0;
    padding-left: 20px;
    position: relative;
}

.note-recommendation:before {
    content: "💡";
    position: absolute;
    left: 0;
}

.note-reference {
    color: #6c757d;
    font-size: 0.85em;
    margin-top: 10px;
    font-style: italic;
}

.report-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 0.9em;
}

/* Modal for detailed report */
.validation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
}

.modal-body {
    margin: 20px 0;
}

.modal-close {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 20px;
}

.modal-close:hover {
    background: #5a6268;
}

/* Style for PAI calibration slider */
#paiCalibrationValue {
    color: #9C27B0;
    font-weight: bold;
}

.slider-item:nth-child(2) {
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 10px;
}

.param-note {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-top: 3px;
    font-style: italic;
}

.validation-alert {
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 0.9rem;
}

.validation-alert.warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.validation-alert.valid {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.param-note {
    display: block;
    font-size: 0.8rem;
    color: #666;
    margin-top: 3px;
    font-style: italic;
}

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

/* Fix any potential z-index issues with charts */
svg {
    position: relative;
    z-index: 3;
}


/* Footer */
.app-footer {
    background: #2c3e50;
    color: white;
    padding: 15px;
    text-align: center;
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }

    .left-panel {
        flex: none;
        width: 100%;
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 10px;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .preset-buttons {
        grid-template-columns: 1fr;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Notification Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: #17a2b8;
    color: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification-error {
    background: #dc3545;
}

.notification-success {
    background: #28a745;
}