:root {
    --primary-color: #4A90E2;
    --primary-hover: #357ABD;
    --accent-color: #4A90E2;
    --accent-hover: #357ABD;
    --bg-color: #F5F9FC;
    --surface-color: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --border-color: #E1E8ED;
    --active-color: #4A90E2;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --temp-high: #E74C3C;
    --temp-low: #3498DB;
    --night-bg: #2C3E50;
    --night-text: #ECF0F1;
    --night-text-secondary: #BDC3C7;
    --night-solo-bg: #34495E;
    --error-color: #d32f2f;
    --error-bg: #ffebee;
}

/* ── Pink Theme ── */
[data-theme="pink"] {
    --primary-color: #E24A8F;
    --primary-hover: #C93578;
    --accent-color: #E24A8F;
    --accent-hover: #C93578;
    --bg-color: #FDF5F9;
    --surface-color: #FFFFFF;
    --text-primary: #4A2035;
    --text-secondary: #8D7F85;
    --border-color: #F0D6E3;
    --active-color: #E24A8F;
    --shadow: 0 2px 8px rgba(226, 74, 143, 0.1);
    --night-bg: #4A2035;
    --night-text: #F5E6ED;
    --night-text-secondary: #C7B0BC;
    --night-solo-bg: #5C2D45;
}

/* ── Green Theme ── */
[data-theme="green"] {
    --primary-color: #27AE60;
    --primary-hover: #1E8C4D;
    --accent-color: #27AE60;
    --accent-hover: #1E8C4D;
    --bg-color: #F5FCF7;
    --surface-color: #FFFFFF;
    --text-primary: #1A3A2A;
    --text-secondary: #7F8D82;
    --border-color: #D4EDDA;
    --active-color: #27AE60;
    --shadow: 0 2px 8px rgba(39, 174, 96, 0.1);
    --night-bg: #1A3A2A;
    --night-text: #E6F5ED;
    --night-text-secondary: #B0C7BA;
    --night-solo-bg: #244D37;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
    --primary-color: #5DADE2;
    --primary-hover: #3498DB;
    --accent-color: #5DADE2;
    --accent-hover: #3498DB;
    --bg-color: #1A1A2E;
    --surface-color: #16213E;
    --text-primary: #E0E0E0;
    --text-secondary: #A0A0B0;
    --border-color: #2A2A4A;
    --active-color: #5DADE2;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --temp-high: #FF6B6B;
    --temp-low: #64B5F6;
    --night-bg: #0F0F1F;
    --night-text: #E0E0E0;
    --night-text-secondary: #A0A0B0;
    --night-solo-bg: #141428;
    --error-color: #FF6B6B;
    --error-bg: #2A1A1A;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background-color: var(--surface-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo {
    height: 40px;
    width: auto;
    display: block;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--text-primary);
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 3px;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

