/* ========== VARIABLES & GENERAL ========== */
:root {
    --bg: #4682ec;
    --container-bg: rgba(255, 255, 255, 0.22);
    --text: #fff;
    --input-bg: rgba(255, 255, 255, 0.82);
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.13);
    --accent: #4682ec;
    --button-bg: linear-gradient(90deg, #6a85f1 40%, #bfeecc 100%);
    --button-hover: linear-gradient(90deg, #4c65d1 50%, #7bffb0 100%);
    --icon-filter: brightness(1) drop-shadow(0 0 0 #fff);
}

body.light-theme {
    --bg: #e9f5ff;
    --container-bg: rgba(255, 255, 255, 0.92);
    --text: #24243c;
    --input-bg: #eef6fa;
    --shadow: 0 10px 34px rgba(90, 140, 170, 0.05);
    --accent: #1b467e;
    --button-bg: linear-gradient(90deg, #e0eeff 40%, #c0ebd6 100%);
    --button-hover: linear-gradient(90deg, #99caff 50%, #90ffd1 100%);
    --icon-filter: brightness(0.7) drop-shadow(0 0 0 #000);
}

html {
    box-sizing: border-box;
    font-size: 16px;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Nunito', Arial, sans-serif;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.3s, color 0.3s;
}

/* Cloud Animated Background */
.clouds-bg {
    position: fixed;
    z-index: 0;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    background: url('https://jooinn.com/images/beautiful-clouds-4.jpg') repeat-x;
    background-size: cover;
    animation: moveClouds 60s linear infinite;
    opacity: 0.5;
    pointer-events: none;
}

@keyframes moveClouds {
    0% {
        background-position-x: 0;
    }

    100% {
        background-position-x: 100vw;
    }
}

/* Theme toggle button */
#theme-toggle {
    position: fixed;
    right: 16px;
    top: 16px;
    background: transparent;
    border: none;
    z-index: 99;
    cursor: pointer;
    padding: 5px;
    transition: filter 0.15s;
}

#theme-img {
    filter: var(--icon-filter);
    transition: filter 0.25s;
    width: 1.6rem;
    height: 1.6rem;
}

#theme-toggle:hover {
    filter: brightness(0.87);
}

/* Favorites bar */
#favorites {
    position: fixed;
    left: 7px;
    top: 8px;
    z-index: 20;
    font-size: 0.94rem;
    color: var(--text);
    max-width: 94vw;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 36px;
}

#favorites b {
    color: var(--text) !important;
    margin-right: 3px;
    font-weight: 900;
    letter-spacing: 1.3px;
    font-size: 1.04em;
}

.favorite-pair {
    display: inline-flex;
    align-items: center;
}

#favorites button {
    border: none;
    background: #b6e3f4;
    color: #234;
    font-weight: 700;
    border-radius: 8px !important;
    padding: 3px 10px !important;
    cursor: pointer;
    font-size: 0.98em !important;
    margin: 0 2px 2.5px 0 !important;
    line-height: 1.35;
    transition: background 0.18s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#favorites button.add-favorite-btn {
    background: #8be8c1 !important;
    color: #345 !important;
    font-weight: 800 !important;
}

.remove-favorite-btn {
    background: none !important;
    color: crimson !important;
    font-weight: 800 !important;
    font-size: 1.1em !important;
    padding: 0 6px !important;
    margin-left: 2px !important;
    border-radius: 50% !important;
    line-height: 1.1 !important;
    cursor: pointer;
    user-select: none;
    height: 24px;
    width: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
    border: 1.5px solid transparent;
}

.remove-favorite-btn:hover {
    background-color: #ffeaea !important;
    border-color: crimson !important;
}

/* Main container */
#weather-container {
    z-index: 10;
    background: var(--container-bg);
    width: 100%;
    max-width: 420px;
    min-width: 0;
    margin: 0 1vw;
    padding: 20px 14px 13px 14px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(13px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    text-align: center;
    color: var(--text);
    transition: background 0.3s, box-shadow 0.3s, color 0.3s;
    box-sizing: border-box;
}

