/* ============================================
   CSS CUSTOM PROPERTIES & RESET
   Coded by Nate
   ============================================ */

/* Dark Theme (default) */
:root,
[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-bg-card: #1e293b;
    --color-bg-card-hover: #334155;
    --color-text: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-accent: #38bdf8;
    --color-accent-hover: #7dd3fc;
    --color-error: #f87171;
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-border: #334155;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light Theme */
[data-theme="light"] {
    --color-bg: #f0f9ff;
    --color-bg-card: #ffffff;
    --color-bg-card-hover: #f1f5f9;
    --color-text: #0f172a;
    --color-text-secondary: #64748b;
    --color-accent: #0284c7;
    --color-accent-hover: #0369a1;
    --color-error: #dc2626;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-border: #e2e8f0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
    transition: background 0.5s ease;
}

/* Dynamic Weather Backgrounds */
body {
    background: linear-gradient(135deg, var(--color-bg) 0%, #1a1a2e 50%, #16213e 100%);
}

body.weather-clear {
    background: linear-gradient(135deg, #1e3a5f 0%, #0c1929 50%, #0a1628 100%);
}

body.weather-clear-day {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 50%, #075985 100%);
}

body.weather-clouds {
    background: linear-gradient(135deg, #374151 0%, #1f2937 50%, #111827 100%);
}

body.weather-rain,
body.weather-drizzle {
    background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 50%, #0f172a 100%);
}

body.weather-thunderstorm {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 50%, #0f0e24 100%);
}

body.weather-snow {
    background: linear-gradient(135deg, #64748b 0%, #475569 50%, #334155 100%);
}

body.weather-mist,
body.weather-fog,
body.weather-haze {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 50%, #374151 100%);
}

[data-theme="light"] body,
[data-theme="light"].weather-clear,
[data-theme="light"].weather-clouds,
[data-theme="light"].weather-rain {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 50%, #7dd3fc 100%);
}

/* ============================================
   LAYOUT
   ============================================ */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-accent), #818cf8);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-accent), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.logo .tagline {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 400;
    line-height: 1.2;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.25rem;
}

.theme-toggle:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-accent);
}

/* Search Container */
.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 250px;
}

.search-wrapper {
    display: flex;
    gap: 0.5rem;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.search-input::placeholder {
    color: var(--color-text-secondary);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    pointer-events: none;
}

.clear-search {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: none;
    font-size: 1.25rem;
    line-height: 1;
}

.clear-search:hover {
    color: var(--color-text);
}

.search-input:not(:placeholder-shown)+.search-icon+.clear-search {
    display: block;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    z-index: 100;
    display: none;
    overflow: hidden;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--color-bg-card-hover);
}

.autocomplete-item .highlight {
    color: var(--color-accent);
    font-weight: 600;
}

.autocomplete-item .location-icon {
    color: var(--color-text-secondary);
}

/* Location Button */
.location-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.location-btn:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-accent);
}

.location-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.location-btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-text-secondary);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Unit Toggle */
.unit-toggle {
    display: flex;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.unit-toggle button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.unit-toggle button.active {
    background: var(--color-accent);
    color: var(--color-bg);
    font-weight: 600;
}

.unit-toggle button:hover:not(.active) {
    color: var(--color-text);
}

/* ============================================
   WEATHER ALERTS
   ============================================ */
.weather-alerts {
    padding: 1rem 1.25rem;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    color: var(--color-warning);
    margin-bottom: 1rem;
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.alert-icon {
    font-size: 1.25rem;
}

.alert-title {
    font-weight: 600;
    flex: 1;
}

.dismiss-alert {
    background: none;
    border: none;
    color: var(--color-warning);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.dismiss-alert:hover {
    opacity: 0.7;
}

#alert-text {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    main {
        grid-template-columns: 1.5fr 1fr;
    }
}

/* Cards */
.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
}

