/* --- Global Styles --- */
:root {
    --color-primary: #2563eb; /* Blue-600 */
    --color-primary-dark: #1d4ed8; /* Blue-700 */
    --color-indigo: #4f46e5; /* Indigo-600 */
    --color-gray-100: #f3f4f6;
    --color-gray-300: #d1d5db;
    --color-gray-800: #1f2937;
    --color-red-100: #fee2e2;
    --color-red-400: #f87171;
    --color-red-700: #b91c1c;
}

body {
    /* FIX: Explicitly remove browser's default margin and padding */
    margin: 0 !important;
    padding: 0 !important;
    
    font-family: 'Inter', sans-serif;
    background-color: #f7f9fb;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* Default body padding for index.php (desktop) */
@media (min-width: 640px) {
    body:not(.is-results-page) {
        padding: 2rem; /* sm:p-8 */
    }
}

/* --- Card Container (Default for index.php) --- */
.weather-card {
    width: 100%;
    max-width: 576px; /* max-w-lg */
    background-color: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-xl */
    border-radius: 1rem; /* rounded-2xl */
    padding: 0; 
    margin-top: 3rem; /* mt-12 */
    border: 1px solid #e5e7eb; /* border-gray-100 equivalent */
}

/* --- RESULTS PAGE OVERRIDES (body.is-results-page) --- */
.is-results-page .weather-card {
    background-color: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
    margin-top: 0; 
    max-width: 100%; /* Go full screen on mobile */
}

@media (min-width: 640px) {
    .is-results-page .weather-card {
        max-width: 576px; /* Keep the max-w-lg for desktop */
        margin-top: 3rem; /* Re-add margin to center it better vertically */
    }
}


/* --- Header --- */
.main-title {
    font-size: 1.875rem; /* text-3xl */
    font-weight: 700; /* font-bold */
    color: var(--color-gray-800);
    margin-bottom: 1.5rem; /* mb-6 */
    text-align: center;
}

/* --- Form Styles --- */
.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* gap-4 */
    margin-bottom: 2rem; /* mb-8 */
    padding: 0 1.5rem;
}

@media (min-width: 640px) {
    .search-form {
        flex-direction: row; /* sm:flex-row */
    }
}

.city-input {
    flex-grow: 1; /* flex-grow */
    padding: 0.75rem; /* p-3 */
    border: 1px solid var(--color-gray-300);
    border-radius: 0.5rem; /* rounded-lg */
    transition: all 150ms ease-in-out;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
}

.city-input:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.search-button {
    background-color: var(--color-primary);
    color: white;
    font-weight: 600; /* font-semibold */
    padding: 0.75rem 1.5rem; /* py-3 px-6 */
    border-radius: 0.5rem; /* rounded-lg */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06); /* shadow-md */
    transition: all 200ms ease-in-out;
    border: none;
}

.search-button:hover {
    background-color: var(--color-primary-dark);
    transform: scale(1.01);
}

.search-button:active {
    transform: scale(0.99);
}

/* --- Subtle Back Link for Display Page --- */
.subtle-back-link {
    display: block;
    width: fit-content;
    margin-top: 2rem; /* mt-8 */
    text-decoration: none;
    text-align: center;
    font-size: 0.875rem; /* text-sm */
    color: #6b7280; /* text-gray-500 */
    font-weight: 500;
    transition: color 200ms ease-in-out;
}

.subtle-back-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* --- Error Message --- */
.error-message {
    background-color: var(--color-red-100);
    border: 1px solid var(--color-red-400);
    color: var(--color-red-700);
    padding: 1rem; /* px-4 py-3 */
    border-radius: 0.75rem; /* rounded-xl */
    margin: 1.5rem 1.5rem 0 1.5rem; 
}

.error-message-display-page {
    margin: 1.5rem 1.5rem 0 1.5rem; 
}

.error-message p { margin: 0; }
.error-message .font-semibold { font-weight: 600; }