/* ── User Menu (desktop dropdown / mobile flat) ── */
.user-menu {
    position: relative;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.user-menu-trigger:hover {
    background-color: var(--bg-color);
    border-color: var(--border-color);
}

.user-menu-caret {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.user-menu-caret.open {
    transform: rotate(180deg);
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.35rem;
    z-index: 200;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    border: none;
    background: none;
    border-radius: 7px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-menu-item:hover {
    background-color: var(--bg-color);
}

.user-menu-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

.user-menu-item svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.user-menu-logout {
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    padding: 0.5rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Content Sections */
.page-header {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.page-header-text {
    flex: 1;
    min-width: 0;
}

.page-header h1 {
    color: var(--text-primary);
    font-size: 2rem;
    margin: 0;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Mobile Navigation Chevrons */
.nav-chevron {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
    background-color: var(--surface-color);
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.nav-chevron:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.nav-chevron:active {
    transform: scale(0.95);
}

.nav-chevron svg {
    display: block;
}

.nav-chevron-left {
    margin-left: 3px;
}

.nav-chevron-right {
    margin-right: 3px;
}

/* Refresh Button */
.refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    z-index: 10;
}

.refresh-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

.refresh-btn svg {
    flex-shrink: 0;
}

.refresh-btn.htmx-request svg {
    animation: spin 1s linear infinite;
}

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

.card {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 0rem 1.5rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card h2 {
    margin-bottom: 0;
    color: var(--primary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Show navigation chevrons on mobile */
    .nav-chevron {
        display: flex;
    }
    
    .page-header {
        gap: 0.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
        flex: 1;
        min-width: 0;
    }
    
    .page-header-text h1 {
        font-size: 1.5rem;
    }
    
    .page-header-text p {
        font-size: 0.9rem;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        top: 60px;
        right: -100%;
        width: 280px;
        height: calc(100vh - 60px);
        background-color: var(--surface-color);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        gap: 0;
    }
    
    .nav-menu.active {
        right: 0;
    }
    
    .nav-link {
        padding: 1rem;
        border-radius: 6px;
        margin-bottom: 0.5rem;
    }
    
    .user-menu {
        margin-left: 0;
        margin-top: 1rem;
        padding-left: 0;
        padding-top: 1rem;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .user-menu-trigger {
        width: 100%;
        justify-content: center;
        padding: 0.5rem;
    }

    .user-menu-caret {
        display: none;
    }

    .user-menu-dropdown {
        position: static;
        box-shadow: none;
        border: none;
        min-width: 0;
        padding: 0;
        margin-top: 0.5rem;
        /* Always visible in hamburger — override Alpine's x-show */
        display: flex !important;
        flex-direction: column;
    }

    .user-menu-item {
        padding: 1rem;
        border-radius: 6px;
        justify-content: center;
    }
    
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(7px, 7px);
    }
    
    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.25rem;
        margin-left: 5px;
    }

    .page-header-text h1 {
        font-size: 1.25rem;
    }

    .page-header-text p {
        font-size: 0.85rem;
        margin-left: 5px;
    }
    
    .card {
        padding: 0.1rem 1.5rem 1.5rem 1.5rem;
    }

    /* Hide refresh text on mobile, show only icon */
    .refresh-btn .refresh-text {
        display: none;
    }
    
    .refresh-btn {
        padding: 0.6rem;
        min-width: 44px;
        justify-content: center;
        margin: 0 0.25rem;
    }
    
    .nav-chevron {
        padding: 0.5rem;
        min-width: 40px;
        min-height: 40px;
    }
    
    .page-header {
        gap: 0.25rem;
    }

    /* Forecast: stack short description below day name and temps */
    .forecast-header {
        position: relative;
        padding-right: 3.5rem;
    }

    .forecast-header-left {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .forecast-icon {
        position: absolute;
        left: 1.25rem;
        bottom: 0.75rem;
        width: 36px;
        height: 36px;
    }

    .forecast-header > .chevron {
        position: absolute;
        right: 1.25rem;
        bottom: 1rem;
    }

    .forecast-day-info {
        display: flex;
        align-items: center;
        gap: 1rem;
        width: 100%;
    }

    .forecast-day-name {
        min-width: 6.5rem;
        width: 6.5rem;
        flex-shrink: 0;
    }

    .forecast-short {
        width: 100%;
        font-size: 0.9rem;
        padding-left: 3.1rem;
    }
}

/* Weather Display Styles */
.coordinates {
    margin: 0;
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: right;
    flex-shrink: 0;
}

#location-container {
    overflow: visible; /* Allow results to overflow */
    position: relative; /* For absolute positioning of results */
}

#location-nameplate {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

#location-name,
#location-search {
    min-height: 2rem;
    display: flex;
    align-items: center;
    margin: 0;
}

#location-name{
    line-height: 1.5rem;
    margin-right: 0.5rem;
}

.favorite-star {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    color: var(--text-secondary);
    padding: 0 0.15rem;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    transition: color 0.15s ease, transform 0.1s ease;
}

.favorite-star:hover {
    transform: scale(1.2);
}

.favorite-star.is-favorite {
    color: #FFD700;
}

#location-search {
    max-width: 60%; /* Limit width to prevent wrapping below coordinates */
    position: relative; /* For positioning results relative to search box */
}

#location-search input {
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.55rem 0.75rem;
    box-sizing: border-box;
}

#search-results {
    position: absolute;
    top: 100%; /* Always flush with the bottom of the search input */
    left: 0;
    z-index: 1000;
    width: 100%;
}

/* Location Search */
.location-results {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.location-result {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.location-result:last-child {
    border-bottom: none;
}

.location-result:hover {
    background-color: var(--bg-color);
}

.location-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.location-detail {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.location-result--favorite .location-name {
    color: var(--text-primary);
}

.no-results {
    padding: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.search-error {
    padding: 12px;
    color: var(--error-color);
    background-color: var(--error-bg);
    border-radius: 4px;
    margin-top: 8px;
}

/* Forecast Display Styles */
.forecast-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.forecast-row {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    scroll-margin-top: 70px;
}

.forecast-row:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.forecast-header {
    padding: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    user-select: none;
}

.forecast-header:hover {
    background-color: var(--bg-color);
}

.forecast-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
    flex-wrap: wrap;
}

.forecast-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.forecast-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.forecast-day-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.forecast-day-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
}

.temperature-range {
    display: flex;
    gap: 1rem;
    font-size: 1rem;
}

.temp-high {
    color: var(--temp-high);
    font-weight: 600;
}

.temp-low {
    color: var(--temp-low);
    font-weight: 600;
}

.forecast-short {
    color: var(--text-secondary);
    flex: 1;
}

.chevron {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.chevron.expanded {
    transform: rotate(180deg);
}

.forecast-details {
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.forecast-period {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.forecast-period:last-child {
    border-bottom: none;
}

.forecast-period.night {
    background-color: var(--night-bg);
    color: var(--night-text);
}

.forecast-period.night .period-title,
.forecast-period.night .detail-label {
    color: var(--night-text);
}

.forecast-period.night .detail-value {
    color: var(--night-text-secondary);
}

.forecast-period.solo-night {
    background-color: var(--night-solo-bg);
    color: var(--night-text);
}

.period-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.period-detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.period-detail-header .period-title {
    margin-bottom: 0;
    flex: 1;
}

.period-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    object-fit: contain;
}

/* Admin copy-period-JSON overlay (desktop only) */
.period-icon-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.copy-period-btn {
    display: none;
}

@media (hover: hover) and (min-width: 768px) {
    .copy-period-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        bottom: -4px;
        right: -4px;
        width: 22px;
        height: 22px;
        border-radius: 4px;
        border: 1px solid var(--border-color);
        background: var(--bg-primary);
        color: var(--text-secondary);
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.15s ease;
        padding: 0;
        z-index: 2;
    }

    .period-icon-wrapper:hover .copy-period-btn {
        opacity: 1;
    }

    .copy-period-btn:hover {
        background: var(--primary-color);
        color: #fff;
        border-color: var(--primary-color);
    }
}

.copy-icon-check {
    font-size: 12px;
    color: var(--success-color, #22c55e);
    font-weight: bold;
}

.period-forecast {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.period-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.weather-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .weather-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Horizontal spacing for page header on larger screens */
    .page-header {
        margin: 0 0.5rem;
    }
}

.weather-metric {
    background-color: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.weather-metric:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.metric-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.metric-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.weather-meta {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 1rem;
}

.station-link {
    color: var(--accent-color, #4a90d9);
    text-decoration: none;
    cursor: pointer;
}

.station-link:hover,
.station-link:focus {
    text-decoration: underline;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* Error Display */
.weather-error {
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.weather-error h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.weather-error p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.retry-button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.retry-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.retry-button:active {
    transform: translateY(0);
}

/* Discussion Display */
.discussion-content {
    padding: 1.5rem;
}

.discussion-content h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.discussion-content h3:first-child {
    margin-top: 0;
}

.discussion-content p {
    margin-bottom: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.discussion-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
    line-height: 1.7;
}

.discussion-content li {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.discussion-content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 1.5rem 0;
}

.discussion-content cite {
    display: block;
    text-align: right;
    color: var(--text-secondary);
    font-style: normal;
    font-size: 0.9rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.climate-table {
    margin: 1rem 0;
    overflow-x: auto;
}

.climate-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.climate-table table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.climate-table th {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.climate-table td {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

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

.climate-table tbody tr:hover {
    background-color: var(--surface-color);
}

/* ===================================================================
   Radar Viewport (maps page)
   =================================================================== */

/* Make the content area a flex column filling the viewport so the
   radar wrapper takes the remaining space after the page header. */
.main-content:has(.radar-wrapper) {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 60px);
    padding: 0;
}

.main-content:has(.radar-wrapper) > .container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 0;
}

.radar-wrapper {
    display: flex;
    flex-direction: column;
    /* Fill remaining space after the page-header sibling. */
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.radar-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #353f69; /* ocean blue — matches OCEAN_COLOR from mrms_renderer */
    min-height: 0; /* allow flex shrink */
}

.radar-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

/* Loading spinner — centred over the radar container */
.radar-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    z-index: 5;
}

.radar-spin-icon {
    color: var(--surface-color);
    animation: radar-spin 1s linear infinite;
}

@keyframes radar-spin {
    to { transform: rotate(360deg); }
}

/* Error overlay */
.radar-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    z-index: 5;
}

/* Location markers (green = selected, red = map center) */
.loc-marker {
    position: absolute;
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-shadow:
        -1px -1px 0 #000,
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000;
}

.loc-marker--center {
    left: 50%;
    top: 50%;
    color: #ff0000;
    z-index: 6;
}

.loc-marker--selected {
    color: #00ff00;
    z-index: 7;
}

/* N / S / E / W navigation buttons */
.radar-nav-btn {
    position: absolute;
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.radar-nav-btn:hover,
.radar-nav-btn:focus-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.radar-nav-n { top: 0.5rem;   left: 50%;  transform: translateX(-50%); }
.radar-nav-s { bottom: 0.5rem; left: 50%;  transform: translateX(-50%); }
.radar-nav-w { left: 0.5rem;  top: 50%;   transform: translateY(-50%); }
.radar-nav-e { right: 0.5rem; top: 50%;   transform: translateY(-50%); }

/* Controls bar below the image */
.radar-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.radar-ctrl-btn {
    padding: 0.45rem 1rem;
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    font-family: inherit;
}

.radar-ctrl-btn:hover,
.radar-ctrl-btn:focus-visible {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    outline: none;
}

.radar-ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.radar-ctrl-btn:disabled:hover {
    background: var(--bg-color);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.radar-zoom-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-left: 0.25rem;
    white-space: nowrap;
}

/* Mobile: slightly larger touch targets */
@media (max-width: 768px) {
    .radar-nav-btn {
        padding: 0.55rem 0.85rem;
        font-size: 1.25rem;
    }

    .radar-controls {
        padding: 0.6rem 0.5rem;
    }

    .radar-ctrl-btn {
        padding: 0.5rem 0.85rem;
    }
}

/* ── Preferences Page ── */
.preferences-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 640px;
    margin: 0 auto;
}

.pref-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    position: relative;
}

.pref-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

/* Theme swatches */
.theme-swatches {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-color);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 72px;
    color: var(--text-primary);
}

.theme-swatch:hover {
    border-color: var(--swatch-color, var(--primary-color));
}

.theme-swatch.active {
    border-color: var(--swatch-color, var(--primary-color));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--swatch-color, var(--primary-color)) 25%, transparent);
}

.swatch-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.swatch-label {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Timezone select */
.pref-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
}

.pref-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

/* Unit toggles */
.unit-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.unit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.unit-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.toggle-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.toggle-btn {
    padding: 0.4rem 0.75rem;
    border: none;
    background: var(--surface-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    min-width: 48px;
}

.toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.toggle-btn:hover {
    background: var(--bg-color);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Save indicator */
.save-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Saved Locations (editor) */
.pref-empty-state {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.5rem 0;
}

.location-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.location-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.location-row:last-child {
    border-bottom: none;
}

.home-toggle {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
    padding: 0.2rem;
    line-height: 1;
}

.home-toggle:hover,
.home-toggle.is-home {
    opacity: 1;
}

.location-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.location-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}

.location-remove:hover {
    color: var(--error-color, #d32f2f);
    background: var(--error-bg, #ffebee);
}

/* ── Alert / Watch / Warning Indicators ── */

.alert-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--error-color, #d32f2f);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: none;
    background: none;
    transition: background 0.15s ease;
}

/* Severity color variants */
.alert-indicator.alert-color-red {
    color: #d32f2f;
}
.alert-indicator.alert-color-red:hover,
.alert-indicator.alert-color-red:focus-visible {
    background: #ffebee;
}
.alert-indicator.alert-color-orange {
    color: #e65100;
}
.alert-indicator.alert-color-orange:hover,
.alert-indicator.alert-color-orange:focus-visible {
    background: #fff3e0;
}
.alert-indicator.alert-color-yellow {
    color: #f9a825;
}
.alert-indicator.alert-color-yellow:hover,
.alert-indicator.alert-color-yellow:focus-visible {
    background: #fffde7;
}

.alert-indicator:hover,
.alert-indicator:focus-visible {
    outline: none;
}

.alert-indicator-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.alert-indicator-text {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.alert-indicator-static {
    display: inline-flex;
    align-items: center;
    color: var(--error-color, #d32f2f);
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

.alert-indicator-static.alert-color-red {
    color: #d32f2f;
}
.alert-indicator-static.alert-color-orange {
    color: #e65100;
}
.alert-indicator-static.alert-color-yellow {
    color: #f9a825;
}

/* ── Weather description row: push warning to right ── */
.weather-description {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.weather-description p {
    margin: 0;
}

/* ── Forecast header: watch icon left of chevron ── */
.forecast-header .alert-indicator-static {
    margin-right: -0.25rem;
}

/* ── Period detail header: watch indicator on right ── */
.period-detail-header .alert-indicator {
    margin-left: auto;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .alert-indicator-text {
        max-width: 120px;
    }
}

/* ── Alert Overlay ── */

.alert-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.alert-overlay-content {
    position: relative;
    background: var(--surface-color, #fff);
    color: var(--text-primary);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.alert-overlay-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.alert-overlay-close:hover {
    color: var(--text-primary);
    background: var(--bg-color);
}

.alert-overlay-item {
    margin-bottom: 1.5rem;
}

.alert-overlay-item:last-child {
    margin-bottom: 0;
}

.alert-overlay-headline {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--error-color, #d32f2f);
    margin-bottom: 0.5rem;
}

.alert-overlay-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.alert-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.alert-pill-tornado {
    background: var(--error-bg, #ffebee);
    color: var(--error-color, #d32f2f);
}

.alert-pill-hail {
    background: #e8eaf6;
    color: #283593;
}

.alert-pill-wind {
    background: var(--warning-bg, #fff3e0);
    color: var(--warning-color, #e65100);
}

.alert-overlay-description {
    line-height: 1.6;
    white-space: pre-wrap;
    margin-bottom: 0.75rem;
}

.alert-overlay-instruction {
    background: var(--bg-color);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    line-height: 1.5;
    border-left: 3px solid var(--error-color, #d32f2f);
}

.alert-overlay-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.alert-overlay-close-btn {
    padding: 0.5rem 2rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.alert-overlay-close-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

