/* ==========================================================
   ZonaFinder — CSS v2
   Pure CSS3, no external dependencies
   ========================================================== */

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --accent:        #0ea5e9;

    --bg:       #f1f5f9;
    --surface:  #ffffff;
    --border:   #e2e8f0;

    --text:       #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --danger:  #ef4444;
    --success: #22c55e;

    --header-h: 56px;
    --nav-h:    64px;
    --radius:   12px;
    --radius-s: 8px;
    --shadow:   0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
    --shadow-m: 0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);

    --t: .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

button { cursor: pointer; border: none; background: none; font-family: inherit; }
input  { font-family: inherit; }
svg    { display: block; }

/* ─── App Shell ───────────────────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 640px;
    margin: 0 auto;
    background: var(--surface);
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,.12);
}

/* ─── Header ─────────────────────────────────────────────── */
.app-header {
    flex-shrink: 0;
    height: var(--header-h);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
    z-index: 10;
}

.header-inner { display: flex; align-items: center; gap: 10px; }

.header-logo { width: 28px; height: 28px; color: rgba(255,255,255,.9); flex-shrink: 0; }

.app-title   { font-size: 1.125rem; font-weight: 700; letter-spacing: -.3px; line-height: 1.2; }
.app-subtitle{ font-size: .7rem; color: rgba(255,255,255,.7); line-height: 1; }

/* ─── Views ──────────────────────────────────────────────── */
.view {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}
.view[hidden] { display: none !important; }

/* ─── Search View ────────────────────────────────────────── */
.search-wrapper {
    flex-shrink: 0;
    background: var(--surface);
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 50px;
    padding: 0 6px 0 12px;
    gap: 6px;
    transition: border-color var(--t), box-shadow var(--t);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }

#search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 4px;
    font-size: .95rem;
    color: var(--text);
    outline: none;
    min-width: 0;
}
#search-input::placeholder       { color: var(--text-light); }
#search-input::-webkit-search-cancel-button { display: none; }

.clear-btn, .mic-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background var(--t), color var(--t);
    color: var(--text-muted);
}
.clear-btn svg, .mic-btn svg { width: 18px; height: 18px; }

.clear-btn:hover { background: var(--bg); color: var(--text); }
.mic-btn { color: var(--primary); }
.mic-btn:hover { background: var(--primary-light); }

.mic-btn.recording {
    background: var(--danger);
    color: #fff;
    animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0   rgba(239,68,68,.4); }
    50%       { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* City chips */
.city-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    max-height: 88px;       /* ~2 rows */
    overflow-y: auto;
    padding-bottom: 2px;
}

.city-chip {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: .78rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
    transition: all var(--t);
    white-space: nowrap;
    flex-shrink: 0;
}
.city-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.city-chip:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* "Tutte" chip — slightly distinct */
.city-chip--all {
    font-weight: 600;
    border-style: solid;
    border-width: 1.5px;
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.city-chip--all.active {
    background: var(--primary);
    color: #fff;
}

/* Results */
.results-container { flex: 1; padding: 8px 12px 12px; }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; padding: 60px 24px;
    color: var(--text-light); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; }
.empty-state p   { font-size: .95rem; line-height: 1.6; }

.results-meta {
    font-size: .8rem;
    color: var(--text-muted);
    padding: 6px 4px 4px;
    font-weight: 500;
}

.results-list { display: flex; flex-direction: column; gap: 6px; }

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    transition: transform var(--t), box-shadow var(--t);
}
.result-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-m); }

.result-street {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.result-street mark {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 2px;
    padding: 0 1px;
}

.result-civico {
    font-size: .75rem;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.result-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.result-city {
    font-size: .78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.result-city::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.result-zone {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 50px;
    color: #fff;
    white-space: nowrap;
}

.no-results {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.6;
}

.load-more-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-s);
    color: var(--primary);
    font-size: .875rem;
    font-weight: 500;
    text-align: center;
    transition: all var(--t);
    background: transparent;
}
.load-more-btn:hover { background: var(--primary-light); border-color: var(--primary); }

/* ─── Settings View ──────────────────────────────────────── */
.settings-content { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.settings-section-title {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.settings-section-title svg { width: 16px; height: 16px; color: var(--primary); }

.settings-desc { font-size: .875rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }

.cities-list { display: flex; flex-direction: column; gap: 2px; }

.city-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-s);
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text);
    transition: background var(--t);
    user-select: none;
}
.city-toggle:hover { background: var(--bg); }
.city-toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

.city-count { font-size: .75rem; color: var(--text-light); font-weight: 400; margin-left: 4px; }

.mic-status { font-size: .875rem; color: var(--text-muted); padding: 4px 0; }
.mic-status.ok    { color: var(--success); }
.mic-status.error { color: var(--danger); }

/* Settings city controls */
.city-toggle--option {
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    padding-bottom: 12px;
    font-weight: 400;
    color: var(--text);
}

.settings-btn-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.settings-action-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius-s);
    font-size: .8rem;
    font-weight: 600;
    border: 1.5px solid var(--primary);
    background: var(--primary);
    color: #fff;
    transition: all var(--t);
    cursor: pointer;
}
.settings-action-btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.settings-action-btn--secondary {
    background: transparent;
    color: var(--primary);
}
.settings-action-btn--secondary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* ─── About View ─────────────────────────────────────────── */
.about-content { padding: 24px 16px; display: flex; flex-direction: column; gap: 20px; align-items: center; }

.about-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }

.about-logo-icon {
    width: 64px; height: 64px;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 50%;
    padding: 14px;
}

.about-hero h2    { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.about-version {
    font-size: .8rem; color: var(--text-muted);
    background: var(--bg); padding: 3px 10px;
    border-radius: 50px; border: 1px solid var(--border);
}

.info-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    font-size: .875rem;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row span   { color: var(--text-muted); white-space: nowrap; }
.info-row strong { color: var(--text); font-weight: 600; text-align: right; }

.info-row--cities strong { font-size: .78rem; line-height: 1.6; }

.info-loading { font-size: .875rem; color: var(--text-muted); text-align: center; padding: 8px; }

.about-desc-box {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.about-desc-box p { font-size: .875rem; color: var(--text-muted); line-height: 1.6; }

/* ─── Bottom Navigation ──────────────────────────────────── */
.bottom-nav {
    flex-shrink: 0;
    height: var(--nav-h);
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    z-index: 10;
}

.nav-btn {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: var(--text-muted);
    font-size: .65rem;
    font-weight: 500;
    letter-spacing: .2px;
    transition: color var(--t);
    position: relative;
}
.nav-btn .nav-icon { width: 22px; height: 22px; transition: transform var(--t); }

.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-icon { transform: scale(1.1); }
.nav-btn.active::after {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}
.nav-btn:hover:not(.active) { color: var(--primary); }

/* ─── Desktop ────────────────────────────────────────────── */
@media (min-width: 480px) {
    .app-header      { height: 60px; padding: 0 20px; }
    .app-title       { font-size: 1.25rem; }
    .search-wrapper  { padding: 16px 20px 10px; }
    .results-container { padding: 12px 20px 20px; }
    .result-card     { padding: 14px 16px; }
    .settings-content { padding: 20px; }
    .about-content   { padding: 32px 20px; }
    .city-chips      { max-height: none; }
}

/* Scrollbar */
.view::-webkit-scrollbar       { width: 4px; }
.view::-webkit-scrollbar-track { background: transparent; }
.view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
