/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #D5BAA1;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
}

/* Header */
.header {
    grid-column: 1 / -1;
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #2d3748;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: #718096;
    font-size: 16px;
}

/* Controls Panel */
.controls-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

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

.control-section h3 {
    color: #2d3748;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: all 0.3s ease;
}

.collapsible-header:hover {
    color: #667eea;
}

.collapse-icon {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.collapsible-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

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

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #4a5568;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-label:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.radio-label input[type="radio"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: #667eea;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #4a5568;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Mini checkbox for advanced panels */
.checkbox-label-mini {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 12px;
    color: #4a5568;
    padding: 4px 0;
}

.checkbox-label-mini input[type="checkbox"] {
    margin-right: 6px;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.checkbox-label-mini span {
    line-height: 1.3;
}

/* Mini buttons for select all/none */
.btn-mini {
    padding: 4px 10px;
    font-size: 11px;
    background: #e2e8f0;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    cursor: pointer;
    color: #4a5568;
    transition: all 0.2s;
    margin-left: 4px;
}

.btn-mini:hover {
    background: #cbd5e0;
    color: #2d3748;
}

/* Advanced features panel */
.advanced-features-panel {
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.status-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    display: none;
}

.status-message.loading {
    display: block;
    background: #bee3f8;
    color: #2c5282;
}

.status-message.success {
    display: block;
    background: #c6f6d5;
    color: #22543d;
}

.status-message.error {
    display: block;
    background: #fed7d7;
    color: #742a2a;
}

/* Content Area */
.content-area {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #718096;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #4a5568;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    flex: 1;
}

.tab-content.active {
    display: block;
}

/* Metrics Panel */
.metrics-panel {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

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

.metric-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.metric-label {
    font-size: 12px;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
}

.metric-value.good {
    color: #38a169;
}

.metric-value.bad {
    color: #e53e3e;
}

/* Metrics Table */
.metrics-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.metrics-table thead {
    background: #2d3748;
}

.metrics-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}

.metrics-table tbody tr:last-child td {
    border-bottom: none;
}

.metrics-table tbody tr:hover {
    background: #f7fafc;
}

.metrics-table .metric-name {
    font-weight: 600;
    color: #2d3748;
}

.metrics-table .metric-ai {
    color: #e53e3e;
    font-weight: 600;
}

.metrics-table .metric-legacy {
    color: #ed8936;
    font-weight: 600;
}

.metrics-table .metric-improvement {
    font-weight: 700;
}

.metrics-table .metric-improvement.good {
    color: #38a169;
    background: #c6f6d5;
}

.metrics-table .metric-improvement.bad {
    color: #e53e3e;
    background: #fed7d7;
}

.metrics-table td.good {
    color: #38a169;
}

.metrics-table td.bad {
    color: #e53e3e;
}

.metrics-table .metric-best {
    font-weight: 700;
    text-align: center;
}

.metrics-table .metric-best.best-ai {
    color: #3182ce;
    background: #e6f2ff;
}

.metrics-table .metric-best.best-legacy {
    color: #805ad5;
    background: #f0e6ff;
}

/* Chart */
#forecastChart {
    min-height: 600px;
}

/* Table View */
.table-controls {
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-end;
}

.month-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.month-tab-btn {
    padding: 8px 16px;
    background: #e2e8f0;
    border: none;
    border-radius: 6px;
    color: #4a5568;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.month-tab-btn:hover {
    background: #cbd5e0;
}

.month-tab-btn.active {
    background: #667eea;
    color: white;
}

.table-container {
    overflow-x: auto;
}

.monthly-summary {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.monthly-summary h3 {
    color: #2d3748;
    margin-bottom: 15px;
}

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

.summary-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
}

.summary-label {
    font-size: 11px;
    color: #718096;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

/* Sub-tabs for table views */
.table-sub-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.table-sub-tab-btn {
    padding: 8px 16px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    color: #4a5568;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.table-sub-tab-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.table-sub-tab-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Monthly summary table */
.monthly-overview-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.monthly-overview-table th {
    background: #2d3748;
    color: white;
    padding: 12px;
    text-align: left;
    font-size: 13px;
}

.monthly-overview-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #2d3748;
}

.monthly-overview-table tbody tr:hover {
    background: #f7fafc;
}

.error-positive {
    color: #e53e3e;
    font-weight: 600;
}

.error-negative {
    color: #38a169;
    font-weight: 600;
}

.cell-best-error {
    background-color: #c6f6d5 !important;
    color: #22543d !important;
    font-weight: 700 !important;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #2d3748;
    color: white;
}

th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    color: #2d3748;
}

tbody tr:hover {
    background: #f7fafc;
}

.cell-actual {
    background: #f7fafc;
}

.cell-chronos {
    background: #fff5f0;
}

.cell-legacy {
    background: #eff6ff;
}

.cell-error-good {
    background: #c6f6d5;
    color: #22543d;
    font-weight: 600;
}

.cell-error-bad {
    background: #fed7d7;
    color: #742a2a;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
    font-size: 18px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive */
@media (max-width: 1400px) {
    .container {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        max-height: none;
    }
}
