/* Variables */
:root {
    --bg-color: #f4f4f4;
    --card-bg: #ffffff;
    --text-color: #333333;
    --input-bg: #ffffff;
    --input-border: #cccccc;
    --secondary-bg: #e0e0e0;
    --label-color: #555555;
    --card-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

body.dark-mode {
    --bg-color: #0a192f;
    --card-bg: #112240;
    --text-color: #ffffff;
    --input-bg: #ffffff;
    --input-border: #ffffff;
    --secondary-bg: #0d1e3a;
    --label-color: #aaaaaa;
    --card-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 40px 20px;
    transition: color 0.3s ease; /* Ensure text transitions smoothly */
    
    /* NEW: Set up the body to handle the oversized gradient animation */
    background-size: 300% 300%;
    animation: gradientBG 15s ease infinite;
}

/* --- Common UI Components --- */
.large-icon { font-size: 5rem; line-height: 1.2; }
.condition-text { font-size: 1.5rem; font-weight: bold; }
.hidden { display: none !important; }
.error { color: #ff4d4d; }

/* Top Nav */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto 40px auto;
}

.search-box input {
    width: 300px;
    padding: 12px 18px;
    border-radius: 8px;
    border: none;
    background-color: var(--input-bg);
    color: #333;
    outline: none;
    font-size: 1rem;
}

#currentLocBtn {
    background-color: #28a745;
    color: white;
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
}

/* Theme Toggle */
.theme-toggle input { display: none; }
.toggle-label {
    width: 55px; height: 30px;
    background-color: #ccc;
    border-radius: 30px;
    position: relative; cursor: pointer; display: inline-block;
}
.toggle-label::after {
    content: ''; position: absolute;
    width: 24px; height: 24px;
    background-color: white; border-radius: 50%;
    top: 3px; left: 3px; transition: 0.3s;
}
.theme-toggle input:checked + .toggle-label { background-color: #4facfe; }
.theme-toggle input:checked + .toggle-label::after { transform: translateX(25px); }

.main-title {
    text-align: center;
    font-size: 2.8rem;
    margin-bottom: 40px;
}

.section-subtitle {
    margin-top: 50px;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 25px;
}

.dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Primary Weather Dashboard Card (top) */
.forecast-row {
    background-color: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--card-shadow);
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.forecast-row:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.location-row h2 { font-size: 2.8rem; text-align: center; }
.temp-col h1 { font-size: 4.5rem; margin-bottom: 15px; }
.temp-col h1 span { font-size: 2.5rem; font-weight: normal; }
.sun-info p { font-size: 1rem; margin-bottom: 10px; line-height: 1.5; color: var(--label-color); }
.sun-info span { font-weight: bold; color: var(--text-color); }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.metric .icon { font-size: 2rem; margin-bottom: 8px; }
.metric .value { font-weight: bold; font-size: 1.3rem; }
.metric .label { font-size: 0.95rem; color: var(--label-color); }

/* --- 12-Hour Wrapped Container --- */
.hourly-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.hourly-card {
    background-color: var(--secondary-bg);
    flex: 1 1 calc(16.666% - 15px); 
    min-width: 110px;
    padding: 20px 10px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 5px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    cursor: pointer;
}

.hourly-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.hourly-card .time { font-size: 0.9rem; font-weight: bold; }
.hourly-card .icon { font-size: 2.2rem; }
.hourly-card .temp { font-weight: bold; font-size: 1.2rem; }

/* ==========================================================
   --- 7-DAY FORECAST SECTION ---
   ========================================================== */

.forecast-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    width: 100%;
}

.forecast-card {
    background-color: var(--card-bg);
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    cursor: pointer;
}

.forecast-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.card-header {
    padding: 20px 20px 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-header .day-name { font-size: 1.5rem; font-weight: bold; }
.card-header .full-date { font-size: 0.9rem; color: var(--label-color); }

.card-status {
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.status-icon.large-icon { font-size: 4rem; }

.card-metrics-footer {
    margin-top: auto; 
    background-color: var(--secondary-bg); 
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 15px;
    gap: 10px;
    transition: background-color 0.3s ease;
}

.footer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 5px;
}

.footer-item .label { font-size: 0.85rem; color: var(--label-color); margin-bottom: 3px; }
.footer-item .value { font-size: 1.1rem; font-weight: bold; }

/* --- Responsiveness --- */
@media (max-width: 900px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 20px;}
    .hourly-card { flex: 1 1 calc(25% - 15px); } /* 4 per row */
}

@media (max-width: 500px) {
    .hourly-card { flex: 1 1 calc(33.333% - 15px); } /* 3 per row */
}

/* ==========================================================
   --- DYNAMIC ANIMATED BACKGROUNDS ---
   ========================================================== */

/* The slow breathing animation for the gradients */
@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 1. CLEAR SKIES */
body[data-weather="clear"] { background-image: linear-gradient(-45deg, #56CCF2, #2F80ED); }
body.dark-mode[data-weather="clear"] { background-image: linear-gradient(-45deg, #0a192f, #112240, #001f3f); }

/* 2. CLOUDY */
body[data-weather="clouds"] { background-image: linear-gradient(-45deg, #8e9eab, #eef2f3); }
body.dark-mode[data-weather="clouds"] { background-image: linear-gradient(-45deg, #1a2639, #2c3e50); }

/* 3. RAIN */
body[data-weather="rain"] { background-image: linear-gradient(-45deg, #4b6cb7, #182848); }
body.dark-mode[data-weather="rain"] { background-image: linear-gradient(-45deg, #0d1e3a, #0a1128); }

/* 4. SNOW */
body[data-weather="snow"] { background-image: linear-gradient(-45deg, #E0EAFC, #CFDEF3); }
body.dark-mode[data-weather="snow"] { background-image: linear-gradient(-45deg, #1c2841, #2b3a55); }

/* 5. FOG */
body[data-weather="fog"] { background-image: linear-gradient(-45deg, #B9935A, #E7CDB3); }
body.dark-mode[data-weather="fog"] { background-image: linear-gradient(-45deg, #2b2b2b, #434343); }

/* 6. THUNDERSTORM */
body[data-weather="thunder"] { background-image: linear-gradient(-45deg, #373B44, #4286f4); }
body.dark-mode[data-weather="thunder"] { background-image: linear-gradient(-45deg, #141E30, #243B55); }