/* =====================================================
   Display pubblico (TV / dashboard) — tema chiaro
   ===================================================== */
:root {
  --bg-1: #f5f6fb;
  --bg-2: #eef0f7;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-soft: #4a4f5e;
  --muted: #8a8f9e;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-soft: rgba(99,102,241,.08);
  --gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --border: rgba(17,24,39,.06);
}

*,*::before,*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: none;
  -ms-touch-action: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(99,102,241,.13), transparent 60%),
    radial-gradient(1100px 600px at 110% 110%, rgba(168,85,247,.13), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ------- Top bar ------- */
.display-top {
  position: fixed; top: 0; left: 0; right: 0; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 30;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 34%; }
.brand-logo {
  width: auto; height: 36px;
  max-height: 36px; max-width: 70px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(99,102,241,.3));
}
.brand-text {
  font-size: clamp(14px, 1.1vw, 19px); font-weight: 700;
  letter-spacing: -.3px; color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shift-pill {
  display: flex; align-items: baseline; gap: 12px;
  padding: 7px 20px; border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(99,102,241,.18);
}
.shift-pill-label {
  font-size: clamp(10px, .8vw, 13px); text-transform: uppercase;
  letter-spacing: 1.1px; color: var(--text-soft); font-weight: 600;
}
.shift-pill-value {
  font-size: clamp(16px, 1.4vw, 24px); font-weight: 800; color: var(--accent);
  letter-spacing: -.3px;
}
.shift-pill-time { font-size: clamp(11px, .9vw, 16px); color: var(--text-soft); font-weight: 600; }

.clock { text-align: right; }
.clock #clockTime {
  display: block; font-size: clamp(18px, 1.6vw, 26px); font-weight: 700;
  letter-spacing: 1px; color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.clock #clockDate { font-size: clamp(10px, .75vw, 13px); font-weight: 500; margin-top: 2px; display: inline-block; }

/* ------- Stage ------- */
.stage {
  position: absolute; inset: 60px 0 34px 0;
}
.slide {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .9s ease;
}
.slide.active {
  opacity: 1;
  pointer-events: auto;
}

/* ------- Daily operator -> cantiere list ------- */
.daily-list-wrap {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.daily-title {
  margin: 0 0 22px;
  font-size: clamp(22px, 2.6vw, 44px);
  font-weight: 900;
  color: var(--accent);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.daily-list {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--daily-columns, 1), minmax(0, 1fr));
  grid-auto-flow: row;
  gap: calc(10px * var(--daily-fit, 1)) calc(28px * var(--daily-fit, 1));
  align-content: start;
  overflow: hidden;
}
.daily-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px -18px rgba(17,24,39,.25);
}
.daily-name {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: calc(var(--daily-name-size, 28px) * var(--daily-fit, 1));
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  padding: calc(var(--daily-row-pad, 14px) * var(--daily-fit, 1)) calc(18px * var(--daily-fit, 1));
  border-right: 1px solid var(--border);
  overflow: hidden;
  overflow-wrap: break-word;
  white-space: normal;
}
.daily-cantiere {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  font-size: calc(var(--daily-cantiere-size, 24px) * var(--daily-fit, 1));
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: calc(var(--daily-row-pad, 14px) * var(--daily-fit, 1)) calc(14px * var(--daily-fit, 1));
  border-radius: 0;
  text-align: center;
  white-space: normal;
  overflow-wrap: break-word;
  overflow: hidden;
}
.daily-cantiere.daily-unassigned {
  background: var(--bg-2) !important;
  color: var(--muted) !important;
  font-style: italic;
  font-weight: 600;
  text-transform: none;
}
.shift-message-panel {
  width: min(1500px, 94vw);
  min-height: min(58vh, 620px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 58px 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 25px 65px -30px rgba(99,102,241,.38),
              0 4px 12px rgba(17,24,39,.05);
  position: relative;
  overflow: hidden;
}
.shift-message-panel::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 7px;
  background: var(--gradient);
}
.shift-message-kicker {
  position: relative;
  margin-bottom: 24px;
  color: var(--accent);
  font-size: clamp(18px, 1.5vw, 28px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.shift-message-text {
  position: relative;
  max-width: 100%;
  color: var(--text);
  font-size: clamp(22px, var(--shift-message-font-size, 6vw), 118px);
  font-weight: 900;
  line-height: 1.05;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* ------- Annunci ------- */
.announcement-card {
  max-width: 90%;
  width: 100%;
  text-align: center;
  padding: 60px 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: 0 30px 70px -30px rgba(99,102,241,.35),
              0 4px 12px rgba(17,24,39,.05);
  position: relative;
  overflow: hidden;
  max-height: 100%;
}
.announcement-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 7px;
  background: var(--gradient);
}
.announcement-title {
  margin: 0 0 32px;
  font-size: clamp(28px, var(--announcement-title-size, 7vw), 130px);
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0;
  line-height: 1;
  overflow-wrap: anywhere;
}
.announcement-message {
  margin: 28px 0 0;
  font-size: clamp(18px, var(--announcement-message-size, 3.2vw), 56px);
  line-height: 1.35;
  color: var(--text-soft);
  white-space: pre-wrap;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.slide-announcement.long-announcement .announcement-card {
  padding: 44px 64px;
}
.slide-announcement.long-announcement .announcement-title {
  margin-bottom: 22px;
  line-height: 1.04;
}
.slide-announcement.long-announcement .announcement-message {
  margin-top: 18px;
  line-height: 1.26;
}
.slide-announcement.dense-announcement .announcement-card {
  padding: 34px 50px;
}
.slide-announcement.dense-announcement .announcement-title {
  margin-bottom: 14px;
  line-height: 1.08;
}
.slide-announcement.dense-announcement .announcement-message {
  margin-top: 12px;
  line-height: 1.18;
}
.announcement-image-wrap img {
  max-width: 100%;
  max-height: 45vh;
  border-radius: 20px;
  margin: 0 auto;
  display: block;
  box-shadow: 0 14px 40px rgba(17,24,39,.18);
}
.slide-announcement.image-only {
  padding: 0;
}
.slide-announcement.image-only .announcement-card {
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slide-announcement.image-only .announcement-card::after {
  display: none;
}
.slide-announcement.image-only .announcement-image-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slide-announcement.image-only .announcement-image-wrap img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
}

/* ------- Bottom bar ------- */
.display-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; height: 34px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 30;
  font-size: clamp(10px, .8vw, 13px);
}
.indicator { display: flex; gap: 12px; }
.indicator span {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(17,24,39,.15);
  transition: background .3s ease, transform .3s ease, width .3s ease;
}
.indicator span.on {
  background: var(--accent);
  width: 36px;
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(99,102,241,.5);
}

/* ------- Weekly operator x cantiere grid (matches the paper roster) ------- */
.slide-weekly-grid {
  padding: clamp(10px, 1.6vw, 26px);
  background: transparent;
}
.weekly-grid-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: #000;
  background: #fff;
  border: 1px solid rgba(17,24,39,.08);
  border-radius: clamp(12px, 1.4vw, 22px);
  padding: clamp(10px, 1.3vw, 20px);
  box-shadow: 0 24px 65px -30px rgba(17,24,39,.42),
              0 3px 12px rgba(17,24,39,.08);
  overflow: hidden;
}
.weekly-grid-table-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  border: 2px solid #000;
  border-radius: clamp(6px, .7vw, 10px);
}
.weekly-grid-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
}
.weekly-grid-table th,
.weekly-grid-table td {
  border: 1.5px solid #333;
  padding: calc(var(--weekly-grid-pad-y, 10px) * var(--weekly-grid-fit, 1)) calc(var(--weekly-grid-pad-x, 10px) * var(--weekly-grid-fit, 1));
  vertical-align: middle;
  overflow-wrap: anywhere;
  overflow: hidden;
  text-align: center;
}
.weekly-grid-num-head,
.weekly-grid-name-head,
.weekly-grid-day-head {
  background: #f1f2f8;
  color: #000;
  font-size: calc(var(--weekly-grid-head-size, 16px) * var(--weekly-grid-fit, 1));
  font-weight: 800;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
}
.weekly-grid-num-head { width: 3.5%; }
.weekly-grid-name-head { width: 16%; text-align: left; }
.weekly-grid-num,
.weekly-grid-name {
  background: #c9b8e8;
  color: #000;
  font-weight: 800;
  font-size: calc(var(--weekly-grid-font-size, 18px) * var(--weekly-grid-fit, 1));
}
.weekly-grid-name { text-align: left; }
.weekly-grid-cell {
  font-weight: 800;
  font-size: calc(var(--weekly-grid-font-size, 18px) * var(--weekly-grid-fit, 1));
  text-transform: uppercase;
  line-height: 1.15;
}
.weekly-grid-cell.weekly-grid-empty {
  background: #fafafa !important;
  color: #bbb !important;
}

@media (max-width: 900px), (max-height: 620px) {
  .slide-weekly-grid {
    padding: 6px;
  }
  .weekly-grid-container {
    border-radius: 12px;
    padding: 8px;
  }
  .weekly-grid-table-wrap {
    border-width: 1px;
  }
  .weekly-grid-table th,
  .weekly-grid-table td {
    border-width: 1px;
  }
}

@media (max-width: 900px) {
  .display-top {
    padding: 0 14px;
    gap: 10px;
  }
  .brand {
    max-width: 30%;
    gap: 8px;
  }
  .shift-pill {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
    padding: 6px 12px;
    gap: 8px;
  }
  .display-bottom {
    padding: 0 14px;
  }
}