/* --- Weather Display Section --- */
.weather-display {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* --- Data Wrapper (Adds back padding below the image) --- */
.data-section-wrapper {
    /* REDUCED vertical padding to tighten the gap between image and text */
    padding: 1rem 1.5rem 1.5rem 1.5rem; 
    color: var(--color-gray-800);
}

.location-info {
    text-align: center;
    margin-bottom: 1.5rem; 
    color: var(--color-gray-800);
}

.location-info h2 {
    /* Made these smaller since the main title is in the overlay */
    font-size: 1.5rem; 
    font-weight: 400; 
    margin-bottom: 0.25rem; 
    color: var(--color-gray-800);
}

.location-info p {
    font-size: 0.875rem; /* text-sm */
    font-weight: 300; /* font-light */
    opacity: 0.8; 
    color: var(--color-gray-800);
}

/* --- Cartoon Image and Overlay Container --- */
.cartoon-image-container {
    position: relative; /* Essential for positioning overlay text */
    width: 100%;
    overflow: hidden; 
}

/* Remove border radius on the results page for full-bleed image */
.is-results-page .cartoon-image-container,
.is-results-page .cartoon-image {
    border-radius: 0;
}

.cartoon-image {
    width: 100%; 
    height: auto;
    display: block;
}

/* --- Overlay Text Styling --- */
.overlay-text {
    position: absolute;
    top: 10%; /* Place in the top half */
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    width: 90%; 
    text-align: center;
    color: white;
    font-size: 1.5rem; /* text-2xl */
    font-weight: 700; /* font-bold */
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7); /* Strong shadow for readability */
    pointer-events: none;
}

@media (min-width: 640px) {
    .overlay-text {
        font-size: 2.5rem; /* Larger text for desktop */
        top: 15%; 
    }
}


/* --- Details Row --- */
.details-row {
    /* Default (mobile) is flex row to save space */
    display: flex;
    flex-direction: row; /* MODIFIED: Start as row on mobile */
    align-items: flex-start; /* Align to the top of the section */
    justify-content: space-between;
    width: 100%;
    margin-top: 0.5rem; /* Slight reduction in top margin */
}

@media (min-width: 640px) {
    .details-row {
        flex-direction: row; /* Keep as row on desktop */
        align-items: center; /* Center align items on desktop */
        margin-top: 1rem; /* Restore desktop margin */
    }
}

.temp-section {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Reduced gap */
    margin-bottom: 0; /* Removed bottom margin */
    color: var(--color-gray-800);
    flex-grow: 1; /* Allows it to take up space on the left */
}

@media (min-width: 640px) {
    .temp-section {
        margin-bottom: 0; 
        gap: 1rem; /* Restore desktop gap */
        flex-grow: 0;
    }
}

/* --- SIZE REDUCTION FOR MOBILE --- */
.api-icon {
    width: 3rem; /* Reduced size on mobile (from 4rem) */
    height: 3rem; /* Reduced size on mobile (from 4rem) */
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05)); 
}
@media (min-width: 640px) {
    .api-icon {
        width: 4rem; /* Restore size on desktop */
        height: 4rem; /* Restore size on desktop */
    }
}
.temp-value {
    text-align: left;
}

.temp-value p:first-child {
    font-size: 1.75rem; /* Reduced size on mobile (from 2.25rem) */
    font-weight: 800; /* font-extrabold */
    line-height: 1.1; /* Tighten line height */
}
@media (min-width: 640px) {
    .temp-value p:first-child {
        font-size: 2.25rem; /* Restore size on desktop */
    }
}

.temp-value p:last-child {
    font-size: 0.875rem; /* Reduced size on mobile (from 1rem) */
    font-weight: 500; /* font-medium */
    text-transform: capitalize;
    line-height: 1; /* Tighten line height */
}
@media (min-width: 640px) {
    .temp-value p:last-child {
        font-size: 1rem; /* Restore size on desktop */
    }
}

/* --- Metrics Section --- */
.metrics-section {
    text-align: right;
    font-size: 0.875rem; /* text-sm */
    color: var(--color-gray-800);
}

.metrics-section p {
    /* REDUCED vertical spacing for tighter line-up */
    margin-top: 0.25rem; 
    line-height: 1.2;
}

.metrics-section strong {
    font-weight: 700;
}

.last-updated {
    font-size: 0.75rem; /* text-xs */
    opacity: 0.75; 
    margin-top: 0.5rem !important; 
}

/* --- Footer --- */
.footer {
    padding: 1rem 1.5rem 1.5rem 1.5rem; 
    border-top: 1px solid #e5e7eb; /* border-t */
    text-align: center;
    font-size: 0.75rem; /* text-xs */
    color: #6b7280; /* text-gray-500 */
}

/* Ensure the footer border is active when the card border is removed on the results page */
.is-results-page .footer {
    border-top: 1px solid #e5e7eb;
}

.footer a {
    color: var(--color-primary);
}

.footer a:hover {
    color: var(--color-primary-dark);
}