/* --- reset & kiosk hardening --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: #fff;
  transition: background-color 0.6s ease;
}

/* --- color states --- */
:root {
  --color-free: #1b8a2e;
  --color-free-dark: #146b22;
  --color-busy: #c41e1e;
  --color-busy-dark: #9a1818;
  --color-upcoming: #d4880a;
  --color-upcoming-dark: #a86d08;
  --color-loading: #333;
  --color-error: #555;
  --ring-size: 160px;
}

.state-free { background-color: var(--color-free); --state-color: var(--color-free); }
.state-upcoming { background-color: var(--color-upcoming); --state-color: var(--color-upcoming); }
.state-busy-awaiting-checkin { background-color: var(--color-busy); }
.state-busy-early-checkin { background-color: var(--color-busy); }
.state-busy-checked-in { background-color: var(--color-busy); }
.state-busy-walkin { background-color: var(--color-busy); }
.state-loading { background-color: var(--color-loading); }
.state-error { background-color: var(--color-error); }

/* amber pulse */
.state-upcoming {
  animation: pulse-amber 2s ease-in-out infinite;
}

@keyframes pulse-amber {
  0%, 100% { background-color: var(--color-upcoming); }
  50% { background-color: var(--color-upcoming-dark); }
}

/* --- layout --- */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* top bar */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.15);
  letter-spacing: 0.02em;
}

#logo {
  height: 28px;
  width: auto;
}

/* main: two panels */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* left panel */
#room-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 16px;
}

#room-info {
  text-align: center;
}

#room-name {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
}

#room-capacity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.3rem;
  margin-top: 8px;
  opacity: 0.85;
}

/* status area */
#status-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 500px;
}

.status-content {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.status-content.active {
  display: flex;
}

.status-label {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
}

.status-detail {
  font-size: 1.4rem;
  opacity: 0.9;
  text-align: center;
}

/* event info */
.event-name {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.event-time-range {
  font-size: 1.3rem;
  opacity: 0.85;
  text-align: center;
}

/* --- action buttons --- */
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 48px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  min-width: 240px;
  min-height: 72px;
  margin-top: 8px;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.97);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.action-btn .btn-label {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.action-btn .btn-sub {
  font-size: 1rem;
  opacity: 0.8;
  margin-top: 2px;
}

.action-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.5);
  margin-top: 12px;
}

/* --- walk-in time picker --- */
.walkin-picker {
  width: 100%;
  text-align: center;
  margin-top: 8px;
}

.picker-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: 8px;
}

.picker-scroll-wrapper {
  position: relative;
}

.picker-scroll-wrapper::before,
.picker-scroll-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  z-index: 1;
  pointer-events: none;
}

.picker-scroll-wrapper::before {
  left: 0;
  background: linear-gradient(to right, var(--state-color, rgba(0,0,0,0.3)), transparent);
}

.picker-scroll-wrapper::after {
  right: 0;
  background: linear-gradient(to left, var(--state-color, rgba(0,0,0,0.3)), transparent);
}

.picker-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px;
  scrollbar-width: none;
  justify-content: flex-start;
}

.picker-scroll::-webkit-scrollbar {
  display: none;
}

.picker-option {
  flex-shrink: 0;
  scroll-snap-align: center;
  padding: 12px 20px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.picker-option:active {
  transform: scale(0.95);
}

.picker-option.selected {
  background: rgba(255, 255, 255, 0.25);
  border-color: #fff;
}

.action-btn-end {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
}

.checked-in-badge {
  font-size: 1.2rem;
  padding: 8px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  letter-spacing: 0.04em;
  margin-top: 8px;
}

/* --- countdown ring --- */
#countdown-ring-container,
#meeting-countdown-container {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  margin: 8px 0;
}

#checkin-countdown-svg,
#meeting-countdown-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 8;
}

.ring-progress {
  fill: none;
  stroke: #fff;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

.ring-meeting {
  stroke: rgba(255, 255, 255, 0.7);
}

#checkin-countdown-text,
#meeting-countdown-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#checkin-countdown-value,
#meeting-countdown-value {
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  font-size: 0.9rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- right panel: schedule --- */
#schedule-panel {
  width: 320px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
}

#schedule-header h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.8;
}

.refresh-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.refresh-btn:active {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.refresh-btn.spinning svg {
  animation: spin 0.8s linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#schedule-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 20px;
  scrollbar-width: none;
}

#schedule-list::-webkit-scrollbar {
  display: none;
}

.schedule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.schedule-item:last-child {
  border-bottom: none;
}

.schedule-time {
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 55px;
  opacity: 0.85;
}

.schedule-details {
  flex: 1;
  min-width: 0;
}

.schedule-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
}

.schedule-meta {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-item.current {
  opacity: 1;
}

.schedule-item.current .schedule-time,
.schedule-item.current .schedule-title {
  font-weight: 700;
}

.schedule-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  margin-top: 6px;
  display: none;
}

.schedule-item.current .schedule-dot {
  display: block;
}

.schedule-item.past {
  opacity: 0.4;
}

#no-meetings {
  padding: 24px;
  text-align: center;
  opacity: 0.5;
  font-size: 1rem;
}

/* --- toast --- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- responsive: portrait tablets --- */
@media (max-aspect-ratio: 1/1) {
  main {
    flex-direction: column;
  }

  #room-panel {
    flex: 1;
    padding: 24px;
  }

  #room-name {
    font-size: 2rem;
  }

  .status-label {
    font-size: 2.4rem;
  }

  #schedule-panel {
    width: 100%;
    max-height: 35%;
  }

  :root {
    --ring-size: 130px;
  }

  #checkin-countdown-value,
  #meeting-countdown-value {
    font-size: 2rem;
  }
}

/* small tablets */
@media (max-height: 600px) {
  #top-bar {
    padding: 8px 20px;
    font-size: 0.95rem;
  }

  #room-name {
    font-size: 1.8rem;
  }

  .status-label {
    font-size: 2rem;
  }

  :root {
    --ring-size: 110px;
  }

  .action-btn {
    padding: 14px 32px;
    min-height: 56px;
  }
}
