/* Modern financial dashboard styling */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-bg: #f5f7fa;
    --dark-text: #2c3e50;
    --light-text: #ecf0f1;
    
    /* Enhanced severity colors */
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #3498db;
    --neutral-color: #7f8c8d;
    
    /* Updated professional meter colors */
    --meter-danger: #e63946;      /* 0-30: Recession - red */
    --meter-warning: #f9844a;     /* 30-45: Below-trend - orange */
    --meter-neutral: #f8c537;     /* 45-55: Normal - yellow */
    --meter-good: #90be6d;        /* 55-70: Strong - light green */
    --meter-excellent: #43aa8b;   /* 70-100: Very strong - dark green */
    
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --ai-color: #8e44ad;
    
    /* Standardized spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background-color: var(--light-bg);
}

header {
    background: linear-gradient(to right, var(--primary-color), #34495e);
    color: var(--light-text);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-lg);
    flex-wrap: nowrap;
}

.logo-section {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.8s ease-in-out;
    flex-shrink: 1;
    min-width: 0;
}

.logo-section h1 {
    margin: 0;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.logo-icon {
    margin-right: 0.5rem;
    color: #3498db;
    animation: pulse 2s infinite;
    font-size: 1.5rem;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-top: 0.2rem;
}

/* Main Navigation */
.main-nav {
    margin: 0 1rem;
    flex-grow: 1;
    flex-shrink: 1;
}

.main-nav ul {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    justify-content: center;
}

.main-nav li {
    margin: 0 0.2rem;
}

.main-nav a {
    color: var(--light-text);
    text-decoration: none;
    padding: 0.6rem 0.8rem;
    display: block;
    transition: all 0.2s;
    border-radius: 4px;
    font-size: 0.9rem;
}

