/* Vintage ARPAV - Weather Forecast Styles */

:root {
    --primary-color: #1e3a5f;
    --secondary-color: #2c5282;
    --accent-color: #4a90d9;
    --bg-color: #f7f9fc;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --success-color: #38a169;
    --warning-color: #d69e2e;
    --danger-color: #e53e3e;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.city-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
}

.city-tabs::-webkit-scrollbar {
    height: 4px;
}

.city-tabs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: var(--transition);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
}

.manage-cities-btn {
    background: rgba(255, 255, 255, 0.25);
}

/* Main Content */
.app-content {
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Views */
.view {
    animation: fadeIn 0.3s ease;
}

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

.view h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.zone-name {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Forecast header with permalink */
.forecast-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.forecast-header h2 {
    margin-bottom: 0;
}

.permalink-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.permalink-icon:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.permalink-icon.copied {
    color: var(--success-color);
}

/* Permalink container (old) */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.permalink-container label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#permalink-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    background: var(--bg-color);
    color: var(--text-color);
}

#copy-permalink-btn {
    padding: 0.5rem 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

#copy-permalink-btn:hover {
    background: var(--secondary-color);
}

/* Search */
.search-container {
    margin-bottom: 1rem;
}

#city-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

#city-search:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Cities List */
.cities-list {
    display: grid;
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.city-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.city-item:hover {
    transform: translateX(4px);
}

.city-item .city-info {
    display: flex;
    flex-direction: column;
}

.city-item .city-name {
    font-weight: 600;
    color: var(--primary-color);
}

.city-item .province {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.city-item .favorite-check {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.city-item.favorite .favorite-check {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

/* Forecast Table */
.forecast-table-container {
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.forecast-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.forecast-table th,
.forecast-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.forecast-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.forecast-table tr:last-child td {
    border-bottom: none;
}

.forecast-table tr:hover {
    background: rgba(74, 144, 217, 0.05);
}

.forecast-date {
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.forecast-icon {
    width: 64px;
    height: 64px;
}

.forecast-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.forecast-weather {
    max-width: 150px;
}

.forecast-temp {
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.forecast-precip {
    font-size: 0.85rem;
}

.forecast-precip .probability {
    color: var(--accent-color);
    font-weight: 600;
}

.forecast-reliability {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.reliability-bassa { background: #fed7d7; color: #c53030; }
.reliability-discreta { background: #fefcbf; color: #b7791f; }
.reliability-buona { background: #c6f6d5; color: #276749; }

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state,
.error-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.error-state {
    color: var(--danger-color);
}

#retry-btn {
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

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

/* Responsive */
@media (max-width: 600px) {
    .app-content {
        padding: 0.5rem;
    }

    .view h2 {
        font-size: 1.25rem;
    }

    .tab-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .forecast-table th,
    .forecast-table td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .forecast-weather {
        max-width: 100px;
        font-size: 0.85rem;
    }
}
