/* Modern Reset & Root Variables */
:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(23, 31, 51, 0.7);
    --bg-card-hover: rgba(30, 41, 69, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(56, 189, 248, 0.3);
    
    --primary-cyan: #38bdf8;
    --primary-blue: #3b82f6;
    --primary-purple: #8b5cf6;
    --primary-rose: #f43f5e;
    --accent-amber: #fbbf24;
    --accent-emerald: #10b981;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.15);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --font-main: 'Noto Sans KR', sans-serif;
    --font-outfit: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* Weather Dynamic Background Effects */
.weather-bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
    transition: background 1s ease;
}

/* App Container Layout */
.app-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon-box {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.logo-icon {
    width: 30px;
    height: 30px;
    color: #ffffff;
}

.app-title {
    font-family: var(--font-outfit);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.app-title span {
    background: linear-gradient(135deg, var(--primary-cyan), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.live-clock-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    font-family: var(--font-outfit);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-cyan);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(59, 130, 246, 0.2));
    color: var(--primary-cyan);
    border: 1px solid var(--border-highlight);
    padding: 0.55rem 1.1rem;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-refresh:hover {
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    color: #fff;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
    transform: translateY(-2px);
}

.btn-refresh.spinning #refresh-icon {
    animation: spin 1s linear infinite;
}

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

/* Stats Overview Cards */
.stats-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.2);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-wrapper svg {
    width: 24px;
    height: 24px;
}

.stat-icon-wrapper.blue { background: rgba(56, 189, 248, 0.15); color: var(--primary-cyan); }
.stat-icon-wrapper.red { background: rgba(244, 63, 94, 0.15); color: var(--primary-rose); }
.stat-icon-wrapper.cyan { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
.stat-icon-wrapper.purple { background: rgba(139, 92, 246, 0.15); color: var(--primary-purple); }

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

.stat-value {
    font-family: var(--font-outfit);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.region-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1.1rem;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.search-sort-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input-box {
    position: relative;
    width: 240px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-input-box input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-input-box input:focus {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.sort-select-box {
    position: relative;
}

.sort-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.sort-select-box select {
    appearance: none;
    padding: 0.55rem 2rem 0.55rem 2.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
}

.sort-select-box select option {
    background: #171f33;
    color: var(--text-primary);
}

/* 20 City Cards Grid */
.city-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

/* City Card Design */
.city-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.city-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-cyan), var(--primary-purple));
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.city-card:hover {
    transform: translateY(-6px);
    background: var(--bg-card-hover);
    border-color: var(--border-highlight);
    box-shadow: var(--shadow-soft), var(--shadow-glow);
}

.city-card:hover::before {
    opacity: 1;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.city-names {
    display: flex;
    flex-direction: column;
}

.city-name-kr {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.city-name-en {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-outfit);
}

.region-tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-cyan);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.card-weather-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.temp-container {
    display: flex;
    flex-direction: column;
}

.temp-current {
    font-family: var(--font-outfit);
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

.temp-feels {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

.weather-icon-img {
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
}

.weather-desc-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: #e2e8f0;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Card Details Footer */
.card-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.detail-item svg {
    width: 15px;
    height: 15px;
    color: var(--primary-cyan);
}

.detail-item span {
    font-weight: 600;
    color: var(--text-primary);
}

.temp-bar-container {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.temp-range-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.temp-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.temp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #f43f5e);
    border-radius: 3px;
}

/* Modal Overlay & Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 8, 16, 0.85);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1.5rem;
}

.modal-overlay[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #131b2e;
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.2);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay[aria-hidden="false"] .modal-card {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--primary-rose);
    color: #fff;
    border-color: transparent;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.modal-title-group h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-title-group h2 span {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    font-family: var(--font-outfit);
}

.modal-weather-desc {
    font-size: 0.95rem;
    color: var(--primary-cyan);
    font-weight: 500;
    margin-top: 0.2rem;
}

.modal-main-temp {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-weather-img {
    width: 72px;
    height: 72px;
}

.temp-big {
    font-family: var(--font-outfit);
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

.feels-like {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.modal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.metric-item svg {
    width: 22px;
    height: 22px;
    color: var(--primary-cyan);
}

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Modal Tab Navigation */
.modal-tab-nav {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.modal-tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.25s ease;
}

.modal-tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-tab-btn.active {
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* 30-Year Climate Highlight Cards */
.climate-highlights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.climate-card {
    background: rgba(56, 189, 248, 0.06);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.climate-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.climate-val {
    font-family: var(--font-outfit);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-cyan);
}

.climate-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.modal-chart-section {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.chart-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chart-wrapper {
    width: 100%;
    height: 220px;
}

/* Footer */
.app-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

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

.footer-links {
    display: flex;
    gap: 1.25rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.2s ease;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-sort-group {
        width: 100%;
    }
    
    .search-input-box {
        width: 100%;
    }

    .footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .modal-tab-nav {
        flex-direction: column;
    }
}
