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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary-color: #64748b;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --warning-color: #d97706;
    --background: #ffffff;
    --surface: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

.header-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

/* Main Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* Search Section */
.search-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 2rem;
}

.search-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.tab-btn:hover {
    background: white;
    color: var(--text-primary);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.search-forms {
    padding: 1.5rem;
}

.search-form {
    display: none;
}

.search-form.active {
    display: block;
}

.form-group {
    display: flex;
    gap: 0.75rem;
}

input[type="text"],
input[type="number"],
select {
    flex: 1;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition);
    background: white;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

select {
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* Main Content Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Loading State */
.loading {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

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

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

/* Error Message */
.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--error-color);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Weather Display */
.weather-display {
    animation: fadeIn 0.3s ease;
}

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

.weather-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.weather-card-header {
    background: var(--surface);
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.location-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

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

.weather-card-body {
    padding: 2rem 1.5rem;
}

.weather-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.temperature-section {
    flex: 1;
}

.temperature {
    font-size: 3.5rem;
    font-weight: 300;
    line-height: 1;
    color: var(--text-primary);
}

.temperature .unit {
    font-size: 1.75rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.weather-description {
    margin-top: 0.5rem;
}

.weather-description .main {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    text-transform: capitalize;
}

.weather-description .feels-like {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.weather-icon-section {
    text-align: center;
}

.weather-icon-section img {
    width: 100px;
    height: 100px;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.detail-icon {
    width: 40px;
    height: 40px;
    background: var(--surface);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.25rem;
}

.detail-info {
    flex: 1;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Forecast Display */
.forecast-display {
    animation: fadeIn 0.3s ease;
}

.forecast-header {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
}

.forecast-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.forecast-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.forecast-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.forecast-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: var(--transition);
}

.forecast-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.forecast-date {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.forecast-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.forecast-icon img {
    width: 48px;
    height: 48px;
    margin: 0.5rem 0;
}

.forecast-temp {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.forecast-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* History Section */
.history-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.history-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-secondary);
}

.clear-history-btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

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

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.history-item {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

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

.history-item:hover {
    background: var(--surface);
}

.history-type {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.5rem;
}

.history-location {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.no-history {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Quick Stats */
.stats-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.stats-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.stat-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.875rem 1.25rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInUp 0.3s ease;
    max-width: 320px;
    font-size: 0.875rem;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.success {
    border-left: 3px solid var(--success-color);
}

.toast.error {
    border-left: 3px solid var(--error-color);
}

.toast.info {
    border-left: 3px solid var(--primary-color);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
    
    .history-section {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .search-tabs {
        flex-direction: column;
    }
    
    .form-group {
        flex-direction: column;
    }
    
    .weather-main {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .weather-details {
        grid-template-columns: 1fr;
    }
    
    .forecast-cards {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .temperature {
        font-size: 3rem;
    }
    
    .weather-icon-section img {
        width: 80px;
        height: 80px;
    }
}

/* Dark Mode */
[data-theme="dark"] {
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --primary-light: rgba(37, 99, 235, 0.1);
    --error-color: #ef4444;
}

[data-theme="dark"] body {
    background: var(--background);
}

[data-theme="dark"] .app-header {
    background: rgba(30, 41, 59, 0.95);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] input,
[data-theme="dark"] select {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] input::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .btn-secondary {
    background: var(--surface);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-secondary:hover {
    background: #334155;
    color: var(--text-primary);
}

[data-theme="dark"] .weather-card,
[data-theme="dark"] .forecast-card,
[data-theme="dark"] .history-section,
[data-theme="dark"] .stats-section,
[data-theme="dark"] .search-section,
[data-theme="dark"] .loading,
[data-theme="dark"] .forecast-header {
    background: var(--surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .weather-card-header,
[data-theme="dark"] .history-header,
[data-theme="dark"] .search-tabs {
    background: rgba(15, 23, 42, 0.5);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .tab-btn:hover {
    background: var(--surface);
}

[data-theme="dark"] .tab-btn.active {
    background: var(--surface);
}

[data-theme="dark"] .detail-icon {
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-secondary);
}

[data-theme="dark"] .history-item:hover {
    background: rgba(51, 65, 85, 0.3);
}

[data-theme="dark"] .error {
    background: rgba(127, 29, 29, 0.2);
    border-color: #991b1b;
    color: #fca5a5;
}

[data-theme="dark"] footer {
    background: var(--surface);
    border-top-color: var(--border-color);
}

[data-theme="dark"] .toast {
    background: var(--surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    transition: var(--transition);
    color: var(--text-secondary);
}

.theme-toggle:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.theme-icon {
    font-size: 1.25rem;
}

/* Logo Link */
.logo-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.logo-link:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}