.main-nav a i {
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.main-nav li.active a {
    background-color: rgba(255, 255, 255, 0.1);
}

.main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Dropdown Menu */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 10;
    border-radius: 4px;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.dropdown-content a {
    color: var(--dark-text);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid #f5f5f5;
}

.dropdown-content a:hover {
    background-color: #f8f9fa;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Language Selector Styles */
.language-selector {
    position: relative;
}

.language-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.language-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.language-toggle i {
    margin-right: 5px;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    display: none;
    z-index: 1000;
    min-width: 140px;
    overflow: hidden;
}

.language-option {
    display: block;
    padding: 8px 15px;
    color: var(--dark-text);
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.language-option:hover {
    background-color: #f5f5f5;
}

.language-option.active {
    background-color: #f0f0f0;
    font-weight: 600;
}

.language-selector:hover .language-dropdown {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

.last-updated-badge {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    display: inline-block;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive header */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-xs);
    }
    
    .logo-section {
        margin-bottom: var(--space-xs);
        width: 100%;
    }
    
    .main-nav {
        width: 100%;
        overflow-x: auto;
        margin-top: var(--space-xs);
    }
    
    .main-nav ul {
        flex-wrap: nowrap;
        width: max-content;
    }
    
    .main-nav a {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: var(--space-xs);
    }
    
    .language-toggle {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    
    .language-dropdown {
        right: 0;
        min-width: 120px;
    }
    
    .language-option {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .dropdown-content {
        right: 0;
    }
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
}

/* Section common styles - standardize spacing */
.health-section,
.commentary-section,
.data-section,
.charts-section {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

/* Health Meter Styling */
.health-section h2,
.commentary-section h2,
.data-section h2,
.charts-section h2 {
    margin-bottom: var(--space-md);
    color: var(--primary-color);
}

.health-meter {
    margin: var(--space-md) auto;
    max-width: 600px;
}

.meter-container {
    height: 20px;
    background-color: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

.meter-fill {
    height: 100%;
    background: linear-gradient(to right, 
        var(--meter-danger) 0%, 
        var(--meter-warning) 30%, 
        var(--meter-neutral) 45%,
        var(--meter-good) 55%,
        var(--meter-excellent) 70%);
    border-radius: 10px;
    transition: width 1s ease-in-out;
}

.meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

.meter-label {
    text-align: center;
    width: 20%;
    font-size: 0.8rem;
    font-weight: 500;
}

.meter-label.recession {
    color: var(--meter-danger);
    text-align: left;
}

.meter-label.below {
    color: var(--meter-warning);
}

.meter-label.normal {
    color: var(--meter-neutral);
}

.meter-label.strong {
    color: var(--meter-good);
}

.meter-label.excellent {
    color: var(--meter-excellent);
    text-align: right;
}

.health-description {
    font-size: 1.2rem;
    margin: var(--space-md) 0;
    font-weight: 500;
}

.last-updated {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    margin-top: var(--space-md);
}

/* Indicators Table Styling with improved mobile responsiveness */
.indicators-table {
    width: 100%;
    border-collapse: collapse;
}

.indicators-table th {
    background-color: #f8f9fa;
    padding: 10px 15px;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid #ddd;
}

.indicators-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.indicator-name {
    font-weight: 600;
}

.indicator-value {
    font-family: monospace;
    font-size: 1.1em;
    position: relative;
    height: 40px;
    vertical-align: middle;
}

.trend {
    display: inline-block;
    margin-left: 5px;
    font-weight: bold;
}

.trend.up {
    color: var(--success-color);
}

.trend.down {
    color: var(--danger-color);
}

.trend.neutral {
    color: #6c757d;
}

.change {
    font-size: 0.8em;
    color: #6c757d;
    margin-left: 3px;
}

/* Chart error message */
.chart-error {
    padding: var(--space-md);
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
    border-radius: 4px;
    text-align: center;
    margin: var(--space-md) 0;
}

/* Mobile table improvements */
@media (max-width: 768px) {
    main {
        padding: var(--space-sm);
    }
    
    .health-section,
    .commentary-section,
    .data-section,
    .charts-section {
        padding: var(--space-sm);
        margin-bottom: var(--space-md);
    }
    
    /* Responsive table layout */
    .data-section {
        overflow-x: hidden; /* Hide horizontal scroll on container */
    }
    
    .indicators-table {
        display: block;
        width: 100%;
        overflow-x: auto; /* Allow table to scroll horizontally */
        -webkit-overflow-scrolling: touch;
    }
    
    /* Card-based layout for mobile */
    .indicators-table, .indicators-table tbody, .indicators-table tr {
        display: block;
        width: 100%;
    }
    
    .indicators-table thead {
        display: none; /* Hide headers on mobile */
    }
    
    .indicators-table tr {
        margin-bottom: var(--space-md);
        border: 1px solid #eee;
        border-radius: 8px;
        padding: var(--space-xs);
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .indicators-table td {
        display: flex;
        text-align: right;
        padding: 8px 10px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .indicators-table td:last-child {
        border-bottom: none;
    }
    
    .indicators-table td::before {
        content: attr(data-label);
        font-weight: bold;
        text-align: left;
        flex: 1;
        color: var(--primary-color);
    }
    
    .indicator-value {
        height: auto;
        min-height: 24px;
    }
    
    /* Tooltip fixes for mobile */
    .tooltip-content {
        width: 200px;
        padding: 6px;
        font-size: 0.65em;
        line-height: 1.2;
    }
}

footer {
    background-color: var(--primary-color);
    color: var(--light-text);
    text-align: center;
    padding: var(--space-md);
    margin-top: var(--space-lg);
}

/* Data Export Button */
.export-buttons {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
    justify-content: flex-end;
}

.export-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s;
}

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

.export-btn i {
    font-size: 1rem;
}

/* Export Status Message */
#export-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 9999;
    font-weight: 500;
    display: flex;
    align-items: center;
}

#export-status::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top: 2px solid white;
    border-radius: 50%;
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

#export-status.active {
    opacity: 1;
    transform: translateY(0);
}

/* Dashboard Controls Styling */
.dashboard-controls {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.dashboard-controls h2 {
    margin-bottom: var(--space-sm);
    color: var(--primary-color);
    font-size: 1.3rem;
}

.control-group {
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid #eee;
}

.control-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.control-group h3 {
    font-size: 1rem;
    margin-bottom: var(--space-xs);
    color: var(--dark-text);
}

/* Time Period Selector */
.time-period-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--space-xs);
}

.period-btn {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.period-btn.active {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.custom-date-range {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: var(--space-xs);
    align-items: center;
}

.custom-date-range label {
    font-size: 0.9rem;
}

.custom-date-range input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9rem;
}

.custom-date-range button,
.apply-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.custom-date-range button:hover,
.apply-btn:hover {
    background-color: #2980b9;
}

/* Indicators Toggle */
.indicators-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: var(--space-sm);
}

.indicator-toggle-item {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.indicator-toggle-item label {
    margin-left: 5px;
    font-size: 0.9rem;
}

/* Improved mobile styling for controls */
@media (max-width: 768px) {
    .time-period-selector,
    .custom-date-range,
    .indicators-toggle {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .period-btn {
        width: 100%;
        text-align: center;
    }
    
    .custom-date-range {
        width: 100%;
    }
    
    .custom-date-range input[type="date"] {
        width: 100%;
    }
    
    .custom-date-range button,
    .apply-btn {
        width: 100%;
    }
    
    .indicators-toggle {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .indicator-toggle-item {
        width: 100%;
    }
}

/* Tooltip styles */
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #555;
    font-size: 11px;
    font-weight: bold;
    margin-left: 5px;
    cursor: help;
}

.tooltip-content {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffffff;
    color: #333333;
    border-radius: 6px;
    padding: 10px 12px;
    width: auto;
    min-width: 200px;
    max-width: 280px;
    font-size: 0.75rem;
    line-height: 1.5;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: left;
    border: 1px solid #ddd;
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tooltip-content::after {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent #ffffff transparent;
}

.tooltip-container:hover .tooltip-content {
    opacity: 1;
    pointer-events: auto;
}

.tooltip-content strong {
    display: block;
    margin-bottom: 3px;
}

.tooltip-content p {
    margin: 0 0 6px 0;
}

/* Status badges with improved colors */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    max-width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
}

.status-badge.normal {
    background-color: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.status-badge.below {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.status-badge.above {
    background-color: rgba(243, 156, 18, 0.15);
    color: var(--warning-color);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.status-badge.na {
    background-color: rgba(127, 140, 141, 0.15);
    color: var(--neutral-color);
    border: 1px solid rgba(127, 140, 141, 0.3);
}

.description {
    font-size: 0.9em;
    color: #555;
}

/* Charts Section Styling */
.charts-section {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
}

.charts-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.chart-item {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}

.chart-item h3 {
    padding: 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    margin: 0;
}

.chart-item img {
    width: 100%;
    display: block;
}

/* Trend legend styles */
.trend-legend {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.trend-legend h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--primary-color);
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

.legend-section {
    margin-bottom: 15px;
}

.legend-section h4 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--dark-text);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 12px;
}

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

.legend-text {
    font-size: 0.9rem;
}

.comparison-list {
    list-style-type: none;
    padding-left: 5px;
    margin-bottom: 10px;
}

.comparison-list li {
    font-size: 0.9rem;
    margin-bottom: 5px;
    line-height: 1.4;
    position: relative;
    padding-left: 12px;
}

.comparison-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
}

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

.info-icon {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-right: 3px;
}

.tooltip-icon-example {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #555;
    font-size: 11px;
    font-weight: bold;
    margin: 0 3px;
}

.info-link {
    color: var(--secondary-color);
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s;
}

.info-link:hover {
    color: var(--primary-color);
}

/* Economic Commentary Section */
.commentary-section {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: relative;
}

.commentary-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.commentary-content {
    line-height: 1.7;
    color: #333;
    font-size: 1.05rem;
}

.commentary-content strong {
    color: var(--primary-color);
}

.commentary-note {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    margin-top: 1.5rem;
    text-align: right;
}

.ai-badge {
    background-color: var(--ai-color);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-weight: normal;
    vertical-align: middle;
}

/* API Error styling */
.api-error {
    background-color: rgba(231, 76, 60, 0.1);
    border-left: 4px solid var(--danger-color);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
    border-radius: 4px;
}

.fallback-notice {
    background-color: rgba(52, 152, 219, 0.1);
    border-left: 4px solid var(--info-color);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
    border-radius: 4px;
}

/* Export Section at bottom of page */
.export-section {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.export-section h2 {
    margin-bottom: var(--space-md);
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .export-section {
        padding: var(--space-sm);
        margin: 0 var(--space-sm) var(--space-md);
    }
    
    .export-buttons {
        flex-direction: column;
    }
}