/* ============================================================
   FILE: /public/css/chat.css
   Stile della chat di famiglia.
   Scritte grandi e chiare, pensate anche per chi non è pratico.
   ============================================================ */

.chat-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: url('/GENS-images/dashboard-pc.jpg') no-repeat center center fixed;
    background-size: cover;
    font-family: 'Inter', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: stretch;
}

@media (max-width: 767px) {
    .chat-body {
        background: url('/GENS-images/dashboard-mobile.jpg') no-repeat center center fixed;
        background-size: cover;
    }
}

/* Pulsante "Torna alla Dashboard" in alto a sinistra */
.chat-toolbar {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1000;
}

/* La finestra della chat */
.chat-box {
    width: 100%;
    max-width: 720px;
    height: calc(100vh - 100px);
    height: calc(100dvh - 100px);
    margin: 70px 16px 30px;
    display: flex;
    flex-direction: column;
    background: rgba(20, 16, 29, 0.78);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    overflow: hidden;
}

@media (max-width: 767px) {
    .chat-box {
        margin: 64px 8px 8px;
        height: calc(100vh - 72px);
        height: calc(100dvh - 72px);
    }
}

.chat-header {
    padding: 14px 70px;   /* spazio ai lati: sul telefono a destra c'è il pulsante della lingua */
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-title {
    margin: 0;
    color: #fff;
    font-family: 'Caveat', cursive;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
}

/* Elenco dei messaggi */
.chat-messaggi {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-vuota {
    margin: auto;
    color: var(--lilla);
    font-size: 1.15rem;
    text-align: center;
}

/* Riga con la data (compare quando cambia il giorno) */
.chat-giorno {
    align-self: center;
    margin: 8px 0 2px;
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--lilla);
    font-size: 0.85rem;
}

/* Un messaggio */
.chat-msg {
    max-width: 82%;
    padding: 9px 14px 7px;
    border-radius: 16px;
    font-size: 1.1rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Messaggi degli altri: a sinistra */
.chat-msg.altri {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.92);
    color: #1d1a26;
    border-bottom-left-radius: 4px;
}

/* I miei messaggi: a destra, color oro tenue */
.chat-msg.miei {
    align-self: flex-end;
    background: var(--oro-miele);
    color: var(--marrone-notte);
    border-bottom-right-radius: 4px;
}

.chat-msg-autore {
    display: block;
    margin-bottom: 2px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--viola);
}

.chat-msg-testo {
    white-space: pre-wrap;   /* mantiene gli "a capo" scritti da chi invia */
}

.chat-msg-piede {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 3px;
    font-size: 0.78rem;
    opacity: 0.75;
}

