/* UGO per ANCI · stile comune. Mobile-first, font ospitati in locale (rete di fiera lenta). */

/* Font del brand Made in Italy: Montserrat per i testi, BD Gitalona (font del logo) per i titoli */
@font-face {
    font-family: "Montserrat";
    src: url("../fonts/Montserrat-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Montserrat";
    src: url("../fonts/Montserrat-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Montserrat";
    src: url("../fonts/Montserrat-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "BD Gitalona Moxa";
    src: url("../fonts/BDGitalonaMoxa-Regular.otf") format("opentype");
    font-weight: 400;
    font-display: swap;
}

:root {
    /* Colori del brand: verde petrolio primario, arancio per gli accenti (non per i testi: contrasto basso) */
    --primary: #33787F;
    --primary-dark: #265B60;
    --accent: #DE8E3E;
    --text: #585B58;
    --text-strong: #3E413E;
    --text-muted: #6B6E6B;
    --bg: #F7EFE6;
    --font-text: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --font-display: "BD Gitalona Moxa", Georgia, serif;
    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.9);
    --shadow: 0 10px 30px rgba(51, 70, 72, 0.12);
    --radius: 16px;
    --focus: 0 0 0 3px rgba(51, 120, 127, 0.35);
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Campi e pulsanti non ereditano il font: lo forziamo */
input, button {
    font-family: inherit;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-text);
    font-size: 18px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 0%, rgba(51, 120, 127, 0.16), transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(222, 142, 62, 0.14), transparent 50%),
        var(--bg);
    -webkit-text-size-adjust: 100%;
}

.page {
    max-width: 560px;
    margin: 0 auto;
    padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}

/* Card glassmorphism */
.card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 20px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Titoli nel font del logo */
h1, h2 {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--text-strong);
}

h1 {
    margin: 0 0 12px;
    font-size: 2rem;
    line-height: 1.15;
}

/* Logo Made in Italy */
.brand-logo {
    display: block;
    width: min(100%, 300px);
    height: auto;
    margin: 0 auto 24px;
}

p {
    margin: 0 0 12px;
}

.muted {
    color: var(--text-muted);
}

/* UGO a figura intera (welcome page e pagine di servizio) */
.ugo-figure {
    display: block;
    width: auto;
    height: 220px;
    margin: 0 auto 16px;
}

/* Form del Comune */
.comune-form {
    margin-top: 20px;
}

.comune-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.combobox {
    position: relative;
}

.combobox input {
    width: 100%;
    /* almeno 16px: sotto questa soglia iOS fa lo zoom sul campo */
    font-size: 1.125rem;
    padding: 14px 16px;
    border: 2px solid #D3D6D3;
    border-radius: 12px;
    background: #FFFFFF;
    color: var(--text);
}

.combobox input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus);
}

.combobox ul {
    position: absolute;
    z-index: 10;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 60vh;
    overflow-y: auto;
}

.combobox li {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
}

.combobox li[aria-selected="true"],
.combobox li:hover {
    background: rgba(51, 120, 127, 0.08);
}

.combobox li small {
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.status {
    min-height: 1.5em;
    margin: 8px 0;
    font-size: 0.9375rem;
    color: var(--text-muted);
}

/* Azione principale */
.btn-primary {
    display: block;
    width: 100%;
    padding: 16px;
    font-size: 1.125rem;
    font-weight: 700;
    color: #FFFFFF;
    background: var(--primary);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.btn-primary:disabled {
    background: #C4C6C3;
    cursor: not-allowed;
}

.btn-secondary {
    display: block;
    width: 100%;
    padding: 14px 16px;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--primary);
    background: #FFFFFF;
    border: 2px solid var(--primary);
    border-radius: 12px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(51, 120, 127, 0.06);
}

.btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.btn-secondary:disabled,
.btn-primary:disabled {
    color: #FFFFFF;
    background: #C4C6C3;
    border-color: #C4C6C3;
    cursor: not-allowed;
}

/* ---------- Chat ---------- */

.chat-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 2px solid rgba(222, 142, 62, 0.45);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.chat-header__text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.chat-header__text span {
    font-size: 0.9375rem;
    color: var(--text-muted);
}

/* Icona Made in Italy a destra nell'intestazione */
.chat-header__brand {
    height: 40px;
    width: auto;
    margin-left: auto;
}

/* Primo piano di UGO nel cerchio dell'intestazione */
.ugo-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 3px rgba(51, 120, 127, 0.18);
}

.chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
}

.chat > * {
    /* lascia spazio sotto l'intestazione fissa quando si scorre a un elemento */
    scroll-margin-top: 80px;
    scroll-margin-bottom: 24px;
}

.msg {
    max-width: 92%;
    padding: 14px 16px;
    border-radius: var(--radius);
    animation: msg-in 0.25s ease-out;
}

.msg--ugo {
    align-self: flex-start;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.msg--user {
    align-self: flex-end;
    color: #FFFFFF;
    background: var(--primary);
    border-top-right-radius: 4px;
    font-weight: 600;
}

/* Puntini "UGO sta scrivendo" */
.msg--typing {
    padding: 18px 20px;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
    animation: typing-dot 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* Balloon di attesa: sotto i puntini, la frase di avanzamento */
.msg-status {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-style: italic;
}

.msg-status:empty {
    display: none;
}

@keyframes typing-dot {
    40% { opacity: 1; transform: translateY(-3px); }
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
    .msg, .typing-dots span { animation: none; }
}

.chat-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

/* ---------- Card prezzi ---------- */

.price-card h2 {
    margin: 0 0 12px;
    font-size: 1.375rem;
}

.price-list {
    margin: 0;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.price-row:last-child {
    border-bottom: 0;
}

.price-row dt {
    flex: 1;
}

.price-row dd {
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.price-row--subtotal {
    border-top: 2px solid rgba(0, 0, 0, 0.12);
}

.price-row--total {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}

.price-row--total dd {
    font-weight: 800;
}

.price-note {
    margin: 12px 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Balloon di attesa: UGO che consulta la cartina accanto ai puntini e alle frasi */
.msg--waiting {
    display: flex;
    align-items: center;
    gap: 14px;
}

.msg-waiting__ugo {
    flex-shrink: 0;
    width: auto;
    height: 120px;
}

.msg-waiting__text {
    flex: 1;
}

/* ---------- Stampa della chat ---------- */
/* Restano testi e card; spariscono intestazione fissa, pulsanti, moduli e animazioni */
@media print {
    body {
        background: #FFFFFF;
        font-size: 11pt;
    }

    .chat-header,
    .chat-actions,
    .msg--typing,
    .email-card,
    .brand-logo,
    .ugo-figure {
        display: none !important;
    }

    .page {
        max-width: none;
        padding: 0;
    }

    .msg,
    .card {
        max-width: 100%;
        background: #FFFFFF;
        border: 1px solid #DDDFDD;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        animation: none;
        break-inside: avoid;
    }

    .msg--user {
        color: var(--text-strong);
        background: #F1F4F4;
    }
}

/* ---------- Modulo email in chat ---------- */
.email-card h2 {
    margin: 0 0 12px;
    font-size: 1.375rem;
}

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-field input {
    width: 100%;
    /* almeno 16px: sotto questa soglia iOS fa lo zoom sul campo */
    font-size: 1.0625rem;
    padding: 12px 14px;
    border: 2px solid #D3D6D3;
    border-radius: 12px;
    background: #FFFFFF;
    color: var(--text-strong);
}

.form-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus);
}

.consent {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 6px 0 8px;
    font-size: 0.9375rem;
    line-height: 1.45;
    cursor: pointer;
}

.consent input {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    margin: 2px 0 0;
    accent-color: var(--primary);
}

.consent a {
    color: var(--primary);
    font-weight: 600;
}

.form-status {
    color: #A3402A;
}
