/* ============================================================
   MEETING ROOM DISPLAY — Styles
   Optimised for landscape tablet (iPad / Android 10"+)
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #21262d;
  --border:       #30363d;

  --available:    #2ea043;
  --available-bg: #0d2113;
  --available-glow: rgba(46, 160, 67, 0.4);

  --busy:         #f85149;
  --busy-bg:      #2d1319;
  --busy-glow:    rgba(248, 81, 73, 0.4);

  --soon:         #e3b341;
  --soon-bg:      #2d2112;
  --soon-glow:    rgba(227, 179, 65, 0.4);

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --accent:       #388bfd;
  --book-btn:     #238636;
  --book-btn-hover: #2ea043;

  --radius-sm:  0.5rem;
  --radius-md:  1rem;
  --radius-lg:  1.5rem;

  /* Safe area insets for notch / Dynamic Island devices */
  --sat: env(safe-area-inset-top,    0px);
  --sar: env(safe-area-inset-right,  0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left,   0px);
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Screens ---- */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  overflow: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}


/* ============================================================
   SCREEN 1 — Sign In
   ============================================================ */
.center-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  width: min(90vw, 480px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.center-card.wide {
  width: min(94vw, 640px);
  align-items: stretch;
  text-align: left;
}

.app-icon {
  font-size: 3.5rem;
  line-height: 1;
}

.center-card h1 {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Google sign-in button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  max-width: 280px;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-google:hover:not(:disabled) {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.btn-google:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.google-logo {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}


/* ============================================================
   SCREEN 2 — Setup
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}
.form-group select {
  appearance: none;
  cursor: pointer;
}
.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
  width: 100%;
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.15);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.center-card.wide {
  gap: 1.25rem;
}


/* ============================================================
   SCREEN 3 — Meeting Room Display
   ============================================================ */
#screen-display {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}
#screen-display.active {
  display: flex;
}

/* Header */
.display-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2rem 0.6rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0.1rem;
}

.clock {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 200;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.room-name {
  font-size: clamp(0.85rem, 1.8vw, 1.1rem);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;   /* ~60+ chars fit comfortably on a tablet */
}

/* Main area */
.display-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.5vh, 2rem);
  padding: 1rem 2rem;
  min-height: 0;
}

/* Status badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.status-dot {
  width: clamp(10px, 1.5vw, 18px);
  height: clamp(10px, 1.5vw, 18px);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.7; }
}

/* Available */
.status-available {
  background: var(--available-bg);
  color: var(--available);
  box-shadow: 0 0 20px var(--available-glow);
}
.status-available .status-dot {
  background: var(--available);
  box-shadow: 0 0 8px var(--available);
}

/* In use */
.status-busy {
  background: var(--busy-bg);
  color: var(--busy);
  box-shadow: 0 0 20px var(--busy-glow);
}
.status-busy .status-dot {
  background: var(--busy);
  box-shadow: 0 0 8px var(--busy);
}

/* Starting soon */
.status-soon {
  background: var(--soon-bg);
  color: var(--soon);
  box-shadow: 0 0 20px var(--soon-glow);
}
.status-soon .status-dot {
  background: var(--soon);
  box-shadow: 0 0 8px var(--soon);
}

/* Meeting card */
.meeting-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  max-width: 85%;
}

.meeting-title {
  font-size: clamp(1.6rem, 5vw, 3.5rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  word-break: break-word;
}

.meeting-organizer {
  font-size: clamp(0.85rem, 1.8vw, 1.2rem);
  color: var(--text-secondary);
}

.meeting-time {
  font-size: clamp(1.1rem, 2.5vw, 1.8rem);
  font-weight: 300;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Next meeting strip */
.next-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.25rem;
  font-size: clamp(0.8rem, 1.6vw, 1.05rem);
  max-width: 80%;
}

.next-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  flex-shrink: 0;
}
.next-title {
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Actions */
.display-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 2rem;
  flex-shrink: 0;
}

.btn-book {
  background: var(--book-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: clamp(0.7rem, 2vh, 1.1rem) clamp(2rem, 6vw, 4rem);
  font-size: clamp(1.1rem, 3vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 4px 20px rgba(46, 160, 67, 0.3);
}
.btn-book:hover {
  background: var(--book-btn-hover);
}
.btn-book:active {
  transform: scale(0.97);
}

.btn-cancel-meeting {
  background: transparent;
  color: var(--busy);
  border: 2px solid var(--busy);
  border-radius: var(--radius-md);
  padding: clamp(0.6rem, 1.8vh, 1rem) clamp(1.5rem, 4vw, 3rem);
  font-size: clamp(0.9rem, 2.2vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.btn-cancel-meeting:hover {
  background: var(--busy-bg);
}
.btn-cancel-meeting:active {
  transform: scale(0.97);
}

/* Danger button — used in cancel confirmation modal */
.btn-danger {
  background: var(--busy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
  width: 100%;
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(1.15);
}
.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cancel-box {
  width: min(95vw, 420px);
}
.cancel-meeting-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}
.cancel-meeting-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
}

/* Footer */
.display-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 2rem 0.8rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-footer-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.4rem 0.75rem;
  font-size: clamp(0.7rem, 1.3vw, 0.85rem);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.btn-footer-ghost:hover {
  color: var(--text-secondary);
}

/* Invisible kiosk-exit tap zone (top-right corner, 60×60 px) */
.kiosk-exit-tap {
  position: fixed;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: transparent;
  border: none;
  cursor: default;
  z-index: 50;
  /* In kiosk mode only — becomes the hidden exit trigger */
}


/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: min(95vw, 520px);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* Book modal */
.book-availability {
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
}

.duration-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.duration-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  min-width: 70px;
}
.duration-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text-primary);
}
.duration-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.duration-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.no-slots-msg {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 0.4rem 0;
}

/* PIN modal */
.pin-box {
  align-items: center;
  width: min(95vw, 380px);
}
.pin-box h2 {
  text-align: center;
}
.pin-box .subtitle {
  text-align: center;
}

.pin-dots {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  margin: 0.5rem 0;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  width: 100%;
}

.pin-key {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 500;
  padding: 0.85rem;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  touch-action: manipulation;
}
.pin-key:hover {
  background: var(--border);
}
.pin-key:active {
  transform: scale(0.94);
}
.pin-key-action {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* iOS instruction modal */
.ios-steps {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  padding-left: 1.25rem;
}
.ios-steps li { margin-bottom: 0.25rem; }
.ios-steps strong { color: var(--text-primary); }

/* Error text */
.error-text {
  color: var(--busy);
  font-size: 0.85rem;
  text-align: center;
}

/* Utility */
[hidden] { display: none !important; }

/* ============================================================
   Loading spinner (shown while GIS loads / API calls)
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
