@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --text-main: #333;
    --text-secondary: #555;
    --accent-color: #667eea;
}

body.dark {
    --primary-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --glass-bg: rgba(30, 30, 50, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f0f0f0;
    --text-secondary: #ccc;
    --accent-color: #a0aec0;
}

/* Dynamic Themes */
body.weather-clear {
    background: linear-gradient(to bottom right, #4facfe 0%, #00f2fe 100%);
}

body.weather-clouds {
    background: linear-gradient(to bottom right, #bdc3c7 0%, #2c3e50 100%);
}

body.weather-rain,
body.weather-drizzle,
body.weather-thunderstorm {
    background: linear-gradient(to bottom right, #373b44 0%, #4286f4 100%);
}

body.weather-night {
    background: linear-gradient(to bottom right, #0f2027, #203a43, #2c5364);
}


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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.5s ease, color 0.5s ease;
    position: relative;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    color: var(--text-main);
}

/* Cloud Animations */
.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    z-index: -1;
    animation: floatCloud 20s infinite linear;
    filter: blur(20px);
}

.cloud:nth-child(1) {
    width: 200px;
    height: 100px;
    top: 10%;
    left: -10%;
    animation-duration: 25s;
}

.cloud:nth-child(2) {
    width: 300px;
    height: 150px;
    top: 40%;
    left: -20%;
    animation-duration: 35s;
    animation-delay: 5s;
}

.cloud:nth-child(3) {
    width: 150px;
    height: 80px;
    top: 70%;
    left: -10%;
    animation-duration: 20s;
    animation-delay: 10s;
}

@keyframes floatCloud {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(120vw);
    }
}

/* Header & Toggles */
.header-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0 1rem;
    position: relative;
    z-index: 20;
}

.app-branding {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    margin-bottom: 0px;
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}


.controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Unit Toggle */
.unit-toggle-container {
    position: relative;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 4px;
    display: flex;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.unit-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 5px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.unit-btn.active {
    background: #fff;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Theme Toggle (Checkbox style) */
.theme-toggle {
    position: relative;
}

.theme-checkbox {
    opacity: 0;
    position: absolute;
}

.theme-label {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
    height: 30px;
    width: 60px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
}

.theme-label i {
    color: white;
    font-size: 14px;
    z-index: 1;
    margin: 0 6px;
}

.theme-label .ball {
    background-color: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    height: 22px;
    width: 22px;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.theme-checkbox:checked+.theme-label .ball {
    transform: translateX(30px);
}

/* Main Container */
.container {
    width: 100%;
    max-width: 800px;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

/* Search Form */
.search-form {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input {
    width: 100%;
    padding: 12px 45px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    font-family: inherit;
    font-size: 0.95rem;
    color: #000;
    transition: all 0.3s ease;
    box-shadow: var(--glass-shadow);
}

body.dark .search-input {
    color: var(--text-main);
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-color), var(--glass-shadow);
}

.search-icon {
    position: absolute;
    left: 18px;
    color: var(--text-secondary);
    pointer-events: none;
    font-size: 0.9rem;
}

.search-button {
    padding: 12px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    box-shadow: var(--glass-shadow);
    flex-shrink: 0;
}

.search-button:hover {
    transform: scale(1.05);
}

/* Suggestions */
.suggestions-list {
    position: absolute;
    top: 110%;
    left: 0;
    right: 60px;
    /* Leave space for button */
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    box-shadow: var(--glass-shadow);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.suggestion-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-main);
    font-size: 0.9rem;
}

.suggestion-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Weather Card */
.weather-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 20px 30px;
    text-align: center;
    box-shadow: var(--glass-shadow);
    color: var(--text-main);
    animation: slideUp 0.6s ease;
    width: 100%;
    max-width: 600px;
    /* Wider card */
    margin: 0 auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.weather-header {
    display: flex;
    flex-direction: row;
    /* Side-by-side layout */
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.weather-temp {
    font-size: 3.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.weather-icon-main {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
}

.weather-desc {
    font-size: 1.1rem;
    text-transform: capitalize;
    margin: 5px 0 3px 0;
    font-weight: 500;
}

.weather-location {
    font-size: 0.95rem;
    opacity: 0.8;
    margin-bottom: 15px;
}

.weather-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
}

/* Forecast Section */
.forecast-container {
    margin-top: 20px;
    width: 100%;
}

.forecast-title {
    color: #fff;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.forecast-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    justify-content: center;
}

.forecast-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 12px;
    text-align: center;
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.forecast-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.35);
}

.forecast-day {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.forecast-date {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 5px;
}

.forecast-icon {
    width: 40px;
    height: 40px;
    margin: 5px 0;
}

.forecast-temps {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 0.85rem;
}

.temp-max {
    font-weight: 600;
}

.temp-min {
    opacity: 0.7;
}

/* Placeholder */
.placeholder-content {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    padding: 30px 0;
}

.placeholder-content i {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.8;
}

/* Error State */
.error-msg {
    color: #ff6b6b;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    margin: 0 auto;
}

/* Responsiveness */
@media (max-width: 768px) {
    .forecast-grid {
        grid-template-columns: repeat(3, 1fr);
        /* 3 cols on tablet */
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    .header-container {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 1.2rem;
        text-align: center;
        width: 100%;
        max-width: 100%;
    }

    .app-branding {
        align-items: center;
        /* Center logo on mobile */
    }

    .app-title {
        font-size: 1.8rem;
    }

    .controls {
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .search-input {
        padding: 12px 20px 12px 40px;
        width: 100%;
        font-size: 0.9rem;
    }

    .search-wrapper {
        width: 100%;
        max-width: 100%;
    }

    .search-form {
        width: 100%;
        padding: 0;
    }

    .weather-card {
        padding: 15px;
        max-width: 100%;
        width: calc(100% - 20px);
        margin: 0 auto;
    }

    .weather-header {
        flex-direction: column;
        /* Vertical on mobile */
        gap: 10px;
    }

    .weather-temp {
        font-size: 3rem;
        /* Further reduce for mobile */
    }

    .weather-icon-main {
        width: 70px;
        height: 70px;
    }

    .forecast-grid {
        display: flex;
        flex-direction: column;
        /* Stack on mobile */
        width: 100%;
        max-width: 450px;
        margin: 0 auto;
    }

    .forecast-card {
        flex-direction: row;
        /* Horizontal cards on stack */
        padding: 12px 20px;
        width: 100%;
        justify-content: space-between;
    }

    .forecast-header {
        text-align: left;
        flex: 1;
    }

    .forecast-icon {
        margin: 0 15px;
    }

    .forecast-temps {
        width: auto;
        flex-direction: column;
        gap: 0;
        text-align: right;
    }
}

/* Very Small Screens */
@media (max-width: 380px) {
    .app-title {
        font-size: 1.8rem;
    }

    .weather-card {
        padding: 15px;
    }

    .weather-temp {
        font-size: 2.5rem;
    }

    .weather-desc {
        font-size: 1rem;
    }
}