/* Header */
.header-icon {
    margin-right: 8px;
    vertical-align: sub;
    filter: var(--icon-filter);
    width: 2.1rem;
    height: 2.1rem;
}

h2 {
    color: var(--text) !important;
    margin-top: 0.23em;
    margin-bottom: 0.35em;
    padding-top: 2px;
    font-size: 1.5rem;
    font-weight: 800;
}

/* Temp toggle */
#temp-toggle {
    text-align: right;
    user-select: none;
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 6px;
    margin-top: 0;
}

/* Search row */
.search-row {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-bottom: 9px;
    flex-wrap: wrap;
    width: 100%;
    position: relative;
    z-index: 10;
}

input#city {
    flex: 2;
    min-width: 90px;
    padding: 8px 12px;
    font-size: 1rem;
    border-radius: 12px;
    border: none;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.2s, background 0.25s, color 0.25s;
    max-width: 200px;
    width: 60vw;
    cursor: text;
}

body:not(.light-theme) input#city {
    /* Dark mode: use darker text for visibility on light input background */
    color: #222;
}

body.light-theme input#city {
    /* Light mode: dark text */
    color: #24243c;
}

input#city:focus {
    box-shadow: 0 0 5px 2px var(--accent);
    outline: none;
}

button {
    padding: 8px 14px;
    background: var(--button-bg);
    color: var(--text);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 1rem;
    transition: background 0.18s, color 0.22s;
    position: relative;
    z-index: 10;
}

button:hover {
    background: var(--button-hover);
}

button.small-btn {
    padding: 7px 10px;
    background: #86bfff;
    border-radius: 10px;
    min-width: 32px;
    display: flex;
    align-items: center;
}

/* Weather icon & temperature */
.large-icon {
    width: 4.2rem;
    height: 4.2rem;
    margin: 8px auto 0 auto;
    display: none;
    filter: var(--icon-filter);
}

#temp-div p {
    font-size: 2.3rem;
    margin: 4px 0 0 0;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -1.5px;
    text-shadow: 0 3px 9px rgba(0, 0, 0, 0.07);
}

#weather-info {
    font-size: 1.07rem;
    margin-top: -5px;
    margin-bottom: 2px;
    font-weight: 500;
    color: var(--text) !important;
}

#extra-info {
    margin: 5px 0 3px 0;
    min-height: 1.4em;
    font-weight: 600;
    color: var(--text) !important;
    font-size: 1rem;
}

/* Hourly forecast */
#hourly-forecast {
    margin-top: 13px;
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: #b6e3f4 transparent;
    max-width: 100vw;
}

.hourly-item {
    background: rgba(153, 182, 241, 0.28);
    border-radius: 10px;
    padding: 4px 4px 2px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 45px;
    flex: 0 0 auto;
    color: var(--text);
    font-weight: 500;
    font-size: 0.97rem;
    box-shadow: 0 1.5px 6px rgba(0, 0, 0, 0.05);
}

.hourly-item img {
    width: 20px;
    height: 20px;
    margin: 2px 0 3px 0;
    filter: var(--icon-filter);
}

::-webkit-scrollbar {
    height: 5px;
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #b6e3f4;
    border-radius: 6px;
}

/* --- MEDIA QUERIES --- */
@media (max-width: 768px) {
    #favorites {
        position: fixed;
        top: 70px;
        /* Move favorites bar down enough to clear weather container header */
        left: 8px;
        max-width: 96vw;
        font-size: 0.9rem;
        padding-right: 20vw;
        gap: 4px;
        z-index: 25;
        /* Ensure it's above background but below theme toggle */
    }

    #weather-container {
        margin-top: 90px;
        /* Add top margin to visually push down content */
        max-width: 95vw;
        padding: 3vw 2vw;
        font-size: 1rem;
        border-radius: 12px;
        position: relative;
        z-index: 20;
        /* Slightly below favorites bar, still above background */
    }
}

/* For very small screens */
@media (max-width: 400px) {
    #favorites {
        top: 60px;
        left: 7px;
        font-size: 0.82rem;
        gap: 3px;
    }

    #weather-container {
        margin-top: 85px;
    }
}