/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

/* Main Container */
main {
    max-width: 500px;
    margin: 0 auto;
    padding: 40px 20px;
}

h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 8px;
    color: #1f2937;
}

.subtitle {
    text-align: center;
    color: #6b7280;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

/* Error Message */
.error-message {
    max-width: 500px;
    margin: 0 auto 16px;
    padding: 12px 16px;
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #991b1b;
    font-size: 0.9rem;
    text-align: center;
}

/* Form Styles */
.input-section {
    background: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row .form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="date"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: #f3f4f6;
}

/* Toggle Switch (Pill Style) */
.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-switch {
    position: relative;
    width: 120px;
    height: 36px;
    background-color: #e5e7eb;
    border-radius: 18px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 56px;
    height: 30px;
    background-color: white;
    border-radius: 15px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch input[type="checkbox"]:checked ~ .slider {
    transform: translateX(58px);
}

.toggle-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-weight: 600;
    font-size: 0.85rem;
    pointer-events: none;
}

.toggle-text .fahrenheit {
    color: #2563eb;
}

.toggle-text .celsius {
    color: #6b7280;
}

.toggle-switch input[type="checkbox"]:checked ~ .toggle-text .fahrenheit {
    color: #6b7280;
}

.toggle-switch input[type="checkbox"]:checked ~ .toggle-text .celsius {
    color: #2563eb;
}

.toggle-hint {
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.8rem;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 14px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.submit-btn:hover {
    background-color: #1d4ed8;
}

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

.submit-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.data-attribution {
    margin-top: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.8rem;
}

/* Loading Spinner */
.spinner {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.spinner-circle {
    width: 50px;
    height: 50px;
    margin: 0 auto 16px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner p {
    color: #6b7280;
    font-size: 0.95rem;
}

/* Results Section */
.results-section {
    margin-top: 32px;
    animation: fadeIn 0.4s ease-in;
}

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

.results-header {
    text-align: center;
    margin-bottom: 24px;
}

.results-header h2 {
    font-size: 1.5rem;
    color: #1f2937;
    margin-bottom: 4px;
}

.results-header p {
    color: #6b7280;
    font-size: 0.95rem;
}

/* Weather Grid Layouts */
.weather-grid {
    margin-bottom: 32px;
}

.month-header {
    font-size: 1.3rem;
    color: #1f2937;
    font-weight: 600;
    text-align: center;
    margin: 24px 0 16px 0;
}

.month-header:first-child {
    margin-top: 0;
}

.month-spacer {
    height: 16px;
}

.grid-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.grid-two-rows {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.grid-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    gap: 12px;
}

/* Weekday Headers (for calendar view) */
.weekday-header {
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #6b7280;
    padding: 8px 0;
}

/* Day Cards */
.day-card {
    background: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    min-width: 110px;
}

.day-card.empty {
    background: transparent;
    box-shadow: none;
    pointer-events: none;
    min-width: 0;
}

.day-card:not(.empty):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.day-card .date {
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.day-card .icon {
    font-size: 3rem;
    margin: 12px 0;
    display: block;
}

.day-card .condition {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 12px;
}

.day-card .temps {
    font-size: 0.85rem;
    line-height: 1.8;
}

.day-card .temp-high {
    color: #dc2626;
    font-weight: 600;
}

.day-card .temp-low {
    color: #2563eb;
    font-weight: 600;
}

.day-card .temp-avg {
    color: #374151;
}

/* Background Tints by Condition */
.day-card.sunny {
    background-color: #fffbeb;
}

.day-card.cloudy {
    background-color: #f3f4f6;
}

.day-card.rain {
    background-color: #eff6ff;
}

.day-card.snow {
    background-color: #f5f3ff;
}

.day-card.storm {
    background-color: #fff7ed;
}

.day-card.fog {
    background-color: #f9fafb;
}

/* Legend */
.legend {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 32px;
}

.legend h3 {
    font-size: 1.1rem;
    color: #1f2937;
    margin-bottom: 16px;
    text-align: center;
}

.legend-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #374151;
    padding: 8px 12px;
    border-radius: 8px;
}

.legend-item .icon {
    font-size: 1.3rem;
}

.legend-item.sunny {
    background-color: #fffbeb;
}

.legend-item.partly-cloudy {
    background-color: #f3f4f6;
}

.legend-item.cloudy {
    background-color: #f3f4f6;
}

.legend-item.rain {
    background-color: #eff6ff;
}

.legend-item.snow {
    background-color: #f5f3ff;
}

.legend-item.storm {
    background-color: #fff7ed;
}

.legend-item.fog {
    background-color: #f9fafb;
}

/* Responsive Design */
@media (max-width: 600px) {
    main {
        padding: 20px 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .input-section {
        padding: 24px 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .grid-calendar,
    .grid-two-rows {
        grid-template-columns: repeat(7, minmax(60px, 1fr));
        gap: 6px;
    }

    .day-card {
        padding: 10px 6px;
        min-width: 60px;
    }

    .day-card .icon {
        font-size: 2rem;
        margin: 6px 0;
    }

    .day-card .date {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }

    .day-card .condition {
        display: none;
    }

    .day-card .temps {
        font-size: 0.7rem;
        line-height: 1.5;
    }

    .day-card .temp-avg {
        display: none;
    }

    .weekday-header {
        font-size: 0.7rem;
        padding: 6px 0;
    }

    .legend {
        padding: 16px;
    }

    .legend-grid {
        gap: 12px;
    }

    .legend-item {
        font-size: 0.75rem;
    }
}
