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

:root {
    --bg-primary: #10162b;
    --bg-card: #1b2340;
    --bg-card-hover: #232c50;
    --accent-blue: #5aa9ff;
    --text-light: #ffffff;
    --text-secondary: #8b93b0;
    --border-color: rgba(255, 255, 255, 0.08);
    --danger-red: #ef4444;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-light);
}

/* Phone-style frame wrapper (mobile default) */
.phone-frame {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Container */
.container {
    padding: 20px 18px 12px;
    min-height: 100vh;
}

/* Header */
.header {
    margin-bottom: 16px;
}

.header-content {
    animation: slideDown 0.6s ease-out;
}

.title {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-light);
}

/* Search Container */
.search-container {
    position: relative;
    margin-bottom: 20px;
    animation: slideUp 0.6s ease-out 0.1s both;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 38px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-light);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(90, 169, 255, 0.15);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.95rem;
    pointer-events: none;
}

/* Comune Search (pagina di dettaglio) */
.comune-search-container {
    margin-bottom: 16px;
}

.comune-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 20;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.comune-result-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

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

.comune-result-item:hover,
.comune-result-item:focus {
    background: var(--bg-card-hover);
}

.comune-result-name {
    font-size: 0.9rem;
    color: var(--text-light);
}

.comune-result-region {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.comune-search-message {
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* List Title Row */
.list-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    animation: slideUp 0.6s ease-out 0.2s both;
}

.list-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-light);
}

.list-sort {
    font-size: 0.85rem;
    color: var(--accent-blue);
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    animation: fadeIn 0.3s ease-out;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(90, 169, 255, 0.2);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

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

/* Province List (single-column rows, like the mockup) */
.province-list {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.5s ease-out;
}

.province-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 4px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
}

.province-card:hover,
.province-card:focus-visible {
    background: var(--bg-card-hover);
}

.province-card:last-child {
    border-bottom: none;
}

.province-header {
    display: flex;
    flex-direction: column;
}

.province-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

.province-region {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.province-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.weather-info {
    display: none;
}

.province-temp {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

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

.weather-icon {
    font-size: 1.3rem;
    margin-top: 2px;
}

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-red);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: var(--danger-red);
    animation: slideUp 0.3s ease-out;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    animation: fadeIn 0.3s ease-out;
}


/* ===================== Detail Page ===================== */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.detail-title {
    text-align: center;
    display: flex;
    flex-direction: column;
}

.detail-city-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-light);
}

.detail-city-region {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.current-weather-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.current-temp {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-light);
}

.current-weather-right {
    text-align: right;
}

.current-icon {
    font-size: 2.6rem;
}

.current-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.current-minmax {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    margin-top: 22px;
}

.hourly-forecast {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 14px;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 44px;
}

.hourly-time,
.hourly-temp {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.hourly-icon {
    font-size: 1.3rem;
}

.daily-forecast {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 14px;
    overflow-x: auto;
}

.daily-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 52px;
}

.daily-day {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.daily-icon {
    font-size: 1.3rem;
}

.daily-minmax {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
}

.details-list {
    display: flex;
    flex-direction: column;
}

.details-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.details-row:last-child {
    border-bottom: none;
}

.details-label {
    color: var(--text-secondary);
}

.details-value {
    color: var(--text-light);
    font-weight: 500;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 16px 14px 10px;
    }

    .title {
        font-size: 1.6rem;
    }

    .current-temp {
        font-size: 2.4rem;
    }
}

/* ===================== Desktop / Tablet Responsive ===================== */
@media (min-width: 900px) {
    .page-list .phone-frame {
        max-width: 1200px;
    }

    .page-list .container {
        padding: 40px 48px;
    }

    .page-list .header,
    .page-list .search-container,
    .page-list .list-title-row {
        max-width: 640px;
    }

    .title {
        font-size: 2.4rem;
    }

    /* Griglia su desktop invece della lista verticale */
    .province-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 12px 20px;
    }

    .province-card {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        border: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 16px 18px;
        background: var(--bg-card);
    }

    .province-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    }

    .province-card:last-child {
        border-bottom: 1px solid var(--border-color);
    }

    .province-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }

    .province-body {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .weather-icon {
        margin-top: 0;
    }

    /* Pagina di dettaglio: card centrata e più larga per ospitare la fascia oraria estesa */
    .page-detail .phone-frame {
        max-width: 960px;
    }

    .page-detail .container {
        padding: 40px 48px;
    }

    .current-weather-card {
        padding: 28px 32px;
    }

    .current-temp {
        font-size: 3.6rem;
    }

    /* Su desktop la previsione oraria mostra più ore: va a capo su più righe invece di scorrere */
    .hourly-forecast {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 20px 16px;
        overflow-x: visible;
    }

    .hourly-item {
        min-width: 56px;
    }

    .daily-forecast {
        justify-content: space-between;
    }

    .details-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        column-gap: 32px;
    }
}

@media (min-width: 1400px) {
    .page-list .phone-frame {
        max-width: 1400px;
    }

    .page-detail .phone-frame {
        max-width: 1100px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}