/* Current Weather */
.current-weather {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.weather-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.location-info h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.location-info .date-time {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.temp-display {
    display: flex;
    align-items: flex-start;
}

.temp-value {
    font-size: 5rem;
    font-weight: 300;
    line-height: 1;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="light"] .temp-value {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.temp-unit {
    font-size: 2rem;
    font-weight: 400;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

/* Weather Icon Container with Animation */
.weather-icon-container {
    position: relative;
    width: 120px;
    height: 120px;
}

.weather-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

.weather-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Animated Weather Effects */
.weather-animation.sunny::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-in-out infinite;
}

.weather-animation.rainy::after {
    content: '💧💧💧';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    animation: rainDrop 1s ease-in-out infinite;
    opacity: 0.7;
}

.weather-animation.snowy::after {
    content: '❄️';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1rem;
    animation: snowFall 2s ease-in-out infinite;
}

.weather-animation.stormy::before {
    content: '⚡';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    animation: lightning 3s ease-in-out infinite;
}

.weather-animation.cloudy::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 60px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 50px;
    transform: translate(-50%, -50%);
    animation: cloudFloat 4s ease-in-out infinite;
}

.weather-animation.windy::after {
    content: '💨';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    animation: windBlow 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

@keyframes rainDrop {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 0.7;
    }

    50% {
        transform: translateX(-50%) translateY(5px);
        opacity: 0.4;
    }
}

@keyframes snowFall {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: translateY(5px) rotate(180deg);
        opacity: 0.6;
    }
}

@keyframes lightning {

    0%,
    90%,
    100% {
        opacity: 0;
    }

    92%,
    94% {
        opacity: 1;
    }
}

@keyframes cloudFloat {

    0%,
    100% {
        transform: translate(-50%, -50%) translateX(0);
    }

    50% {
        transform: translate(-50%, -50%) translateX(10px);
    }
}

@keyframes windBlow {

    0%,
    100% {
        transform: translateY(-50%) translateX(0);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-50%) translateX(5px);
        opacity: 0.5;
    }
}

.weather-condition {
    flex: 1;
    min-width: 150px;
}

.condition-text {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: capitalize;
}

.feels-like {
    color: var(--color-text-secondary);
    font-size: 1rem;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}

[data-theme="light"] .detail-item {
    background: rgba(0, 0, 0, 0.03);
}

.detail-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(56, 189, 248, 0.1);
    border-radius: var(--radius-sm);
    color: var(--color-accent);
    font-size: 1.25rem;
}

.detail-info {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-value {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Forecast */
.forecast-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--color-text-secondary);
}

.forecast-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.forecast-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

[data-theme="light"] .forecast-card {
    background: rgba(0, 0, 0, 0.03);
}

.forecast-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .forecast-card:hover {
    background: rgba(0, 0, 0, 0.05);
}

.forecast-day {
    font-weight: 600;
    min-width: 80px;
}

.forecast-icon {
    width: 50px;
    height: 50px;
}

.forecast-precip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--color-accent);
    font-size: 0.9rem;
    min-width: 50px;
}

.forecast-temps {
    display: flex;
    gap: 0.5rem;
    min-width: 80px;
    justify-content: flex-end;
}

.forecast-high {
    font-weight: 600;
}

.forecast-low {
    color: var(--color-text-secondary);
}

/* ============================================
   FOOTER & RECENT SEARCHES
   ============================================ */
footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.recent-searches {
    margin-bottom: 1rem;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.recent-header h4 {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.clear-recent {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}

.clear-recent:hover {
    color: var(--color-error);
}

.recent-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.recent-chip {
    padding: 0.5rem 1rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 50px;
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.recent-chip:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-accent);
}

.last-updated {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.credits {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ============================================
   ERROR & LOADING STATES
   ============================================ */
.error-message {
    display: none;
    padding: 1rem 1.25rem;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--color-error);
    border-radius: var(--radius-md);
    color: var(--color-error);
    margin-bottom: 1rem;
}

.error-message.active {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.error-message button {
    margin-left: auto;
    padding: 0.5rem 1rem;
    background: var(--color-error);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
    cursor: pointer;
}

.setup-instructions {
    text-align: center;
    padding: 3rem 1.5rem;
}

.setup-instructions h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.setup-instructions code {
    display: block;
    background: var(--color-bg);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    font-size: 0.9rem;
    overflow-x: auto;
}

/* Loading Skeleton */
.loading-skeleton {
    display: contents;
}

.skeleton {
    background: linear-gradient(90deg, var(--color-bg-card) 25%, var(--color-bg-card-hover) 50%, var(--color-bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-temp {
    width: 180px;
    height: 80px;
}

.skeleton-icon {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1.5rem;
    margin-bottom: 0.5rem;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-detail {
    height: 60px;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}