/* Accessible visually hidden utility class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

svg { display: inline; }

/* --- Navigation Tabs --- */
.dash-nav {
    display: flex;
    gap: 10px;
    /*margin-bottom: 15px;*/
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    overflow-x: auto;
}
.tab-btn {
    background: #e0e0e0;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    border-radius: 6px 6px 0 0;
    color: #333;
    transition: background 0.2s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.tab-btn:hover { background: #d0d0d0; }
.tab-btn.active {
    background: #102E51;
    color: white;
}

/* --- Wrapper & Loading State --- */
.weatherlink-wrapper {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    min-height: 425px;
    background-color: #f8f9fa;
    border-radius: 0 8px 8px 8px;
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.weatherlink-wrapper::before {
    content: ""; position: absolute; width: 40px; height: 40px; top: 50%; left: 50%; margin-top: -20px; margin-left: -20px;
    border: 4px solid #e0e0e0; border-top: 4px solid #004d80;
    border-radius: 50%; animation: weather-spin 1s linear infinite; display: none;
}

.weatherlink-wrapper.loading::before { display: block; }
.weatherlink-wrapper.loading .custom-widget { opacity: 0; visibility: hidden; }

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

/* --- Native Widget Base Styles --- */
.custom-widget {
    width: 100%; min-height: 100%; display: flex; flex-direction: column;
    padding: 20px; box-sizing: border-box; transition: opacity 0.3s ease;
    background: linear-gradient(135deg, #102E51 0%, #194480 100%); color: white;
}

/* View Panes */
.view-pane { display: none; width: 100%; }
.view-pane.active { display: flex; flex-direction: column; flex-grow: 1; }

.error-banner {
    display: none;
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* --- Global Header & Titles --- */
.persistent-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end; /* Aligns the bottom of the title with the time */
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-wrap: wrap; /* Allows stacking on very small mobile screens */
    gap: 10px;
}
.global-title {
    margin: 0;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #ffffff;
}
.header-time {
    font-size: 14px;
    opacity: 0.8;
    white-space: nowrap;
}
.pane-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 500;
    opacity: 0.9;
}

/* --- Current Conditions Styles --- */
.widget-header { text-align: center; margin-bottom: 20px; }
.main-temp { font-size: 72px; font-weight: bold; line-height: 1; margin: 10px 0; }
.feels-like { font-size: 18px; opacity: 0.8; margin-bottom: 5px; }

.daily-extremes {
    font-size: 14px;
    opacity: 0.7;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    column-gap: 20px;
    container-type: inline-size; 
    width: 100%;
}

.daily-extremes > span:not(:last-child)::after {
    content: "|";
    position: absolute;
    margin-left: 7.5px;
}

@media (max-width: 370px) {
    .daily-extremes > span::after {
        display: none;
    }
}

.widget-grid { display: grid; gap: 15px; flex-grow: 1; width: 100%; }
.stat-box { background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px; text-align: center; }
.stat-label { display: block; font-size: 14px; opacity: 0.8; text-transform: uppercase; margin-bottom: 5px; }
.stat-value { display: block; font-size: 22px; font-weight: bold; }
.stat-time { font-size: 14px; opacity: 0.6; display: block; margin-top: 3px; }

/* --- Tabular Styles --- */
.table-container { 
    width: 100%; 
    overflow-x: auto; 
    margin-bottom: 25px; 
}

.wl-table { 
    display: flex;
    flex-direction: column;
    width: 100%; 
    font-size: 14px; 
    min-width: 600px; 
}

.wl-table-row {
    display: grid;
    width: 100%;
}

.col-3 .wl-table-row { grid-template-columns: 20% repeat(2, 1fr); }
.col-4 .wl-table-row { grid-template-columns: 20% repeat(3, 1fr); }
.col-5 .wl-table-row { grid-template-columns: 20% repeat(4, 1fr); }
#ext-table.col-6 .wl-table-row { grid-template-columns: 7% repeat(5, 1fr); }

.wl-table-cell {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
}

.header .wl-table-cell {
    background: rgba(0,0,0,0.3);
    color: white;
    font-weight: bold;
    border-bottom: 2px solid rgba(255,255,255,0.2);
}

.wl-table-cell:first-child { 
    font-weight: bold; 
    color: white; 
    text-align: left; 
}
.wl-table-cell:not(:first-child) { 
    text-align: right; 
}

.error-row {
    display: block;
    text-align: center;
}
.error-row .wl-table-cell {
    color: #ff4d4d;
    font-weight: bold;
    text-align: center;
}

/* --- Chart Container Styles --- */
/* --- Localized Chart Loading --- */
.localized-loading-area {
    position: relative; /* Keeps the absolute-positioned spinner contained */
    min-height: 200px; /* Prevents the area from collapsing if empty */
}

/* Dim the canvases, not the whole wrapper */
.localized-loading-area canvas {
    transition: opacity 0.3s ease;
}

.localized-loading-area.is-loading canvas {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Spinner Styles --- */
.chart-spinner {
    display: none; /* Hidden by default */
    position: absolute;
    top: 50%;
    left: 50%;
    
    /* Center it perfectly using negative margins (half of width/height) */
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    
    /* Styling the ring */
    border: 4px solid #e0e0e0;
    border-top: 4px solid #005fcc; /* Matches your active button blue */
    border-radius: 50%;
    
    /* The spin animation */
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Show the spinner only when loading */
.localized-loading-area.is-loading .chart-spinner {
    display: block;
}

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

.chart-controls {
    display: flex;
    align-items: center;
    gap: 8px; /* Adds space between buttons */
}

.timeframe-btn {
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.timeframe-btn:hover,
.timeframe-btn:focus {
    background-color: #e0e0e0;
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

/* Active State Styling */
.timeframe-btn.active,
.timeframe-btn[aria-pressed="true"] {
    background-color: #005fcc;
    color: #ffffff;
    border-color: #005fcc;
    font-weight: bold;
}

.chart-container {
    width: 100%;
    overflow-x: auto; 
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#tempChartWrapper,
#rainBaroChartWrapper {
    position: relative;
    height: 350px;
    width: 100%;
    min-width: 600px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- Extremes Tab Styles --- */
.ext-selector { margin-bottom: 20px; }
.ext-selector select {
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    color: #1c1d1f;
}
.ext-tables { display: flex; flex-direction: column; gap: 20px; }
.ext-month-title { font-size: 20px; margin: 0 0 10px 0; border-bottom: 2px solid rgba(255,255,255,0.2); padding-bottom: 5px; }
.tie-note { font-size: 12px; opacity: 0.7; font-style: italic; margin-top: -10px; margin-bottom: 15px; }

.widget-footer { text-align: -webkit-right; font-size: 14px; margin-top: 20px; width: 100%; opacity: 0.9; }

/* --- Responsive Breakpoints --- */
@media (max-width: 575px) {
    .widget-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 576px) and (max-width: 991px) {
    .weatherlink-wrapper { min-height: 480px; }
    .widget-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
    .main-temp { font-size: 90px; }
}
@media (min-width: 992px) {
    .weatherlink-wrapper { height: auto; min-height: 540px; }

    #view-current.active {
        display: grid;
        grid-template-columns: 1fr 1.2fr;
        gap: 40px;
        align-items: center;
        padding: 10px;
    }

    .widget-header { text-align: left; margin-bottom: 0; }

    .widget-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .main-temp { font-size: 110px; }

    .widget-footer {
        grid-column: 1 / -1;
        margin-top: 30px;
    }
}