/**
 * @file style.css
 * @description Main stylesheet for the weathers.pro application.
 * @author Roo
 * @version 1.1.0
 */

/* --- General & Layout --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* --- Header --- */
header {
    background-color: #fff;
    padding: 0 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a1a1a;
    text-decoration: none;
}

/* --- Search Section --- */
.search-section {
    position: relative;
    width: 400px;
}

#search-form {
    display: flex;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px 0 0 20px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: #007bff;
}

#search-form button {
    padding: 0.75rem 1.5rem;
    border: 1px solid #007bff;
    background-color: #007bff;
    color: white;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

#search-form button:hover {
    background-color: #0056b3;
}

#search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: none; /* Hidden by default */
    max-height: 300px;
    overflow-y: auto;
}

#search-suggestions div {
    padding: 0.75rem 1rem;
    cursor: pointer;
}

#search-suggestions div:hover {
    background-color: #f0f2f5;
}

/* --- Footer --- */
footer {
    background-color: #fff;
    padding: 1rem 2rem;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
    text-align: center;
    margin-top: auto;
    font-size: 0.9rem;
    color: #666;
    width: 100%;
    box-sizing: border-box;
}

/* --- Weather & Content Containers --- */
.weather-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 2rem;
}

.loading-message {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
    padding: 4rem 0;
}

h2, h3 {
    color: #1c5a9b;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    margin-top: 20px;
}

/* --- Current Weather Display --- */
.current-weather-section {
    text-align: left;
    border-bottom: 1px solid #eee;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

.current-weather-section h1 {
    font-size: 1.6rem; /* Reduced size */
    margin-bottom: 1rem;
    color: #1a1a1a;
}

.current-weather-details {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 2rem;
    text-align: left;
}

.temp-description {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

.weather-icon-large {
    width: 128px;
    height: 128px;
}

.current-weather-details .temp {
    font-size: 4rem;
    font-weight: 400;
}

.current-weather-details .description {
    font-size: 1.5rem;
    color: #555;
    text-transform: capitalize;
}

.current-weather-details .weather-details-list {
    list-style: none;
    padding: 0;
    margin: 0;
    color: #666;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 20px; /* Significantly increased padding */
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
    box-sizing: border-box; /* Ensure padding is included in width to prevent overflow */
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item .detail-label {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #555;
}

.detail-item .detail-label::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 12px; /* Increased space after icon */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
}

/* Simple CSS Icons using Emojis/Symbols tailored for styling */
/* Using inline SVG or specialized characters for a cleaner look than standard emojis if possible,
   but emojis are the most reliable "text-based icon" solution without external assets.
   We style them to look more like flat icons. */

.detail-item.type-pop .detail-label::before { content: '💧'; }
.detail-item.type-thermometer .detail-label::before { content: '🌡️'; }
.detail-item.type-wind .detail-label::before { content: '🌬️'; }
.detail-item.type-wind-gust .detail-label::before { content: '💨'; }
.detail-item.type-humidity .detail-label::before { content: '💦'; }
.detail-item.type-pressure .detail-label::before { content: '⏲️'; }
.detail-item.type-visibility .detail-label::before { content: '👁️'; }
.detail-item.type-cloud .detail-label::before { content: '☁️'; }
.detail-item.type-sun .detail-label::before { content: '☀️'; }
.detail-item.type-dew-point .detail-label::before { content: '💧'; filter: hue-rotate(180deg); } /* Variation */
.detail-item.type-rain .detail-label::before { content: '🌧️'; }
.detail-item.type-snow .detail-label::before { content: '❄️'; }
.detail-item.type-water .detail-label::before { content: '🌊'; }
.detail-item.type-mountain .detail-label::before { content: '⛰️'; }
.detail-item.type-aqi .detail-label::before { content: '😷'; }

.detail-item .detail-value {
    font-weight: 600;
    color: #333;
    margin-left: 10px; /* Ensure space between long label and value */
    text-align: right;
}

/* --- Forecast Tables --- */
.hourly-forecast-table, .daily-forecast-table {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    padding-top: 5px; /* Add top padding for border visibility */

    border-top: 1px solid #eee;
    cursor: grab;
    /* Hide scrollbar for modern "drag" feel */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
    user-select: none; /* Prevent text selection during drag */
}

.hourly-forecast-table.active, .daily-forecast-table.active {
    cursor: grabbing;
    cursor: -webkit-grabbing;
}

/* Specific style for forecast items to maintain width and scrolling */
.hourly-forecast-table .forecast-item, .daily-forecast-table .forecast-item {
    flex: 0 0 100px; /* Fixed width for items */
    min-width: 100px;
}

.hourly-forecast-table::-webkit-scrollbar, .daily-forecast-table::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
}

.forecast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align items to top */
    text-align: center;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 15px 10px; /* Keep padding */
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.2s;
    min-height: 140px; /* Slightly reduced height */
}

.forecast-item:hover {
    background-color: #e9e9e9;
    transform: translateY(-3px);
}

.forecast-item.selected {
    background-color: #eef6fc;
    border: 1px solid #1c5a9b;
    color: #1c5a9b;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(28, 90, 155, 0.2);
}

.weather-icon-small {
    width: 50px;
    height: 50px;
}

.forecast-item .time, .forecast-item .day {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.9rem; /* Standardize font size */
}

.forecast-item .date-display {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.2;
    white-space: nowrap; /* Keep date on one line if possible, or remove if wrapping needed */
}

