:root {
    --primary-gradient: linear-gradient(135deg, #667eea, #764ba2);
    --secondary-gradient: linear-gradient(135deg, #f093fb, #f5576c);
    --success-gradient: linear-gradient(135deg, #4facfe, #00f2fe);
    --warning-gradient: linear-gradient(135deg, #43e97b, #38f9d7);
    --dark-bg: #0f0f23;
    --dark-card: #1a1a2e;
    --light-bg: #f8fafc;
    --light-card: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-light: #ffffff;
    --border-light: #e2e8f0;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] {
    --bg-primary: var(--dark-bg);
    --bg-secondary: var(--dark-card);
    --text-color: var(--text-light);
    --text-muted: #a0aec0;
    --border-color: #2d3748;
    --card-bg: var(--glass-bg);
    --input-bg: rgba(45, 55, 72, 0.8);
    --hover-bg: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
    --bg-primary: var(--light-bg);
    --bg-secondary: var(--light-card);
    --text-color: var(--text-primary);
    --text-muted: var(--text-secondary);
    --border-color: var(--border-light);
    --card-bg: rgba(255, 255, 255, 0.8);
    --input-bg: rgba(255, 255, 255, 0.9);
    --hover-bg: rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-primary);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    opacity: 0.1;
    z-index: -2;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background: var(--primary-gradient); }
    25% { background: var(--secondary-gradient); }
    50% { background: var(--success-gradient); }
    75% { background: var(--warning-gradient); }
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: var(--text-light);
}

.weather-loader {
    position: relative;
    margin-bottom: 2rem;
}

.cloud {
    width: 80px;
    height: 50px;
    background: #fff;
    border-radius: 50px;
    position: relative;
    margin: 0 auto 20px;
    animation: float 3s ease-in-out infinite;
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: #fff;
    border-radius: 50px;
}

.cloud::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 10px;
}

.cloud::after {
    width: 60px;
    height: 40px;
    top: -15px;
    right: 15px;
}

.rain {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 0;
}

.drop {
    width: 2px;
    height: 15px;
    background: #4facfe;
    margin: 0 8px;
    border-radius: 0 0 10px 10px;
    animation: rain 1s linear infinite;
    display: inline-block;
}

.drop:nth-child(2) { animation-delay: 0.2s; }
.drop:nth-child(3) { animation-delay: 0.4s; }
.drop:nth-child(4) { animation-delay: 0.6s; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes rain {
    0% { transform: translateY(-100px); opacity: 1; }
    100% { transform: translateY(100px); opacity: 0; }
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.units-toggle,
.theme-toggle {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 50px;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

.units-toggle:hover,
.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.theme-toggle {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.sun-icon,
.moon-icon {
    position: absolute;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

[data-theme="light"] .sun-icon {
    opacity: 1;
    transform: rotate(0deg);
}

[data-theme="light"] .moon-icon {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Main Container */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 2rem 2rem;
    min-height: 100vh;
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-box {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: 25px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    overflow: hidden;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: #667eea;
}

#cityInput {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
}

#cityInput::placeholder {
    color: var(--text-muted);
}

.search-btn {
    padding: 1rem;
    border: none;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    filter: brightness(1.1);
}

.location-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(20px);
    white-space: nowrap;
}

.location-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--success-gradient);
    color: white;
    border-color: transparent;
}

/* Recent Searches */
.recent-searches {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.recent-searches h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.recent-item {
    padding: 0.5rem 1rem;
    background: var(--hover-bg);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
}

.recent-item:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-1px);
}

/* Error Container */
.error-container {
    display: none;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    animation: slideIn 0.3s ease;
}

.error-container.show {
    display: flex;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

/* Weather Card */
.weather-card {
    background: var(--card-bg);
    border-radius: 30px;
    padding: 2rem;
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-xl);
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease;
}

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

/* Current Weather */
.current-weather {
    margin-bottom: 3rem;
}

.weather-main {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: center;
}

.location-info h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.country-region {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.last-updated {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.temperature-display {
    text-align: right;
}

.main-temp {
    font-size: 5rem;
    font-weight: 300;
    line-height: 1;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.feels-like {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.weather-visual {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background: var(--hover-bg);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.weather-icon {
    width: 120px;
    height: 120px;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.weather-condition {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    text-transform: capitalize;
}

.time-date-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: var(--hover-bg);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.current-time {
    font-size: 2.5rem;
    font-weight: 600;
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.current-date {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Section Titles */
.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    position: relative;
    padding-left: 1rem;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* Weather Details */
.weather-details-section {
    margin-bottom: 3rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.detail-card {
    background: var(--hover-bg);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    cursor: pointer;
}

.detail-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    background: var(--primary-gradient);
    color: white;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.detail-header svg {
    opacity: 0.8;
}

.detail-label {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
}

.detail-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.detail-description {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Astronomy Section */
.astronomy-section {
    margin-bottom: 3rem;
}

.astronomy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.astronomy-card {
    background: var(--hover-bg);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.astronomy-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    background: var(--secondary-gradient);
    color: white;
}

.astro-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.astro-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.astro-time {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Hourly Forecast */
.hourly-section {
    margin-bottom: 3rem;
}

.hourly-scroll-container {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
}

.hourly-forecast {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.hourly-forecast::-webkit-scrollbar {
    display: none;
}

.hourly-item {
    flex: 0 0 auto;
    background: var(--hover-bg);
    border-radius: 15px;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--glass-border);
    min-width: 100px;
    transition: all 0.3s ease;
}

.hourly-item:hover {
    transform: translateY(-3px);
    background: var(--success-gradient);
    color: white;
}

.hourly-time {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.hourly-icon {
    width: 40px;
    height: 40px;
    margin: 0.5rem 0;
}

.hourly-temp {
    font-size: 1.1rem;
    font-weight: 600;
}

.hourly-desc {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

/* 7-Day Forecast */
.forecast-section {
    margin-bottom: 3rem;
}

.forecast-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.forecast-day {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--hover-bg);
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.forecast-day:hover {
    transform: translateX(5px);
    background: var(--warning-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.forecast-date {
    font-weight: 600;
    font-size: 1.1rem;
}

.forecast-icon {
    width: 50px;
    height: 50px;
}

.forecast-temps {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.forecast-high {
    font-size: 1.2rem;
    font-weight: 700;
}

.forecast-low {
    font-size: 1.1rem;
    opacity: 0.7;
}

.forecast-desc {
    text-align: right;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Weather Insights */
.insights-section {
    margin-bottom: 3rem;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.insight-card {
    background: var(--hover-bg);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.insight-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.insight-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.insight-content {
    font-size: 0.95rem;
    line-height: 1.5;
    opacity: 0.8;
}

/* Air Quality */
.air-quality-section {
    margin-bottom: 3rem;
}

.air-quality-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    align-items: center;
    background: var(--hover-bg);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--glass-border);
}

.aqi-display {
    text-align: center;
}

.aqi-value {
    font-size: 3rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.aqi-label {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.aqi-description {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.pollutants {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 1rem;
}

.pollutant-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.pollutant-name {
    font-size: 0.8rem;
    opacity: 0.7;
}

.pollutant-value {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: var(--shadow-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 1rem;
    }
    
    .nav-title {
        display: none;
    }
    
    .main-container {
        padding: 80px 1rem 2rem;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .weather-main {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .temperature-display {
        text-align: center;
    }
    
    .main-temp {
        font-size: 4rem;
    }
    
    .weather-visual {
        flex-direction: column;
        text-align: center;
    }
    
    .time-date-display {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .details-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .astronomy-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .forecast-day {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 0.5rem;
    }
    
    .forecast-temps {
        justify-content: center;
    }
    
    .forecast-desc {
        text-align: center;
    }
    
    .air-quality-card {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 80px 0.5rem 2rem;
    }
    
    .weather-card {
        padding: 1.5rem;
        border-radius: 20px;
    }
    
    .location-info h1 {
        font-size: 2rem;
    }
    
    .main-temp {
        font-size: 3rem;
    }
    
    .current-time {
        font-size: 2rem;
    }
    
    .details-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-card {
        padding: 1rem;
    }
    
    .astronomy-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--hover-bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-gradient);
}

/* Smooth transitions for all interactive elements */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, 
                transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}