:root {
    --bg-midnight: #020617;
    --bg-deep: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --secondary-bg: rgba(15, 23, 42, 0.85);
    --mood-color-1: rgba(59, 130, 246, 0.2);
    --mood-color-2: rgba(139, 92, 246, 0.15);
    --mood-glow: rgba(255, 255, 255, 0.2);
    --border-radius: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overscroll-behavior-y: auto;
    background-color: var(--bg-midnight);
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: linear-gradient(to bottom, var(--bg-deep), var(--bg-midnight));
    background-attachment: fixed;
    line-height: 1.5;
}

/* Atmospheric Mood Blobs - Hyper-optimized with radial gradients instead of blur filters */
.mood-blob {
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    opacity: 1; /* Opacity controlled by the transparent gradient */
    transition: background 3s ease-in-out;
    pointer-events: none;
    will-change: background;
}

.blob-1 {
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, var(--mood-color-1) 0%, transparent 65%);
    top: -200px;
    right: -200px;
}

.blob-2 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, var(--mood-color-2) 0%, transparent 65%);
    bottom: -150px;
    left: -150px;
}

.blob-3 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--mood-color-1) 0%, transparent 65%);
    top: 40%;
    left: 20%;
    opacity: 0.4;
}

/* Dynamic Themes - Neutral & Atmospheric */
.theme-default {
    --mood-color-1: rgba(59, 130, 246, 0.15);
    --mood-color-2: rgba(139, 92, 246, 0.1);
    --mood-glow: rgba(59, 130, 246, 0.3);
}
.theme-clear {
    --mood-color-1: rgba(251, 191, 36, 0.15); /* Soft Amber */
    --mood-color-2: rgba(245, 158, 11, 0.1); /* Soft Orange */
    --mood-glow: rgba(251, 191, 36, 0.4);
    --secondary-bg: rgba(30, 41, 59, 0.8);
}
.theme-cloudy {
    --mood-color-1: rgba(148, 163, 184, 0.2);
    --mood-color-2: rgba(71, 85, 105, 0.15);
    --mood-glow: rgba(148, 163, 184, 0.3);
}
.theme-rain {
    --mood-color-1: rgba(37, 99, 235, 0.15);
    --mood-color-2: rgba(30, 41, 59, 0.2);
    --mood-glow: rgba(37, 99, 235, 0.4);
}
.theme-night {
    --mood-color-1: rgba(79, 70, 229, 0.15);
    --mood-color-2: rgba(17, 24, 39, 0.3);
    --mood-glow: rgba(79, 70, 229, 0.2);
}
.theme-storm {
    --mood-color-1: rgba(30, 41, 59, 0.3);
    --mood-color-2: rgba(2, 6, 23, 0.4);
    --mood-glow: rgba(255, 255, 255, 0.1);
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

/* Header & Search */
header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    position: relative;
    z-index: 100;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(to right, var(--gradient-1), var(--gradient-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.search-form {
    width: 100%;
    position: relative;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.search-form:focus-within {
    transform: translateY(-2px);
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: color 0.3s ease;
}

input[type="text"] {
    width: 100%;
    padding: 1.25rem 3.5rem 1.25rem 3.5rem;
    border-radius: 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 8px 32px 0 rgba(59, 130, 246, 0.2);
    background: rgba(30, 41, 59, 0.6);
}

input[type="text"]:focus+.search-icon {
    color: var(--accent);
}

.geo-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
}

.geo-btn:hover {
    color: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

/* Autocomplete Suggestions */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    margin-top: 0.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    z-index: 50;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.suggestions-dropdown.hidden {
    display: none;
}

.suggestion-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-item:last-child {
    border-bottom: none;
}

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

.suggestion-city {
    font-weight: 500;
    color: var(--text-primary);
}

.suggestion-country {
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* Favorites */
.favorites-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    width: 100%;
    padding: 0.5rem 0;
}

.fav-chip-wrapper {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.fav-chip-wrapper:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.fav-chip-wrapper.active {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.fav-chip {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem 0.6rem 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.fav-chip-wrapper.active .fav-chip {
    font-weight: 600;
}

.fav-delete-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.5rem 1rem 0.5rem 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.fav-delete-btn:hover {
    color: #ef4444;
}

/* Glass Cards Generic - Optimized */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    will-change: transform;
}

/* Only apply expensive blur to the most important cards */
.main-weather.glass-card, 
.hourly-forecast.glass-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* For secondary cards, use a more opaque background instead of blur */
.detail-card.glass-card,
.solar-card.glass-card,
.forecast.glass-card,
.error-card,
.suggestions-dropdown {
    background: var(--secondary-bg); /* Use theme-aware background */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Dashboard Animations */
.weather-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.weather-dashboard.show {
    opacity: 1;
    transform: translateY(0);
}

/* Main Weather */
.main-weather {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.location-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    justify-content: center;
}

.fav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.fav-btn.active {
    color: #fbbf24;
}

.location-info h2 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.country {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.25rem;
}

.temperature-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

.weather-main-icon {
    font-size: 5rem;
    color: var(--text-primary);
    filter: drop-shadow(0 0 30px var(--mood-glow));
    animation: pulse 4s infinite ease-in-out;
    will-change: transform;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.temp-wrapper {
    display: flex;
    align-items: flex-start;
}

.temp-value {
    font-size: 6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
}

.temp-unit {
    font-size: 2rem;
    font-weight: 500;
    margin-top: 0.5rem;
    color: var(--text-secondary);
}

.weather-desc {
    font-size: 1.5rem;
    font-weight: 500;
    text-transform: capitalize;
    margin-bottom: 0.5rem;
}

.hl-temp {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Detail Cards */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* Se o último cartão estiver sozinho (índice par devido ao solar-card ser índice 1) */
.grid-cards > .detail-card:last-child:nth-child(even) {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.detail-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.3s ease, background 0.3s ease;
}

.detail-card:hover {
    transform: translateY(-5px);
    background: rgba(30, 41, 59, 0.6);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.detail-header i {
    color: var(--accent);
}

.detail-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.solar-card {
    grid-column: span 2;
    overflow: hidden;
}

.solar-arc-container {
    position: relative;
    height: 100px;
    width: 100%;
    margin: 1rem 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.solar-arc-svg {
    width: 100%;
    height: 100%;
    stroke-dasharray: 4;
}

.sun-indicator {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #fbbf24;
    border-radius: 50%;
    box-shadow: 0 0 20px #fbbf24, 0 0 40px rgba(251, 191, 36, 0.4);
    z-index: 10;
    transform: translate3d(-50%, 50%, 0);
    animation: sunPulse 3s infinite ease-in-out;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

@keyframes sunPulse {
    0%, 100% { transform: translate3d(-50%, 50%, 0) scale(1); opacity: 0.7; }
    50% { transform: translate3d(-50%, 50%, 0) scale(1.2); opacity: 1; }
}

.solar-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

.solar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.solar-item i {
    font-size: 0.8rem;
}

/* Hourly Forecast Timeline */
.hourly-forecast {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hourly-forecast h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
}

.hourly-list-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding-bottom: 0.5rem;
}

.hourly-chart-overlay {
    position: absolute;
    bottom: 2.5rem; /* Aligned between icon and temp */
    left: 0;
    height: 100px;
    pointer-events: none;
    z-index: 1;
}

.hourly-list {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 0.5rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

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

.hourly-list::-webkit-scrollbar-track {
    background: transparent;
}

.hourly-list::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    min-width: 80px; /* Fixed width for chart alignment */
    width: 80px;     /* Fixed width for chart alignment */
    scroll-snap-align: start;
    padding: 1rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s ease, transform 0.2s ease;
    z-index: 2; /* Content above line */
}

.hourly-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

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

.hourly-icon {
    font-size: 1.4rem;
    color: var(--text-primary);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.1));
    z-index: 3;
}

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

/* Forecast list */
.forecast h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.forecast-accordion-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.forecast-accordion-item:last-child {
    border-bottom: none;
}

.forecast-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    transition: padding 0.3s ease;
    gap: 0.5rem;
    cursor: pointer;
}

.forecast-item:hover {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.accordion-icon {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    margin-left: 0.2rem;
    display: flex;
    align-items: center;
}

.forecast-accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.forecast-dropdown {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}

.forecast-dropdown-inner {
    overflow: hidden;
}

.forecast-accordion-item.active .forecast-dropdown {
    grid-template-rows: 1fr;
}

.forecast-dropdown .hourly-list {
    padding-bottom: 1rem;
    padding-top: 0.5rem;
}

.forecast-day-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    /* Ensures text wrap inside flex item */
}

.forecast-day {
    font-size: 1.1rem;
    font-weight: 500;
}

.forecast-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

.forecast-date {
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 400;
    margin-left: 0.2rem;
}

.forecast-icon {
    font-size: 1.5rem;
    flex: 0 0 30px;
    text-align: center;
}

.forecast-temps {
    flex: 0 0 100px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
}

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

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

/* Error Card */
.error-card {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    color: #fca5a5;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    backdrop-filter: blur(12px);
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

.error-card i {
    font-size: 3rem;
    color: #ef4444;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Loading State for JS */
.loading-indicator {
    display: none;
    justify-content: center;
    padding: 2rem;
    color: var(--accent);
}

.loading-indicator i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

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

@media (max-width: 480px) {
    .app-container {
        padding: 1rem;
    }

    .temp-value {
        font-size: 5rem;
    }

    .grid-cards {
        grid-template-columns: 1fr;
    }
}