.forecast-item .temp, .forecast-item .temp-range {
    font-weight: 500;
    font-size: 1rem; /* Standardize font size */
}

.forecast-item .pop {
    font-size: 0.8rem;
    color: #555;
    margin-top: 2px;
}

/* --- Other Sections --- */
.air-pollution-details ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    list-style: none;
    padding: 0;
    font-size: 0.85rem; /* Reduced font size for pollution data */
}

.error-container {
    text-align: center;
    padding: 40px;
}

.error-details {
    background: #eee;
    padding: 10px;
    border-radius: 4px;
    color: #d32f2f;
    white-space: pre-wrap;
}
/* --- Info Box --- */
.info-box {
    background-color: #f0f8ff;
    border-left: 4px solid #1c5a9b;
    padding: 15px;
    margin-top: 1rem;
    margin-bottom: 2rem;
    border-radius: 0 4px 4px 0;
}

.info-box p {
    margin: 0;
    font-size: 0.9rem;
    color: #333;
    line-height: 1.5;
}

/* --- Responsive Design (Mobile) --- */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    header {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: column;
        height: auto;
        padding: 1rem 0;
        gap: 1rem;
    }

    .search-section {
        width: 100%; /* Full width search on mobile */
        max-width: 100%; /* Allow full width */
    }

    .current-weather-details {
        grid-template-columns: 1fr; /* Stack vertically */
        text-align: center;
        gap: 1.5rem;
    }

    .current-weather-details .weather-icon-large {
        margin: 0 auto; /* Center icon */
        display: block; /* Ensure it behaves as a block for margin auto */
    }

    .temp-description {
        flex-direction: column; /* Stack temp and desc */
        justify-content: center;
        text-align: center;
        gap: 0.5rem;
    }

    .current-weather-details .temp {
        font-size: 3.5rem; /* Slightly smaller temp */
    }

    .current-weather-details .description {
        font-size: 1.2rem;
    }

    .current-weather-details ul {
        display: flex; /* Use flex column instead of grid to prevent wrapping issues */
        flex-direction: column;
        gap: 0; /* Remove gap as padding handles spacing */
        text-align: center; /* Center text for better mobile look */
        background: #f9f9f9;
        padding: 10px 0; /* Remove horizontal padding from container, let items handle it */
        border-radius: 12px;
        margin-top: 15px;
        width: 100%; /* Full width */
        box-sizing: border-box;
        box-shadow: 0 2px 8px rgba(0,0,0,0.03);
        overflow: hidden; /* Ensure rounded corners clip content */
    }
    
    .current-weather-details ul li {
        padding: 12px 20px 12px 15px; /* Adjusted padding: Right 20px, Left 15px to balance visual perception */
        border-bottom: 1px solid #eee; /* Add separators for readability */
        box-sizing: border-box;
    }

    .current-weather-details ul li:last-child {
        border-bottom: none;
    }

    /* Daily Forecast mobile styles are now covered by general styles above */
}

/* --- Specific Mobile Portrait Styles for Forecast --- */
@media (max-width: 480px) {
    .hourly-forecast-table, .daily-forecast-table {
        gap: 8px; /* Reduce gap to fit more items */
    }

    /* Resize forecast items to show ~4.5 items on standard mobile portrait (360px-390px) */
    .hourly-forecast-table .forecast-item, .daily-forecast-table .forecast-item {
        flex: 0 0 72px;
        min-width: 72px;
    }

    .forecast-item {
        padding: 10px 5px; /* Reduce padding but keep some vertical space */
        min-height: 125px; /* Slightly smaller min-height for mobile */
    }

    .forecast-item .date-display {
        font-size: 0.7rem;
        margin-bottom: 5px;
        white-space: normal; /* Allow wrapping on very small screens */
    }

    .weather-icon-small {
        width: 36px;
        height: 36px;
    }

    .forecast-item .time, .forecast-item .day {
        font-size: 0.75rem;
    }

    .forecast-item .temp, .forecast-item .temp-range {
        font-size: 0.9rem;
    }

    .forecast-item .pop {
        font-size: 0.7rem;
    }

    /* Adjust headings and other text to match the scaled-down items */
    h2, h3 {
        font-size: 1.1rem;
        margin-top: 15px;
    }

    .info-box {
        padding: 10px;
        margin-top: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .info-box p {
        font-size: 0.8rem;
    }

    .air-pollution-details .aqi {
        font-size: 0.95rem;
    }

    .air-pollution-details ul {
        font-size: 0.85rem;
        gap: 5px;
    }
}

/* --- PWA Install Banner --- */
#pwa-install-banner {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 1rem 2rem;
    box-sizing: border-box;
    z-index: 2000; /* Above everything */
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    border-top: 4px solid #1c5a9b;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#pwa-install-banner.show {
    display: flex;
}

.pwa-content {
    flex: 1;
    min-width: 200px;
}

.pwa-text {
    margin: 0;
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.pwa-buttons {
    display: flex;
    gap: 1rem;
}

.pwa-btn-install {
    background-color: #1c5a9b;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.pwa-btn-install:hover {
    background-color: #144272;
}

.pwa-btn-dismiss {
    background-color: transparent;
    color: #666;
    border: 1px solid #ddd;
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-btn-dismiss:hover {
    background-color: #f0f2f5;
    color: #333;
}

@media (max-width: 600px) {
    #pwa-install-banner {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .pwa-buttons {
        width: 100%;
        justify-content: center;
    }
}