/* ==================== HOME / WEATHER DASHBOARD ==================== */
/* Shared tokens, reset, body background & scrollbars come from base.css */

.container {
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==================== HERO ROW ====================
   Explicit areas at each breakpoint (not auto-fit - see the note in git
   history: auto-fit + a full-span item made the grid compute phantom empty
   columns on wide screens).
     <640px   : stacked, one per row
     640-1439 : Map + Seeing paired, Meteogram alone on a full-width row
                (its chart's axis labels/legend get unreadable sharing a
                column with anything else at this width)
     >=1440px : wide enough for Meteogram to join the row too - all three
                side by side. */
.weather-hero-row {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "map"
        "seeing"
        "meteogram";
    gap: 20px;
    align-items: stretch;
}

@media (min-width: 640px) and (max-width: 1439px) {
    .weather-hero-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "map seeing"
            "meteogram meteogram";
    }
}

@media (min-width: 1440px) {
    .weather-hero-row {
        grid-template-columns: 1fr 2fr 1fr;
        grid-template-areas: "map meteogram seeing";
    }
}

.weather-map-card {
    grid-area: map;
    min-height: 700px;
}

.meteogram-card {
    grid-area: meteogram;
    min-height: 900px;
}

@media (max-width: 1439px) {
    .meteogram-card {
        min-height: 760px;
    }
}

.seeing-card {
    grid-area: seeing;
    min-height: 700px;
    max-height: 700px;
    overflow-y: auto;
}

.hero-card {
    display: flex;
    flex-direction: column;
    min-height: 560px;
}

.hero-iframe {
    width: 100%;
    flex: 1;
    border: 0;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.seeing-card {
    display: flex;
    flex-direction: column;
}

.seeing-frame-wrap {
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #fff;
}

.seeing-frame-wrap iframe {
    width: 100%;
    height: 736px;
    border: 0;
    display: block;
}

.widget-refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--border-hairline);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.widget-refresh-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hairline-strong);
    transform: rotate(90deg);
}

.widget-refresh-btn.spinning svg {
    animation: spin 0.6s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.widget-credit {
    text-align: center;
    margin-top: 8px;
}

.widget-credit a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78em;
}

/* ==================== STAT GRID (6 monitoring images) ====================
   Same auto-fit approach: as many 280px+ cards per row as actually fit. */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.dash-cell {
    min-height: 240px;
    display: flex;
    flex-direction: column;
}

.dash-cell img {
    width: 100%;
    flex: 1;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: var(--surface-2);
}

/* ==================== RAIN PREDICTION CAROUSEL ==================== */
.carousel-wrap {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 0;
}

.carousel-wrap img {
    width: 100%;
    flex: 1;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: var(--surface-2);
}

.carousel-nav-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.carousel-wrap:hover .carousel-nav-overlay {
    opacity: 1;
}

.carousel-nav-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px;
    transition: all 0.2s ease;
}

.carousel-nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.08);
}

.carousel-pagination {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
}

.carousel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.6);
}

.carousel-dot.active {
    background: var(--primary-purple);
    border-color: var(--primary-purple);
    transform: scale(1.25);
}

/* ==================== ALL SKY CAMERA ==================== */
.allsky-card {
    width: 100%;
}

.allsky-time {
    font-size: 0.75em;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 10px;
}

.allsky-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

#allsky-image {
    width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    display: block;
    cursor: pointer;
}

#allsky-image.is-hidden {
    display: none;
}

.allsky-placeholder {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    color: var(--text-muted);
    font-size: 0.85em;
    letter-spacing: 0.5px;
    background: var(--surface-2);
    border: 1px dashed var(--border-hairline-strong);
    border-radius: var(--border-radius-sm);
}

.allsky-placeholder.is-visible {
    display: flex;
}

/* ==================== TOPBAR EXTRAS ==================== */
.update-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 180px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.78em;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 32px;
    text-align: right;
}

/* Rain Warning Styles (also used as a topbar status pill) */
.rain-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(239, 90, 90, 0.15);
    border: 1px solid rgba(239, 90, 90, 0.4);
    border-radius: 999px;
    color: #ff8a8a;
    font-weight: 500;
    font-size: 0.85em;
}

.rain-warning .warning-icon {
    font-size: 1.1em;
}

.rain-warning.high-alert {
    background: rgba(239, 90, 90, 0.18);
    border-color: rgba(239, 90, 90, 0.5);
    color: #ff8a8a;
}

.rain-warning.normal-alert {
    background: rgba(240, 184, 79, 0.15);
    border-color: rgba(240, 184, 79, 0.45);
    color: #f0b84f;
}

/* ==================== FLOATING UPDATE STATUS TOAST ==================== */
.update-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface-2);
    border: 1px solid var(--border-hairline-strong);
    color: var(--text-primary);
    padding: 14px 22px;
    border-radius: 999px;
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: var(--shadow-hover);
    display: none;
    z-index: 1200;
}

/* Loading animation for button */
#manual-update.loading {
    background: var(--secondary-gradient);
    animation: pulse 1.5s infinite;
    pointer-events: none;
    opacity: 0.8;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* ==================== RESPONSIVE ====================
   The hero row's own breakpoint (640px) is defined above next to its base
   rule. Dashboard grid columns are handled by auto-fit/minmax already.
   This just covers the topbar layout and a hard single-column floor for
   very narrow phones. */
@media (max-width: 900px) {
    .page-topbar .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 420px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
