/* Dashboard Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8f9fa;
    color: #333;
    overflow-x: hidden;
}

.dashboard-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.dashboard-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-title h1 {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.header-title p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
    font-weight: 300;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-controls .control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-controls label {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.header-controls select {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.header-controls select option {
    background: #2c3e50;
    color: white;
}

.header-controls select:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-controls select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.3);
}

.header-stats {
    display: flex;
    gap: 30px;
    align-items: center;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    color: #ecf0f1;
}

.stat-label {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Navigation */
.dashboard-nav {
    background: white;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-tabs {
    display: flex;
    gap: 2px;
}

.nav-tab {
    padding: 16px 24px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.nav-tab:hover {
    color: #495057;
    background: #f8f9fa;
}

.nav-tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: #f8f9fa;
}

.nav-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: #e9ecef;
    color: #495057;
}

/* Main Content */
.dashboard-main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
    width: 100%;
}

.chart-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.chart-panel.hidden {
    display: none;
}

.panel-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.panel-header h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    color: #2c3e50;
    font-weight: 600;
}

.panel-header p {
    margin: 0;
    color: #6c757d;
    font-size: 15px;
}

.panel-controls {
    padding: 20px 30px;
    background: #ffffff;
    border-bottom: 1px solid #f1f3f4;
    display: flex;
    align-items: center;
    gap: 25px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
    white-space: nowrap;
}

.control-group select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    min-width: 150px;
}

.control-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

.toggle-group {
    display: flex;
    gap: 2px;
    background: #e9ecef;
    border-radius: 8px;
    padding: 2px;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: #3498db;
    color: white;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.toggle-btn:hover:not(.active) {
    background: #dee2e6;
    color: #495057;
}

.control-btn {
    padding: 8px 16px;
    border: 1px solid #3498db;
    border-radius: 6px;
    background: #3498db;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: #2980b9;
    border-color: #2980b9;
}

.control-btn.secondary {
    background: #6c757d;
    border-color: #6c757d;
}

.control-btn.secondary:hover {
    background: #5a6268;
    border-color: #5a6268;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.chart-container {
    min-height: 600px;
    padding: 20px;
    position: relative;
}

.scatter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    align-items: end;
}

/* Panel Summary */
.panel-summary {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

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

.summary-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.summary-item.positive .summary-value {
    color: #28a745;
}

.summary-item.negative .summary-value {
    color: #dc3545;
}

.summary-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}

.summary-label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #6c757d;
    font-size: 16px;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #495057;
}

.modal-body {
    padding: 20px 30px 30px;
}

.modal-body h4 {
    color: #2c3e50;
    margin: 20px 0 10px 0;
    font-size: 16px;
}

.modal-body h4:first-child {
    margin-top: 0;
}

.modal-body ul {
    margin: 0 0 15px 0;
    padding-left: 20px;
}

.modal-body li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Selection Panel */
.selection-panel {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 500;
    transition: all 0.3s ease;
}

.selection-panel.hidden {
    display: none;
}

.selection-header {
    padding: 15px 20px;
    background: #3498db;
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selection-header h4 {
    margin: 0;
    font-size: 16px;
}

.selection-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.selection-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.selection-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* Tooltips (Global) */
.treemap-tooltip,
.scatter-tooltip {
    position: absolute;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 8px;
    pointer-events: none;
    font-size: 13px;
    line-height: 1.4;
    max-width: 280px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.treemap-tooltip strong,
.scatter-tooltip strong {
    color: #fff;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dashboard-main {
        padding: 20px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .nav-content {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }
    
    .panel-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .scatter-controls {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        padding: 15px 20px;
    }
    
    .header-title h1 {
        font-size: 24px;
    }
    
    .header-stats {
        gap: 20px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .nav-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-tab {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .dashboard-main {
        padding: 15px;
    }
    
    .panel-header {
        padding: 15px 20px;
    }
    
    .panel-controls {
        padding: 15px 20px;
    }
    
    .chart-container {
        min-height: 400px;
        padding: 15px;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .selection-panel {
        position: fixed;
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        transform: none;
        width: auto;
    }
    
    .modal-content {
        margin: 20px;
        width: auto;
    }
}

@media (max-width: 480px) {
    .header-title h1 {
        font-size: 20px;
    }
    
    .header-stats {
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
    }
    
    .nav-tab {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .chart-container {
        min-height: 350px;
        padding: 10px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .scatter-controls {
        grid-template-columns: 1fr;
    }
    
    .control-group select {
        min-width: 100%;
    }
}

/* Print Styles */
@media print {
    .dashboard-nav,
    .panel-controls,
    .nav-controls,
    .selection-panel,
    .modal-overlay {
        display: none !important;
    }
    
    .dashboard-container {
        background: white;
    }
    
    .chart-panel {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .chart-panel {
        border: 2px solid #000;
    }
    
    .nav-tab.active {
        background: #000;
        color: #fff;
    }
    
    .control-btn {
        border: 2px solid #000;
    }
}

/* Focus Styles for Accessibility */
.nav-tab:focus,
.nav-btn:focus,
.toggle-btn:focus,
.control-btn:focus,
.control-group select:focus,
.checkbox-label input:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Animation for smooth transitions */
.chart-panel {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}