/* Prenotazione Aule – pagina della sala per il tablet */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --green: #16a34a;
  --green-d: #15803d;
  --red: #dc2626;
  --red-d: #b91c1c;
  --grey: #475569;
  --state: var(--green);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body.kiosk {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
body.state-busy   { --state: var(--red); }
body.state-closed { --state: var(--grey); }

.k-wrap {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  gap: 2.5vh;
  padding: 3vh 4vw 2vh;
  background: none;
  background: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--state) 22%, transparent), transparent 65%);
  transition: background .4s;
}

/* Intestazione: sala a sinistra, ora e data a destra */
.k-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.k-room { display: flex; align-items: center; gap: 20px; min-width: 0; }
.k-logo { max-height: 9vh; max-width: 22vw; object-fit: contain; background: #fff; border-radius: 10px; padding: 6px 10px; }
.k-room h1 { margin: 0; font-size: clamp(26px, 5vmin, 56px); font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; }
.k-sub { margin: 4px 0 0; color: var(--muted); font-size: clamp(14px, 2.2vmin, 22px); }
.k-clock { text-align: right; flex-shrink: 0; }
.k-time { font-size: clamp(40px, 9vmin, 110px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.k-date { color: var(--muted); font-size: clamp(14px, 2.6vmin, 26px); margin-top: 6px; }

/* Pulsante di stato */
.k-main { display: flex; align-items: center; justify-content: center; min-height: 0; }
.k-status {
  width: min(88vw, 900px);
  height: 100%;
  max-height: 48vh;
  min-height: 200px;
  border: 0;
  border-radius: 36px;
  background: var(--state);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4vh;
  padding: 24px;
  cursor: pointer;
  font: inherit;
  box-shadow: 0 20px 60px -10px color-mix(in srgb, var(--state) 60%, transparent), inset 0 -8px 0 rgba(0,0,0,.15);
  transition: transform .12s, background .3s, box-shadow .3s;
}
.k-status:active { transform: scale(.98); }
.k-status:disabled { cursor: default; }
.k-status-label { font-size: clamp(56px, 15vmin, 190px); font-weight: 800; letter-spacing: .06em; line-height: 1; }
.k-status-info { font-size: clamp(18px, 3.4vmin, 38px); font-weight: 600; text-align: center; max-width: 95%; overflow-wrap: anywhere; }
.k-status-hint { font-size: clamp(14px, 2.3vmin, 24px); opacity: .9; background: rgba(0,0,0,.18); padding: 6px 18px; border-radius: 999px; }
.k-status-hint:empty { display: none; }

/* Programma di oggi */
.k-today h2 { margin: 0 0 10px; font-size: clamp(16px, 2.4vmin, 24px); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.k-hours { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 8px; }
.k-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; }
.k-list::-webkit-scrollbar { display: none; }
.k-list li {
  flex: 0 0 auto;
  min-width: 190px;
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: clamp(14px, 2vmin, 19px);
}
.k-list li.past { opacity: .4; border-left-color: var(--grey); }
.k-list li.now { border-color: var(--red); background: #4a1f28; background: color-mix(in srgb, var(--red) 25%, var(--panel)); }
.k-list li.empty { border-left-color: var(--green); color: var(--muted); }
.k-list .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.k-list .s { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-list .o { display: block; color: var(--muted); font-size: .9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.k-foot { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.k-conn { color: #fbbf24; font-size: 14px; }
.k-fs { margin-left: auto; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; width: 40px; height: 32px; font-size: 18px; cursor: pointer; }

/* Finestre */
.k-modal {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(2, 6, 23, .75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  user-select: text; -webkit-user-select: text;
}
.k-dialog {
  background: #fff; color: #0f172a;
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  border-radius: 22px;
  padding: 26px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.k-dialog h2 { margin: 0 0 4px; font-size: 26px; }
.k-dialog h3 { margin: 0 0 4px; font-size: 19px; }
.k-muted { color: #64748b; margin: 0 0 14px; }
.k-field { display: block; margin: 14px 0 0; }
.k-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 16px; }
.k-dialog input {
  width: 100%;
  font: inherit; font-size: 20px;
  padding: 14px 16px;
  border: 2px solid #cbd5e1; border-radius: 12px;
  background: #fff; color: #0f172a;
}
.k-dialog input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.2); }
.k-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.k-pw { position: relative; display: block; }
.k-pw input { padding-right: 56px; }
.k-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; font-size: 22px; width: 44px; height: 44px; cursor: pointer; opacity: .6; }
.k-eye.on { opacity: 1; }

.k-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.k-choice, .k-chip {
  font: inherit; cursor: pointer;
  border: 2px solid #cbd5e1; background: #f8fafc; color: #0f172a;
  border-radius: 12px;
}
.k-choice { padding: 14px 8px; font-size: 19px; font-weight: 700; line-height: 1.15; }
.k-choice small { display: block; font-weight: 400; font-size: 13px; color: #64748b; margin-top: 3px; }
.k-choice.sel, .k-chip.sel { border-color: var(--green); background: #dcfce7; color: #14532d; }
.k-choice.sel small { color: #166534; }
.k-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.k-chip { padding: 9px 16px; font-size: 16px; border-radius: 999px; }

.k-detail { background: #fef2f2; border: 1px solid #fecaca; border-radius: 14px; padding: 14px 18px; margin: 12px 0 18px; font-size: 18px; }
.k-detail strong { font-size: 21px; }
.k-end-box { border-top: 1px solid #e2e8f0; padding-top: 16px; }

.k-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 10px; padding: 10px 14px; margin: 16px 0 0; font-weight: 600; }
.k-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }
.k-btn { font: inherit; font-size: 19px; font-weight: 700; padding: 14px 26px; border-radius: 12px; border: 2px solid #cbd5e1; background: #fff; color: #0f172a; cursor: pointer; min-width: 130px; }
.k-btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.k-btn-green:active { background: var(--green-d); }
.k-btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.k-btn-red:active { background: var(--red-d); }
.k-btn:disabled { opacity: .6; cursor: wait; }

.k-toast {
  position: fixed; left: 50%; bottom: 7vh; transform: translateX(-50%); z-index: 20;
  background: #fff; color: #14532d;
  border-left: 8px solid var(--green);
  padding: 18px 26px; border-radius: 14px;
  font-size: clamp(17px, 2.6vmin, 24px); font-weight: 600;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  max-width: 90vw; text-align: center;
}

@media (orientation: portrait) {
  .k-head { flex-direction: column; align-items: flex-start; }
  .k-clock { text-align: left; }
  .k-status { max-height: 42vh; }
}
@media (max-width: 560px) {
  .k-grid { grid-template-columns: 1fr; }
  .k-dialog { padding: 20px; }
}

/* Altre sale */
.k-others h2 { margin: 0 0 10px; font-size: clamp(16px, 2.4vmin, 24px); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.k-olist { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; }
.k-olist::-webkit-scrollbar { display: none; }
.k-olist li {
  flex: 0 0 auto; min-width: 200px; max-width: 320px;
  background: var(--panel); border: 1px solid var(--line); border-left: 8px solid var(--grey);
  border-radius: 14px; padding: 10px 16px; font-size: clamp(14px, 2vmin, 19px);
}
.k-olist li.o-free { border-left-color: var(--green); }
.k-olist li.o-busy { border-left-color: var(--red); }
.k-olist .n { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-olist .st { display: block; font-weight: 600; }
.k-olist li.o-free .st { color: #4ade80; }
.k-olist li.o-busy .st { color: #f87171; }
.k-olist li.o-closed .st { color: var(--muted); }
.k-olist .x { display: block; color: var(--muted); font-size: .85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-wrap > * { min-width: 0; }

/* Titolo in alto (es. «Artisti Informatici») */
.k-top { display: flex; flex-direction: column; gap: 2vh; }
.k-title {
  font-size: clamp(16px, 3vmin, 34px); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #e2e8f0; padding-bottom: 1.4vh; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (orientation: portrait) { .k-title { white-space: normal; } }
.k-status-label { font-size: clamp(56px, min(15vmin, 13vh), 190px); }
.k-wrap { gap: 2vh; }
.k-title.is-center { text-align: center; }
.k-status-teacher { font-size: clamp(16px, 2.8vmin, 32px); font-weight: 500; opacity: .95; text-align: center; margin-top: -.6vh; }

/* v1.4: il pulsante di stato non esce mai dal suo spazio (non copre più orario e programma) */
.k-wrap { grid-template-rows: auto minmax(0, 1fr) auto auto auto; }
.k-main { align-items: stretch; overflow: hidden; padding: 1vh 0; }
.k-status { height: auto; min-height: 0; max-height: none; overflow: hidden; gap: 1vh; padding: clamp(10px, 2.2vh, 24px) 24px; }
.k-status-label { font-size: clamp(34px, min(15vmin, 12vh), 190px); }
.k-status-info { font-size: clamp(15px, min(3.4vmin, 3.6vh), 38px); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.k-status-teacher { font-size: clamp(14px, min(2.8vmin, 3vh), 32px); margin-top: 0; }
.k-status-hint { font-size: clamp(12px, min(2.3vmin, 2.4vh), 24px); padding: 4px 16px; }
/* Schermi bassi (es. 1024×600): intestazione e liste più compatte, così resta spazio al pulsante */
@media (max-height: 700px) and (orientation: landscape) {
  .k-wrap { padding: 2vh 3vw 1.5vh; gap: 1.6vh; }
  .k-top { gap: 1.2vh; }
  .k-title { padding-bottom: 1vh; font-size: clamp(14px, 2.6vmin, 26px); }
  .k-time { font-size: clamp(34px, 8vmin, 80px); }
  .k-date { margin-top: 2px; }
  .k-today h2, .k-others h2 { margin-bottom: 6px; font-size: 14px; }
  .k-list li, .k-olist li { padding: 6px 12px; font-size: 13px; }
  .k-list .o, .k-olist .x { display: none; }
  .k-foot { min-height: 0; }
}
.k-status > * { flex-shrink: 0; }
@media (max-height: 540px) and (orientation: landscape) {
  .k-status-info { -webkit-line-clamp: 1; }
  .k-status-label { font-size: clamp(30px, 11vh, 80px); }
}
/* Sala non disponibile (disattivata dall'amministratore, con il motivo) */
body.state-unavailable { --state: var(--red); }
.k-status-label.is-long { font-size: clamp(30px, min(9.5vmin, 9vh), 120px); letter-spacing: .03em; text-align: center; }
.k-olist li.o-unavailable { border-left-color: var(--red); opacity: .8; }
.k-olist li.o-unavailable .st { color: #fca5a5; }
