:root {
    /* Light Mode (Default) */
    --primary-bg: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #0ea5e9;
    --card-bg: rgba(255, 255, 255, 0.5);
    --card-hover: rgba(255, 255, 255, 0.8);
    --input-bg: rgba(255, 255, 255, 0.5);
    --font-main: 'Outfit', sans-serif;
    --gradient-1: #e2e8f0;
    --gradient-2: #f8fafc;
    --shape-color-1: rgba(14, 165, 233, 0.3);
    --shape-color-2: rgba(139, 92, 246, 0.3);
    --shape-color-3: rgba(244, 114, 182, 0.3);
    --map-opacity: 0.1;
}

.dark-mode {
    /* Dark Mode Overrides */
    --primary-bg: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-hover: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.2);
    --gradient-1: #1e293b;
    --gradient-2: #0f172a;
    --shape-color-1: rgba(56, 189, 248, 0.2);
    --shape-color-2: rgba(139, 92, 246, 0.2);
    --shape-color-3: rgba(236, 72, 153, 0.2);
    --map-opacity: 0.05;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 2rem 0;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Dynamic Background */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, var(--gradient-1) 0%, var(--gradient-2) 100%);
    z-index: -2;
    transition: background 0.5s ease;
}

/* Moving Shapes */
.moving-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.8;
    animation: float-shape 20s infinite ease-in-out alternate;
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: var(--shape-color-1);
    animation-delay: 0s;
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: var(--shape-color-2);
    animation-delay: -5s;
}

.shape-3 {
    top: 40%;
    left: 40%;
    width: 300px;
    height: 300px;
    background: var(--shape-color-3);
    animation-delay: -10s;
}

@keyframes float-shape {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(50px, 50px) scale(1.1);
    }

    66% {
        transform: translate(-30px, 80px) scale(0.9);
    }

    100% {
        transform: translate(20px, -40px) scale(1);
    }
}

/* World Map Background */
.world-map-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url('https://upload.wikimedia.org/wikipedia/commons/8/80/World_map_-_low_resolution.svg');
    background-repeat: repeat-x;
    background-size: auto 80%;
    background-position: center;
    opacity: var(--map-opacity);
    animation: map-scroll 120s linear infinite;
    pointer-events: none;
    filter: grayscale(100%);
}

@keyframes map-scroll {
    from {
        background-position: 0 center;
    }

    to {
        background-position: -2000px center;
    }
}

/* Glass Container */
.app-container {
    width: 90%;
    max-width: 500px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header & Search */
.app-header {
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

h1 {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.theme-btn {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background: var(--card-hover);
    transform: rotate(15deg);
}

.search-container {
    position: relative;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
    transform: scale(1.02);
}

.search-box i {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    margin: 0 0.75rem;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

#search-btn {
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#search-btn:hover {
    transform: scale(1.1);
}

#search-btn i {
    color: #fff;
    /* Always white for contrast on accent color */
    font-size: 1rem;
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    position: absolute;
    left: 0;
    width: 100%;
    text-align: left;
    padding-left: 0.5rem;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Weather Display */
.weather-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.current-weather {
    text-align: center;
    animation: fade-in-down 0.6s ease-out;
}

.weather-icon-wrapper {
    font-size: 5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.2));
    animation: float-icon 3s ease-in-out infinite;
}

@keyframes float-icon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.temp-container {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
    background: linear-gradient(to bottom, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.unit {
    font-size: 2rem;
    vertical-align: top;
    opacity: 0.7;
}

.condition-container p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

#location-text {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Details Grid */
.weather-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    opacity: 0;
    /* For animation */
    animation-fill-mode: forwards;
}

.detail-card:hover {
    background: var(--card-hover);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
}

.detail-card i {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.detail-info {
    display: flex;
    flex-direction: column;
}

.detail-info .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-info .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Map Styling */
.map-wrapper {
    width: 100%;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    opacity: 0;
    animation-fill-mode: forwards;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Leaflet Customization */
.leaflet-control-attribution {
    background: rgba(15, 23, 42, 0.8) !important;
    color: #94a3b8 !important;
}

.leaflet-control-attribution a {
    color: #38bdf8 !important;
}

/* States */
.hidden {
    display: none !important;
}

.initial-state {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
}

.big-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--text-primary);
}

.bounce {
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.loading-container {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--glass-border);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Animations */
@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fade-in-up 0.6s ease-out forwards;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .app-container {
        width: 95%;
        padding: 1.5rem;
    }

    .temp-container {
        font-size: 3.5rem;
    }

    .weather-details {
        grid-template-columns: 1fr;
    }
}

/* Natural Icon Colors */

/* Sunny / Clear */
.weather-icon-wrapper .ph-sun,
.weather-icon-wrapper .ph-sun-dim {
    color: #fbbf24;
    /* Golden Yellow */
    filter: drop-shadow(0 0 25px rgba(251, 191, 36, 0.6));
}

/* Moon / Clear Night */
.weather-icon-wrapper .ph-moon {
    color: #94a3b8;
    /* Moon Silver */
    filter: drop-shadow(0 0 20px rgba(148, 163, 184, 0.4));
}

/* Clouds (General) */
.weather-icon-wrapper .ph-cloud,
.weather-icon-wrapper .ph-cloud-fog {
    color: #cbd5e1;
    /* Cloud Gray */
    filter: drop-shadow(0 0 20px rgba(203, 213, 225, 0.4));
}

/* Partly Cloudy (Sun) - Gradient Effect */
.weather-icon-wrapper .ph-cloud-sun {
    background: linear-gradient(135deg, #fbbf24 30%, #cbd5e1 70%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.3));
}

/* Partly Cloudy (Moon) - Gradient Effect */
.weather-icon-wrapper .ph-cloud-moon {
    background: linear-gradient(135deg, #94a3b8 30%, #64748b 70%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(148, 163, 184, 0.3));
}

/* Rain */
.weather-icon-wrapper .ph-cloud-rain,
.weather-icon-wrapper .ph-drop,
.weather-icon-wrapper .ph-drop-half-bottom {
    color: #60a5fa;
    /* Rain Blue */
    filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.5));
}

/* Snow */
.weather-icon-wrapper .ph-snowflake,
.weather-icon-wrapper .ph-cloud-snow {
    color: #67e8f9;
    /* Ice Cyan */
    filter: drop-shadow(0 0 20px rgba(103, 232, 249, 0.5));
}

/* Thunder */
.weather-icon-wrapper .ph-lightning {
    color: #facc15;
    /* Lightning Yellow */
    filter: drop-shadow(0 0 25px rgba(250, 204, 21, 0.6));
}