/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Sections */
.section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.section-title svg {
    width: 22px;
    height: 22px;
    color: var(--primary-color);
}

/* Location Section */
.location-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.divider {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-container {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.search-container .input-field {
    flex: 1;
}

.location-display {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.location-name {
    font-weight: 600;
    font-size: 1.125rem;
}

.location-coords {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Weather Section */
.weather-card {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.weather-icon {
    font-size: 4rem;
    line-height: 1;
}

.weather-temp {
    font-size: 3rem;
    font-weight: 700;
}

.weather-details {
    flex: 1;
}

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

.weather-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.weather-info span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.weather-info svg {
    width: 16px;
    height: 16px;
}

/* Theme Section */
.theme-options {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.theme-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.theme-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.style-buttons,
.mood-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.style-btn,
.mood-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.style-btn.active,
.mood-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Preview Section */
.preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--background);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

#wallpaperCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.preview-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Auto Update Section */
.auto-update-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--secondary-color);
    border-radius: 26px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.update-interval {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.next-update {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.next-update svg {
    width: 18px;
    height: 18px;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

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

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

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

.btn-large {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Input Fields */
.input-field {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

/* Select Fields */
.select-field {
    padding: 0.625rem 2rem 0.625rem 1rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' 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: 18px;
}

.select-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Footer */
.footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.875rem 1.5rem;
    background: var(--surface);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

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

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

.toast.warning {
    border-left: 4px solid var(--warning);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 1001;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 1.35rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .section {
        padding: 1.25rem;
    }

    .location-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .divider {
        text-align: center;
    }

    .search-container {
        flex-direction: column;
    }

    .weather-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .weather-main {
        flex-direction: column;
    }

    .weather-icon {
        font-size: 3rem;
    }

    .weather-temp {
        font-size: 2.5rem;
    }

    .weather-info {
        align-items: center;
    }

    .style-buttons,
    .mood-buttons {
        justify-content: center;
    }

    .preview-container {
        aspect-ratio: 4 / 3;
    }

    .preview-actions {
        flex-direction: column;
    }

    .btn-large {
        width: 100%;
    }

    .update-interval {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .weather-icon {
        font-size: 2.5rem;
    }

    .weather-temp {
        font-size: 2rem;
    }

    .style-btn,
    .mood-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}