.chat-msg-elimina {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.78rem;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* Casella per scrivere */
.chat-scrivi {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
}

.chat-testo {
    flex: 1;
    min-height: 48px;
    max-height: 140px;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1.1rem;
    resize: none;
    box-sizing: border-box;
}

.chat-invia {
    padding: 0 22px;
    border: none;
    border-radius: 12px;
    background: var(--oro-miele);
    color: var(--marrone-notte);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-invia:hover {
    background: #f7e3a6;
}

.chat-invia:disabled {
    opacity: 0.5;
    cursor: default;
}

.hidden {
    display: none !important;
}

/* ============================================================
   NUOVO (aggiornamento 39): elenco "Con chi vuoi parlare?" e chat private
   ============================================================ */

/* Le due viste (elenco / conversazione) riempiono la finestra */
.chat-vista {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* L'elenco delle persone */
.chat-elenco {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Un tasto grande per ogni persona (comodo anche col dito) */
.chat-persona {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 68px;
    padding: 10px 16px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    color: #1d1a26;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

.chat-persona:hover,
.chat-persona:focus-visible {
    background: #fff;
    outline: 3px solid var(--oro-miele);
}

.chat-persona-famiglia {
    background: var(--oro-miele);
    color: var(--marrone-notte);
}

.chat-persona-famiglia:hover,
.chat-persona-famiglia:focus-visible {
    background: #f7e3a6;
}

.chat-persona-cerchio {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--viola);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
}

.chat-persona-famiglia .chat-persona-cerchio {
    background: rgba(255, 255, 255, 0.55);
    font-size: 1.5rem;
}

.chat-persona-testi {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-persona-nome {
    font-size: 1.3rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.chat-persona-sotto {
    font-size: 0.95rem;
    opacity: 0.75;
}

/* Frasi di spiegazione nell'elenco ("Un momento...", "Sei l'unica persona...") */
.chat-nota {
    margin: 8px 4px;
    color: var(--lilla);
    font-size: 1.1rem;
    text-align: center;
}

/* Intestazione della conversazione: tasto "Torna all'elenco" + titolo + nota */
.chat-header-conv {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px 10px;
}

.chat-indietro {
    align-self: flex-start;
    min-height: 44px;
    padding: 6px 16px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: inherit;
    font-size: 1.05rem;
    cursor: pointer;
}

.chat-indietro:hover,
.chat-indietro:focus-visible {
    background: rgba(255, 255, 255, 0.25);
}

.chat-header-conv .chat-title {
    font-size: 1.9rem;
    overflow-wrap: anywhere;
}

.chat-nota-conv {
    margin: 0;
    color: var(--lilla);
    font-size: 0.95rem;
    text-align: center;
}

/* ============================================================
   NUOVO (aggiornamento 41): ingranaggio e impostazioni della chat
   ============================================================ */
.chat-header { position: relative; }

.chat-ingranaggio {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.chat-ingranaggio:hover,
.chat-ingranaggio:focus-visible {
    background: rgba(255, 255, 255, 0.3);
}

/* Finestra delle impostazioni: sopra a tutto, sfondo scurito */
.chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.6);
}

.chat-pannello {
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px 18px 18px;
    border-radius: 18px;
    background: #fff;
    color: #222;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.chat-pannello-titolo {
    margin: 0 0 14px 0;
    font-size: 1.5rem;
    text-align: center;
}

/* Una scelta = una riga grande, comoda da toccare */
.chat-opzione {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 8px 4px;
    cursor: pointer;
}

.chat-opzione input[type="checkbox"] {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    accent-color: var(--viola);
    cursor: pointer;
}

.chat-opzione-testo {
    font-size: 1.2rem;
    line-height: 1.25;
}

.chat-prova {
    margin: 0 0 10px 44px;
    min-height: 44px;
    padding: 6px 16px;
    border: 1px solid #c9bfe6;
    border-radius: 999px;
    background: #f3effb;
    color: #3d2d73;
    font-family: inherit;
    font-size: 1.05rem;
    cursor: pointer;
}

.chat-pannello-nota {
    margin: 10px 4px 14px;
    color: #666;
    font-size: 0.95rem;
    text-align: center;
}

.chat-chiudi {
    display: block;
    width: 100%;
    min-height: 52px;
    border: none;
    border-radius: 14px;
    background: var(--viola);
    color: #fff;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
}


/* NUOVO (aggiornamento 41): spunte stile WhatsApp e testo di aiuto nel pannello */
.chat-spunte {
    margin-left: 6px;
    font-size: 0.95rem;
    letter-spacing: -2px;
    color: #7a6a3a;
}
.chat-spunte.letto {
    color: #1a73e8;
    font-weight: 700;
}
.chat-opzione-aiuto {
    margin: -2px 4px 8px 48px;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.25;
}


/* ============================================================
   Pulsante "Svuota la conversazione" (i messaggi spariscono solo per te)
   ============================================================ */
.chat-svuota {
    min-height: 40px;
    margin-top: 4px;
    padding: 6px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    background: transparent;
    color: var(--lilla);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.chat-svuota:hover,
.chat-svuota:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.chat-svuota.hidden { display: none; }


/* ============================================================
   NUOVO (aggiornamento 48): foto dell'album dentro la chat
   ============================================================ */

/* Pulsante "📷 Foto" accanto alla casella */
.chat-foto-btn {
    flex: 0 0 auto;
    padding: 0 14px;
    border: none;
    border-radius: 12px;
    background: #fff;
    color: var(--marrone-notte);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
}
.chat-foto-btn:hover { background: #f3effb; }

/* La foto scelta, piccola, sopra la casella */
.chat-foto-anteprima {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
}
.chat-foto-anteprima.hidden { display: none; }
.chat-foto-anteprima img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
}
.chat-foto-anteprima-titolo {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
}
.chat-foto-togli {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
}
.chat-foto-togli:hover { background: rgba(255, 255, 255, 0.35); }

/* La foto dentro un messaggio */
.chat-msg-foto-box { margin-bottom: 4px; }
.chat-msg-foto {
    display: block;
    width: 100%;
    max-width: 280px;
    max-height: 320px;
    min-height: 90px;
    object-fit: cover;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.12);
    cursor: zoom-in;
}
.chat-msg-foto-titolo {
    margin-top: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0.85;
}
.chat-msg-foto-persa {
    margin: 0 0 4px;
    padding: 14px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.1);
    font-size: 0.95rem;
    font-style: italic;
}

/* Finestra per scegliere la foto */
.chat-foto-pannello { max-width: 560px; }
.chat-foto-griglia {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.chat-foto-voce {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    background: #f3effb;
    color: #222;
    font-family: inherit;
    font-size: 0.8rem;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
}
.chat-foto-voce:hover,
.chat-foto-voce:focus-visible { border-color: var(--viola); }
.chat-foto-voce img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.08);
}
.chat-foto-voce span {
    padding: 0 4px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#chat-foto-altre { display: block; margin: 0 auto 12px; }
#chat-foto-altre.hidden { display: none; }

/* Foto ingrandita */
.chat-foto-grande {
    flex-direction: column;
    gap: 14px;
    background: rgba(0, 0, 0, 0.88);
}
.chat-foto-grande img {
    max-width: 100%;
    max-height: calc(100dvh - 110px);
    object-fit: contain;
    border-radius: 8px;
}
.chat-foto-grande .chat-chiudi { max-width: 320px; }

@media (max-width: 767px) {
    .chat-foto-btn { padding: 0 10px; font-size: 1rem; }
    .chat-foto-griglia { grid-template-columns: repeat(2, 1fr); }
}


/* NUOVO (aggiornamento 49): scelta "dal telefono" o "dall'album" */
.chat-foto-grande-btn {
    display: block;
    width: 100%;
    min-height: 60px;
    margin: 0 0 14px;
    padding: 10px 14px;
    border: none;
    border-radius: 14px;
    background: var(--viola);
    color: #fff;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
}
.chat-foto-grande-btn:hover { background: #5a3fa3; }
.chat-foto-oppure {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    color: #3d2d73;
}

/* ============================================================
   Riquadro "Vuoi un avviso sul telefono?" (push.js)
   ============================================================ */
.chat-avvisi {
    margin: 10px 4px 14px;
    padding: 12px 14px;
    border: 1px solid rgba(217, 210, 233, 0.45);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.07);
    text-align: center;
}
.chat-avvisi-testo {
    margin: 0 0 10px;
    color: var(--lilla);
    font-size: 1.05rem;
    line-height: 1.4;
}
.chat-avvisi .chat-prova {
    margin: 0 auto;
    min-height: 48px;
    font-size: 1.05rem;
}
.chat-avvisi .chat-prova.hidden,
.chat-avvisi .chat-avvisi-testo.hidden { display: none; }


/* ---- Persone dell'albero non ancora iscritte (elenco della chat) ---- */
.chat-titolo-invito {
    margin: 18px 4px 6px;
    font-weight: 700;
    text-align: left;
    color: var(--lilla);
}
.chat-persona-invito {
    border-style: dashed;
    opacity: 0.92;
}
.chat-persona-invito .chat-persona-cerchio {
    background: transparent;
    border: 2px dashed rgba(224, 192, 128, 0.8);
    color: var(--oro-chiaro);
}
.chat-persona-invito-spento {
    opacity: 0.6;
    cursor: default;
}


/* ---- Aggiornamento 55: il pulsante della lingua non copre piu' l'ingranaggio ---- */
/* 1) La finestra della chat parte piu' in basso (sotto il pulsante della lingua) */
@media (max-width: 767px) {
    .chat-box {
        margin: 90px 8px 8px;
        height: calc(100vh - 98px);
        height: calc(100dvh - 98px);
    }
}
/* 2) Nell'elenco "Con chi vuoi parlare?" l'ingranaggio sta a sinistra */
#chat-vista-elenco .chat-ingranaggio {
    right: auto;
    left: 10px;
}


/* ---- Aggiornamento 73: nella conversazione l'ingranaggio non sta piu' sotto il pulsante della lingua ---- */
/* (con la tastiera aperta la pagina scorre e il pulsante della lingua finiva sopra l'ingranaggio) */
.chat-header-conv .chat-ingranaggio {
    right: auto;
    left: 12px;
    top: 10px;
}
.chat-header-conv .chat-indietro {
    margin-left: 54px;          /* lascia posto all'ingranaggio, che ora sta alla sua sinistra */
    padding: 6px 14px;
    font-size: 1rem;
}
@media (max-width: 340px) {
    .chat-header-conv .chat-indietro { font-size: 0.85rem; padding: 6px 8px; }
}


/* NUOVO (aggiornamento 99): la scritta "Scrivi un messaggio" non esce piu' dalla casella, in nessuna lingua */
.chat-testo { min-width: 0; line-height: 1.3; }
.chat-testo::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1rem;
}
@media (max-width: 767px) {
    .chat-testo { font-size: 1rem; padding: 12px 10px; }
    .chat-testo::placeholder { font-size: 0.95rem; }
}
