
/* =========================================
   DLY1 WAVE TIMER WEB
   Layout TV e browser responsive
   ========================================= */

* {
  box-sizing: border-box;
}

:root {
  font-family: Arial, sans-serif;
  color: #111827;
  background: #f9fafb;
  --panel-bg: #ffffff;
  --row-bg: #f3f4f6;
  --border-color: #d1d5db;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
}

body {
  min-height: 100vh;
  background: #f9fafb;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

/* TOP BAR */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(16px, 2vw, 36px);
  min-height: 100px;
  background: #e5e7eb;
}

.top-bar h1 {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: clamp(24px, 3vw, 52px);
  font-weight: 800;
  letter-spacing: 1px;
}

.logo-left {
  width: auto;
  height: clamp(42px, 5vw, 70px);
  object-fit: contain;
}

.logo-right {
  width: auto;
  height: clamp(55px, 8vw, 120px);
  object-fit: contain;
}

/* LAYOUT PRINCIPALE */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.6fr);
  gap: clamp(16px, 2vw, 30px);
  padding: clamp(20px, 2.5vw, 36px);
  align-items: stretch;
}

.timer-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.5vh, 30px);
  min-width: 0;
}

.wave-title {
  width: 100%;
  text-align: center;
  font-size: clamp(24px, 2.5vw, 40px);
  font-weight: 700;
  color: #111827;
}

/* TIMER */

.timer-box {
  width: 100%;
  padding: clamp(18px, 3vw, 42px);
  border-radius: 22px;
  text-align: center;
  background: #e5e7eb;
  color: #111827;
  transition: background-color 0.3s ease;
}

.status-label {
  font-size: clamp(12px, 1.3vw, 21px);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.timer-display {
  margin: 14px 0;
  font-size: clamp(48px, 6vw, 100px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.phase-label {
  font-size: clamp(12px, 1.2vw, 20px);
  line-height: 1.4;
}

.progress-wrapper {
  width: 100%;
  height: 9px;
  margin-top: 18px;
  background: #cbd5e1;
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: #22c55e;
  transition: width 0.4s linear;
}

.timer-box.pulse {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* DETTAGLI ORARI */

.details {
  width: 100%;
  text-align: center;
  font-size: clamp(14px, 1.3vw, 22px);
  line-height: 1.7;
}

.details p {
  margin: 5px 0;
}

/* PANNELLO LATERALE */

.side-panel {
  min-width: 0;
  min-height: 0;
  padding: clamp(12px, 1.5vw, 24px);
  background: var(--panel-bg);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgb(15 23 42 / 6%);
}

.side-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.side-section {
  min-width: 0;
}

.side-section h2 {
  margin: 0 0 12px;
  padding-bottom: 8px;
  font-size: clamp(20px, 1.8vw, 30px);
  border-bottom: 1px solid #e5e7eb;
}

/* WAVES OVERVIEW */

#waves-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  overflow-x: auto;
}

:root {
  --waves-grid:
    32px
    minmax(100px, 1.5fr)
    minmax(65px, 1fr)
    minmax(65px, 1fr)
    minmax(65px, 1fr);
}

.waves-table-row {
  display: grid;
  grid-template-columns: var(--waves-grid);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 6px;
  background: var(--row-bg);
  font-size: clamp(12px, 1.1vw, 18px);
  white-space: nowrap;
}

.waves-table-row.header {
  font-weight: 700;
  background: #e5e7eb;
}

.waves-table-row.body {
  cursor: default;
}

.waves-table-row.active {
  background: #dbeafe;
  border-left: 4px solid #3b82f6;
}

.waves-table-row.completed {
  opacity: 0.65;
}

.wave-status-icon {
  text-align: center;
}

/* ROUTES PER WAVE */

#vans-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
}

.vans-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.vans-row {
  display: grid;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
}

.vans-row.header {
  background: #e5e7eb;
  font-weight: 700;
}

.vans-row.body {
  background: var(--row-bg);
}

.vans-row.footer {
  background: #9da7b4;
  font-weight: 700;
}

.vans-cell {
  min-width: 0;
  padding: 4px;
  text-align: center;
  overflow-wrap: anywhere;
}

.vans-cell.wave-label,
.vans-cell.header-label,
.vans-cell.total-label {
  text-align: left;
  font-weight: 600;
}

.dsp-input,
.van-input {
  width: 100%;
  min-width: 0;
  padding: 6px 4px;
  text-align: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
}

.van-input {
  font-variant-numeric: tabular-nums;
}

.highlight-total {
  color: #713f12;
  font-size: 1.1em;
  font-weight: 800;
}

/* DEBUG */

.debug-section {
  margin-top: 16px;
  overflow: hidden;
}

.debug-log {
  max-height: 200px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #e5e7eb;
  color: #111827;
}

/* ETICHETTA VERSIONE */

.app-version-label {
  padding: 10px 16px;
  text-align: center;
  font-size: 12px;
  color: #64748b;
}

/* COLORI FASI TIMER */

.upcoming_firstwave {
  background-color: #d1d5db !important;
  color: #111827 !important;
}

.upcoming,
.pre-authorized {
  background-color: #1d4ed8 !important;
  color: #ffffff !important;
}

.green {
  background-color: #166534 !important;
  color: #ffffff !important;
}

.yellow {
  background-color: #facc15 !important;
  color: #111827 !important;
}

.orange {
  background-color: #ff8c00 !important;
  color: #111827 !important;
}

.expired {
  background-color: #4b5563 !important;
  color: #ffffff !important;
}

/* TABLET E SCHERMI STRETTI */

@media (max-width: 900px) {
  .top-bar {
    gap: 10px;
    padding: 12px;
  }

  .top-bar h1 {
    font-size: clamp(18px, 4vw, 30px);
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .timer-panel {
    width: 100%;
  }

  .timer-box {
    max-width: 700px;
  }

  .side-panel {
    width: 100%;
  }
}

/* SCHERMI TV GRANDI */

@media (min-width: 1600px) {
  .layout {
    gap: 28px;
    padding: 24px 32px;
  }

  .waves-table-row {
    padding: 12px;
  }
}

/* ACCESSIBILITÀ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
