/* CSS Variables */
:root {
    --primary-bg: #1a1a2e;
    --secondary-bg: #16213e;
    --card-bg: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent: #4cc9f0;
    --danger: #ff6b6b;
    --success: #51cf66;
    
    --gradient-clear: linear-gradient(135deg, #56ccf6 0%, #2f80ed 100%);
    --gradient-cloudy: linear-gradient(135deg, #636fa4 0%, #e8cbc0 100%);
    --gradient-rainy: linear-gradient(135deg, #3a1c71 0%, #d76d77 50%, #ffaf7b 100%);
    --gradient-night: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --gradient-snow: linear-gradient(135deg, #83a4d4 0%, #b6fbff 100%);
    --gradient-storm: linear-gradient(135deg, #373b44 0%, #4286f4 100%);
    
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 20px;
    --radius-sm: 12px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-clear);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background 0.5s ease;
}

body.cloudy { background: var(--gradient-cloudy); }
body.rainy { background: var(--gradient-rainy); }
body.night { background: var(--gradient-night); }
body.snow { background: var(--gradient-snow); }
body.storm { background: var(--gradient-storm); }

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 20px;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.location-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.location-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.location-btn.loading svg {
    animation: spin 1s linear infinite;
}

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

/* Search */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 4px;
    backdrop-filter: blur(10px);
}

.search-icon {
    color: var(--text-secondary);
    margin-left: 12px;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
}

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

.search-clear {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.2s ease;
}

.search-clear.visible {
    opacity: 1;
}

.search-clear:active {
    background: rgba(255, 255, 255, 0.1);
}

/* Search Results */
.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--secondary-bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 100;
    display: none;
}

.search-results.active {
    display: block;
    animation: slideDown 0.3s ease;
}

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

.search-result-item {
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-result-item:hover,
.search-result-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.search-result-item svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-result-name {
    font-weight: 500;
}

.search-result-country {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Main Weather */
.weather-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Weather Content */
.weather-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.weather-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Current Weather */
.current-weather {
    text-align: center;
    padding: 20px 0 40px;
}

.weather-icon {
    font-size: 6rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
}

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

.temperature {
    font-size: 5rem;
    font-weight: 700;
    letter-spacing: -3px;
    line-height: 1;
    margin-bottom: 8px;
}

.condition {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: capitalize;
    margin-bottom: 8px;
}

.location-name {
    font-size: 1rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Weather Details */
.weather-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.detail-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 16px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.detail-card svg {
    color: var(--accent);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Forecast */
.forecast h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.forecast-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.forecast-day {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    transition: background 0.2s ease;
}

.forecast-day:active {
    background: rgba(255, 255, 255, 0.15);
}

.forecast-day-name {
    width: 50px;
    font-weight: 500;
    font-size: 0.9rem;
}

.forecast-day-icon {
    font-size: 1.75rem;
    margin: 0 12px;
}

.forecast-day-temp {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.forecast-day-temp .high {
    font-weight: 600;
    font-size: 1.1rem;
}

.forecast-day-temp .low {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Error */
.error-message {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 16px;
}

.error-message.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.error-message svg {
    color: var(--danger);
}

.error-message p {
    color: var(--text-secondary);
}

.retry-btn {
    background: var(--accent);
    color: var(--primary-bg);
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:active {
    transform: scale(0.95);
}

/* Responsive */
@media (min-width: 481px) {
    .app-container {
        padding: 30px;
    }
    
    .weather-icon {
        font-size: 8rem;
    }
    
    .temperature {
        font-size: 6rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-bg: #0d0d1a;
        --secondary-bg: #121225;
    }
}
