/* Aggiunte per chat, annuncio e modalità modifica. Usa le variabili del sito. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.nav-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); margin-left: 6px; vertical-align: middle; }
.nav-dot[hidden] { display: none; }
.announce { margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px))) calc(-1 * max(16px, env(safe-area-inset-right, 0px))); background: var(--yellow); color: var(--on-yellow); font-weight: 700; text-align: center; padding: 10px 16px; }
.closed-note { background: var(--yellow-soft); border-left: 6px solid var(--red); padding: 12px 14px; font-weight: 700; color: var(--ink); }
#sendBtn[disabled] { opacity: .6; cursor: not-allowed; }

/* chat */
.chat-layout { padding-top: 24px; max-width: 760px; display: grid; gap: 14px; }
.chat-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-tabs button { font: 700 .92rem var(--font-body); border: 2px solid var(--line); background: var(--paper); color: var(--ink); padding: 7px 14px; border-radius: 99px; cursor: pointer; }
.chat-tabs button[aria-selected="true"] { border-color: var(--red); background: var(--sel-bg); }
.chat-tabs .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-left: 6px; }
.chat { background: var(--paper); border: 1px solid var(--line); border-top: 8px solid var(--red); box-shadow: var(--shadow); display: flex; flex-direction: column; height: min(78vh, 720px); min-height: 440px; }
.chat[hidden], .chat-empty[hidden], .chat-tabs[hidden] { display: none; }
.chat-top { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--red); color: var(--yellow); display: grid; place-items: center; font: 400 1.2rem var(--font-display); }
.chat-who { min-width: 0; flex: 1; line-height: 1.25; }
.chat-who b { display: block; }
.chat-who small { color: var(--muted); }
.chat-link { font: 700 .85rem var(--font-body); background: none; border: 2px solid var(--line); color: var(--ink); padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.chat-link:hover { border-color: var(--muted); }
.chat-item { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--sel-bg); border-bottom: 1px solid var(--line); }
.chat-item .ci-ico { flex: none; width: 44px; height: 52px; background: var(--paper); border: 2px solid var(--ink); display: grid; place-items: center; font: 400 1rem var(--font-display); color: var(--red); }
.chat-item .ci-txt { min-width: 0; flex: 1; line-height: 1.3; }
.chat-item .ci-txt b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .ci-txt small { color: var(--muted); }
.pill { display: inline-block; font: 700 .78rem var(--font-body); padding: 3px 10px; border-radius: 99px; background: var(--yellow); color: var(--on-yellow); white-space: nowrap; }
.pill.st-completata { background: #1f7a3d; color: #fff; }
.pill.st-annullata { background: var(--muted); color: #fff; }
.pill.st-confermata, .pill.st-incorso { background: var(--red); color: #fff; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); overscroll-behavior: contain; }
.chat-msgs .day { align-self: center; font: 700 .75rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; }
.chat-msgs .sys { align-self: center; max-width: 88%; text-align: center; font-size: .9rem; color: var(--muted); background: var(--paper); border: 1px dashed var(--line); padding: 8px 12px; border-radius: 10px; margin: 8px 0; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.bub { padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; font-size: 1rem; }
.msg.me .bub { background: var(--red-deep); color: #fff; border-bottom-right-radius: 4px; }
.msg.them .bub { background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me .bub a { color: var(--yellow); }
.bub img { display: block; max-width: min(240px, 100%); max-height: 300px; border-radius: 10px; cursor: zoom-in; }
.msg time { font-size: .72rem; color: var(--muted); margin: 2px 6px 0; }
.chat-err { color: var(--link); font-weight: 700; font-size: .92rem; padding: 0 14px; margin: 0; }
.chat-err:empty { display: none; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--paper); }
.chat-form textarea { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--field-bg); border: 2px solid var(--line); border-radius: 20px; padding: 9px 14px; resize: none; max-height: 120px; line-height: 1.4; }
.chat-form textarea:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1px; }
.chat-attach, .chat-send { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 0; }
.chat-attach { background: transparent; color: var(--muted); border: 2px solid var(--line); }
.chat-attach:hover { color: var(--ink); border-color: var(--muted); }
.chat-send { background: var(--red-deep); color: #fff; }
.chat-send[disabled] { opacity: .5; }
.chat-empty { background: var(--paper); border: 1px solid var(--line); border-top: 8px solid var(--yellow); padding: 28px; display: grid; gap: 16px; justify-items: start; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; }
@media (max-width: 520px) { .chat { height: calc(100dvh - 190px); min-height: 420px; } .msg { max-width: 90%; } }

/* ----- modalità modifica (solo admin, ?edit=1) ----- */
body.ed-on { padding-bottom: 120px; }
.ed-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 200; background: #1c1c1e; color: #fff; font: 500 14px/1.3 var(--font-body); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; box-shadow: 0 -4px 18px rgba(0,0,0,.35); }
.ed-bar select, .ed-bar button { font: 700 13px var(--font-body); border-radius: 6px; border: 0; padding: 8px 12px; cursor: pointer; }
.ed-bar select { background: #3a3a3c; color: #fff; }
.ed-bar button { background: #3a3a3c; color: #fff; }
.ed-bar button:hover { background: #48484a; }
.ed-bar button.primary { background: var(--yellow); color: #2b0d11; }
.ed-bar button.danger { background: #8e0c18; }
.ed-bar button[disabled] { opacity: .4; cursor: default; }
.ed-bar .sp { flex: 1; }
.ed-bar .ed-msg { color: #ffd; min-width: 140px; }
.ed-bar .ed-ctx { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-right: 8px; border-right: 1px solid #555; }
.ed-bar .ed-ctx[hidden] { display: none; }
.ed-bar .ed-ctx span { color: #bbb; font-size: 12px; }
.ed-text { outline: 2px dashed rgba(245, 184, 0, .75); outline-offset: 2px; cursor: text; }
.ed-text:focus { outline: 2px solid #f5b800; background: rgba(245, 184, 0, .12); }
.ed-item { outline: 2px dotted rgba(120, 120, 255, .5); outline-offset: 4px; }
.ed-item.ed-sel { outline: 3px solid #4d7cff; outline-offset: 4px; }
.ed-img { cursor: pointer; }
img.ed-img.ed-sel { outline: 3px solid #4d7cff; outline-offset: -3px; }
.ed-add { margin: 14px 0; font: 700 14px var(--font-body); padding: 9px 14px; border: 2px dashed #4d7cff; background: transparent; color: #4d7cff; border-radius: 6px; cursor: pointer; }
.ed-login { position: fixed; inset: 0; z-index: 300; background: rgba(20,5,8,.78); display: grid; place-items: center; padding: 16px; }
.ed-login form { background: var(--paper); color: var(--ink); width: min(380px, 100%); padding: 24px; border-top: 8px solid var(--red); display: grid; gap: 12px; box-shadow: var(--shadow); }
.ed-login h2 { font-size: 1.4rem; }
.ed-login input { font: inherit; padding: 11px 12px; border: 2px solid var(--line); border-radius: 4px; background: var(--field-bg); color: var(--ink); width: 100%; }
.ed-login .err { min-height: 1.2em; }

/* ----- accesso clienti ----- */
.auth-modal { position: fixed; inset: 0; z-index: 150; background: rgba(20,5,8,.72); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.auth-modal[hidden] { display: none; }
.auth-box { position: relative; background: var(--paper); color: var(--ink); width: min(420px, 100%); padding: 26px 24px 22px; border-top: 10px solid var(--red); box-shadow: var(--shadow); display: grid; gap: 12px; }
.auth-box h2 { font-size: 1.6rem; padding-right: 36px; }
.auth-x { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border: 0; background: transparent; font-size: 1.8rem; line-height: 1; color: var(--muted); cursor: pointer; }
.auth-google { width: 100%; }
.auth-google .g { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); font: 700 .85rem var(--font-body); }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .88rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#authForm { display: grid; gap: 12px; }
.ok { color: #1f7a3d; font-weight: 700; font-size: .92rem; margin: 0; }
.ok:empty { display: none; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin: 0; }
.linkbtn { background: none; border: 0; padding: 4px 0; font: 700 .9rem var(--font-body); color: var(--link); text-decoration: underline; cursor: pointer; }
#navLogin { cursor: pointer; }
