/* TurniAI — stile fedele al design Turni.dc.html (Claude Design di Giuseppe) */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #F6F5F2; color: #1B1B18; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* --- accesso --- */
#auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid #ECEBE5; border-radius: 20px; padding: 30px 28px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand-icon { width: 30px; height: 30px; border-radius: 9px; background: #1F7A5C; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.auth-card h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; margin: 18px 0 8px; }
.auth-card .sub { font-size: 14.5px; line-height: 1.55; color: #6E6D66; margin: 0 0 18px; }
.tabs { display: flex; gap: 6px; background: #F2F1EC; border-radius: 11px; padding: 4px; margin-bottom: 14px; }
.tab { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font-size: 14px; font-weight: 600; color: #6E6D66; }
.tab.active { background: #fff; color: #1B1B18; box-shadow: 0 1px 4px rgba(30,28,20,.08); }
#form-auth input { width: 100%; margin-bottom: 10px; border: 1px solid #E4E3DD; border-radius: 11px; padding: 12px 14px; font-family: inherit; font-size: 15px; background: #FCFCFA; outline: none; }
#form-auth input:focus { border-color: #1F7A5C; }
#btn-auth { width: 100%; border: none; border-radius: 12px; background: #1F7A5C; color: #fff; font-size: 15px; font-weight: 700; padding: 13px; }
.err { color: #B3402E; font-size: 13.5px; margin: 10px 2px 0; }
.privacy { font-size: 11.5px; line-height: 1.55; color: #A6A59E; margin: 16px 2px 0; }

/* --- struttura app --- */
#app { height: 100vh; display: flex; flex-direction: column; }
.topbar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.hello { font-size: 13px; color: #8A887F; margin-right: 4px; }
.ghost { border: 1px solid #E4E3DD; background: #fff; color: #55544E; font-size: 13px; font-weight: 600; padding: 8px 13px; border-radius: 10px; }
#main { flex: 1; min-height: 0; display: flex; }

/* --- chat --- */
#chat-panel { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#main.has-board #chat-panel { flex: 0 0 420px; }
#msgs { flex: 1; overflow-y: auto; padding: 8px 22px 4px; }
.chat-col { width: 100%; max-width: 680px; margin: 0 auto; }
#main.has-board .chat-col { max-width: 100%; }
.msg { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; animation: msgIn .35s ease; }
.msg.user { justify-content: flex-end; }
.msg .avatar { width: 28px; height: 28px; border-radius: 8px; background: #E7F1EC; color: #1F7A5C; flex: none; display: flex; align-items: center; justify-content: center; font-size: 13px; margin-top: 1px; }
.msg .bubble { max-width: 90%; font-size: 15.5px; line-height: 1.62; white-space: pre-wrap; word-break: break-word; padding: 3px 0; color: #26261F; }
.msg.user .bubble { background: #1F7A5C; color: #fff; padding: 10px 15px; border-radius: 18px 18px 5px 18px; max-width: 80%; font-size: 15px; line-height: 1.55; }
.dots { display: inline-flex; gap: 5px; padding: 11px 2px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: #B6B5AE; animation: dotPulse 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }

#composer { flex: none; padding: 8px 22px 16px; }
#chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 auto 8px; max-width: 680px; }
#main.has-board #chips { max-width: 100%; }
.chip { border: 1px solid #E4E3DD; background: #fff; color: #1F7A5C; font-size: 13.5px; font-weight: 600; padding: 8px 13px; border-radius: 999px; }
.chip:hover { border-color: #1F7A5C; }
.inputrow { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 1px solid #E4E3DD; border-radius: 18px; padding: 7px 7px 7px 16px; box-shadow: 0 2px 10px rgba(30,28,20,.04); max-width: 680px; margin: 0 auto; }
#main.has-board .inputrow { max-width: 100%; }
#input { flex: 1; border: none; outline: none; resize: none; background: transparent; font-family: inherit; font-size: 15px; line-height: 1.5; max-height: 150px; padding: 8px 0; color: #1B1B18; }
#input::placeholder { color: #A9A8A2; }
#send { flex: none; width: 38px; height: 38px; border: none; border-radius: 13px; color: #fff; background: #1F7A5C; font-size: 17px; transition: background .2s; }
#send:disabled { background: #CFCEC7; cursor: default; }
.note { text-align: center; font-size: 11.5px; color: #A6A59E; margin: 9px auto 0; max-width: 680px; }

/* --- tabellone --- */
#board-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; border-left: 1px solid #E9E8E2; animation: boardIn .55s cubic-bezier(.4,0,.2,1); }
.board-head { flex: none; padding: 22px 26px 16px; border-bottom: 1px solid #F0EFE9; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #1F7A5C; margin-bottom: 5px; }
.board-head h2 { display: inline; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 0 10px 0 0; }
#board-meta { font-size: 13.5px; color: #8A887F; }
.board-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wa-btn { display: flex; align-items: center; gap: 8px; border: none; background: #25D366; color: #fff; font-size: 13.5px; font-weight: 700; padding: 10px 15px; border-radius: 11px; box-shadow: 0 2px 8px rgba(37,211,102,.28); white-space: nowrap; }
#board-scroll { flex: 1; overflow: auto; padding: 20px 26px 10px; }
#board-grid { min-width: min-content; }
.grid-row { display: grid; gap: 8px; margin-bottom: 8px; animation: rowIn .4s ease; }
.grid-head { font-size: 12px; font-weight: 700; color: #55544E; }
.grid-head > div { display: flex; align-items: center; justify-content: center; padding: 8px 6px; }
.grid-head .h-first { justify-content: flex-start; padding-left: 12px; color: #A6A59E; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.person { display: flex; align-items: center; gap: 9px; padding: 8px 10px 8px 12px; min-height: 54px; background: #FBFBF9; border-radius: 12px; }
.person .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.person .who { min-width: 0; flex: 1; }
.person .nm { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .rl { font-size: 12px; color: #9A988F; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .wa-mini { flex: none; width: 30px; height: 30px; border: none; border-radius: 9px; background: #E7F7EE; color: #1B9E54; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.cell { display: flex; align-items: center; justify-content: center; min-height: 54px; border-radius: 12px; font-weight: 600; font-size: 13px; text-align: center; padding: 4px; white-space: nowrap; }
.cell.rest { background: #FAFAF8; color: #C9C8C1; font-weight: 500; }
.cell.absent { background: #F8F2E3; color: #8A6A2A; }
.back-to-chat { display: none; text-align: center; padding: 6px 0 18px; margin: 0; }
.back-to-chat a { color: #1F7A5C; font-size: 13.5px; font-weight: 600; text-decoration: none; }
#jump-board { position: fixed; right: 16px; bottom: 16px; z-index: 40; border: none; border-radius: 999px; background: #1F7A5C; color: #fff; font-size: 14px; font-weight: 700; padding: 12px 18px; box-shadow: 0 6px 18px rgba(20,60,45,.3); }

/* --- modale whatsapp --- */
#wa-modal { position: fixed; inset: 0; background: rgba(24,23,20,.44); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 60; }
.wa-box { background: #fff; width: 100%; max-width: 460px; max-height: 84vh; border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(20,18,12,.28); }
.wa-head { flex: none; padding: 20px 22px 16px; border-bottom: 1px solid #F0EFE9; display: flex; justify-content: space-between; gap: 12px; }
.wa-head h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.wa-head p { margin: 0; font-size: 13px; line-height: 1.5; color: #8A887F; }
#wa-close { flex: none; width: 32px; height: 32px; border: none; border-radius: 9px; background: #F2F1EC; color: #6E6D66; }
#wa-list { flex: 1; overflow-y: auto; padding: 14px 18px 6px; display: flex; flex-direction: column; gap: 10px; }
.wa-card { border: 1px solid #ECEBE5; border-radius: 14px; padding: 13px 14px; background: #fff; }
.wa-card .row1 { display: flex; align-items: center; gap: 9px; }
.wa-card .row1 .nm { flex: 1; font-size: 15px; font-weight: 700; }
.wa-send { display: flex; align-items: center; gap: 7px; border: none; background: #25D366; color: #fff; font-size: 13px; font-weight: 700; padding: 8px 13px; border-radius: 9px; }
.wa-card input { width: 100%; margin-top: 10px; border: 1px solid #E4E3DD; border-radius: 9px; padding: 9px 12px; font-family: inherit; font-size: 14px; background: #FCFCFA; outline: none; }
.wa-toggle { margin-top: 8px; border: none; background: transparent; color: #1F7A5C; font-size: 12.5px; font-weight: 600; padding: 2px 0; }
.wa-prev { margin: 6px 0 0; padding: 11px 13px; background: #F6F5F2; border-radius: 10px; font-family: inherit; font-size: 12.5px; line-height: 1.55; color: #4A4944; white-space: pre-wrap; word-break: break-word; }
.wa-note { flex: none; margin: 4px 20px 16px; font-size: 11.5px; line-height: 1.5; color: #A6A59E; }

@keyframes msgIn { from { transform: translateY(8px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes rowIn { from { transform: translateY(10px); } to { transform: none; } }
@keyframes boardIn { from { transform: translateX(36px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes dotPulse { 0%,60%,100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* --- telefono: tabellone SOTTO la chat --- */
@media (max-width: 879px) {
  #app { height: auto; min-height: 100vh; }
  #main, #main.has-board { display: block; }
  #main.has-board #chat-panel { flex: none; }
  #msgs { max-height: 60vh; }
  #board-panel { border-left: none; border-top: 1px solid #E9E8E2; }
  #board-scroll { overflow-x: auto; }
  .back-to-chat { display: block; }
  .board-head { padding: 18px 16px 14px; }
  #board-scroll { padding: 14px 12px 6px; }
}
