:root {
    --bg-gradient: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent: #4facfe;
    --input-bg: rgba(0, 0, 0, 0.2);
    --item-bg: rgba(255, 255, 255, 0.05);
    --item-hover-bg: rgba(255, 255, 255, 0.12);
    --modal-overlay: rgba(0, 0, 0, 0.6);
    --error-bg: rgba(255, 50, 50, 0.2);
    --btn-icon-bg: rgba(255, 255, 255, 0.1);
}

body.light-mode {
    --bg-gradient: linear-gradient(135deg, #a1c4fd, #c2e9fb);
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-primary: #2c3e50;
    --text-secondary: rgba(44, 62, 80, 0.7);
    --accent: #007bff;
    --input-bg: rgba(255, 255, 255, 0.5);
    --item-bg: rgba(255, 255, 255, 0.4);
    --item-hover-bg: rgba(255, 255, 255, 0.7);
    --modal-overlay: rgba(255, 255, 255, 0.4);
    --error-bg: rgba(255, 50, 50, 0.1);
    --btn-icon-bg: rgba(255, 255, 255, 0.6);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    transition: background 0.5s ease-in-out;
}

.container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
}

header {
    margin-bottom: 30px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.city-header {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.app-main-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}

form {
    display: flex;
    gap: 10px;
    background: var(--input-bg);
    padding: 5px 5px 5px 20px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    transition: border-color 0.3s;
}

form:focus-within {
    border-color: var(--text-secondary);
}

input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
}

input::placeholder {
    color: var(--text-secondary);
}

form button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}

form button:hover {
    transform: scale(1.05);
    background: #00f2fe;
}

.hidden {
    display: none !important;
}

.current-weather {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeIn 0.5s ease-out;
}

#city-name {
    font-size: 2rem;
    font-weight: 600;
}

.fav-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s;
    padding-bottom: 5px;
}

.fav-btn:hover {
    transform: scale(1.15);
}

.current-temp {
    font-size: 4.5rem;
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: start;
    line-height: 1;
}

.current-temp span {
    letter-spacing: -2px;
}

.current-temp::after {
    content: '°C';
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 10px;
    margin-left: 5px;
    text-shadow: none;
}

.current-desc {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
    text-transform: capitalize;
}

.current-details {
    display: flex;
    justify-content: center;
    gap: 40px;
    background: var(--item-bg);
    border-radius: 16px;
    padding: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-item span:first-child {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detail-item span:last-child {
    font-weight: 600;
    font-size: 1.1rem;
}

.forecast-container h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.forecast-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.forecast-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--item-bg);
    padding: 15px 20px;
    border-radius: 16px;
    transition: background 0.3s, transform 0.2s;
    animation: slideUp 0.4s ease-out forwards;
    opacity: 0;
}

.forecast-item:hover {
    background: var(--item-hover-bg);
    transform: translateX(4px);
}

.forecast-item.today {
    background: var(--item-hover-bg);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
}

.forecast-item.today::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--accent);
    border-radius: 6px 0 0 6px;
}

.forecast-day {
    font-weight: 600;
    width: 110px;
}

.forecast-icon {
    font-size: 1.5rem;
}

.forecast-precip {
    font-size: 0.85rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
    width: 70px;
    justify-content: center;
    white-space: nowrap;
}

.forecast-temps {
    display: flex;
    gap: 15px;
    width: 90px;
    justify-content: flex-end;
}

.temp-min {
    color: var(--text-secondary);
}

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

.forecast-sun {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    color: var(--text-secondary);
    gap: 3px;
    width: 65px;
    white-space: nowrap;
}

.attribution {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 25px;
    opacity: 0.8;
}

.attribution a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.2s;
}

.attribution a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Loader */
.loader {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error {
    background: var(--error-bg);
    color: #ff5555;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    margin-top: 20px;
    border: 1px solid var(--error-bg);
    font-size: 0.9rem;
}

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

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

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-gradient);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
    margin-top: 10px;
}

.modal-header-nav h3 {
    margin-bottom: 0;
    text-align: center;
    flex: 1;
    font-size: 1.1rem;
}

.nav-arrow-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    font-size: 1rem;
}

.nav-arrow-btn:hover:not(:disabled) {
    background: var(--accent);
    transform: scale(1.1);
}

.nav-arrow-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#modal-date {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.hourly-container {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(0,0,0,0.2);
}

.hourly-container::-webkit-scrollbar {
    height: 6px;
}

.hourly-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.hourly-container::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 75px;
    background: var(--item-bg);
    padding: 15px 10px;
    border-radius: 16px;
    gap: 8px;
}

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

.hourly-icon {
    font-size: 1.5rem;
}

.hourly-precip {
    font-size: 0.8rem;
    color: var(--accent);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

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

/* Map Modal */
.map-modal-content {
    max-width: 800px;
    height: 80vh;
}

#map-container {
    width: 100%;
    height: 100%;
    flex: 1;
    border-radius: 12px;
    background: var(--item-bg);
}

/* Fix Leaflet Map Z-Index issue */
.leaflet-container {
    z-index: 1;
}

.theme-btn {
    background: var(--btn-icon-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s, background 0.2s;
    color: var(--text-primary);
}

.theme-btn:hover {
    transform: scale(1.1);
    background: var(--accent);
}

.windy-btn {
    background: var(--btn-icon-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s, background 0.2s;
    margin-left: 10px;
}

.windy-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

.moon-link {
    background: transparent;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, background 0.2s;
}

.moon-link:hover {
    background: var(--accent);
    transform: scale(1.1);
}

.saved-locations-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    margin-top: 10px;
    gap: 5px;
    width: 100%;
}

.saved-locations-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 0;
    scrollbar-width: none;
    flex: 1;
    scroll-behavior: smooth;
    mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
}

.scroll-arrow {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
    z-index: 2;
}

.scroll-arrow:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

.scroll-arrow:active {
    transform: scale(0.95);
}

.saved-locations-container::-webkit-scrollbar {
    display: none;
}

.saved-location-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.2s, transform 0.2s;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saved-location-btn:hover {
    background: var(--item-hover-bg);
    transform: translateY(-2px);
}

.warning-banner {
    background: rgba(255, 60, 60, 0.85);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    animation: pulseWarning 2s infinite;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
}

@keyframes pulseWarning {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px 15px;
        border-radius: 16px;
    }

    .header-top {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 10px;
    }

    .app-main-title {
        font-size: 1.2rem;
        margin-bottom: 0;
        text-align: left;
    }

    .theme-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .city-header {
        flex-wrap: wrap;
    }

    #city-name {
        font-size: 1.5rem;
        text-align: center;
    }

    .current-temp {
        font-size: 3.5rem;
    }
    
    .current-temp::after {
        font-size: 1.2rem;
        margin-top: 5px;
    }

    .current-details {
        gap: 15px;
        padding: 15px 10px;
    }

    .detail-item span:first-child {
        font-size: 0.75rem;
    }

    .detail-item span:last-child {
        font-size: 0.95rem;
    }

    form {
        padding: 5px 5px 5px 15px;
    }

    form button {
        width: 38px;
        height: 38px;
    }

    .forecast-item {
        padding: 12px 10px;
    }

    .forecast-day {
        width: 80px;
        font-size: 0.9rem;
    }

    .forecast-icon {
        font-size: 1.2rem;
    }

    .forecast-temps {
        width: 75px;
        gap: 10px;
        font-size: 0.9rem;
    }

    .forecast-sun {
        display: none;
    }
    
    .forecast-precip {
        width: 60px;
        font-size: 0.8rem;
    }
}
