/* Floorwalker Agent Dashboard — terminal overview */

:root {
  --bg: #0f1115;
  --surface: #1a1d29;
  --card: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.08);
  --text: #fff;
  --muted: rgba(255,255,255,0.55);
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden { display: none !important; }

/* ── Screens ───────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.active { display: flex; }

/* ── Terminal Selection ────────────────────────────────────────────────── */
#screenSelectTerminal {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.select-card {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
}

.select-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.select-subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 1.05rem;
}

.terminal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.terminal-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  border: none;
  border-radius: 16px;
  padding: 1.5rem 1rem;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

.terminal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.terminal-btn:active { transform: translateY(0); }

/* ── Dashboard Header ──────────────────────────────────────────────────── */
#screenDashboard {
  flex-direction: column;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dash-title {
  font-size: 1.5rem;
  font-weight: 800;
}

.dash-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-signout {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.btn-signout:hover { background: rgba(255,255,255,0.12); }

.dash-clock {
  font-family: 'Courier New', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 4rem;
  text-align: right;
}

/* ── Main Grid ─────────────────────────────────────────────────────────── */
.dash-main {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
}

.dash-loading {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.dash-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 1rem;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Gate Cards ────────────────────────────────────────────────────────── */
.gate-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s, background 0.15s;
}

.gate-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
}

.gate-card.empty {
  opacity: 0.65;
  border-style: dashed;
}

.gate-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.gate-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
}

.gate-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}

.status-boarding { background: rgba(37, 99, 235, 0.2); color: #60a5fa; }
.status-on-time { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-delayed { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-departed { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
.status-cancelled { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.gate-route {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-light);
}

.gate-destination {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.gate-time {
  font-family: 'Courier New', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--success);
}

.gate-time.delayed { color: var(--warning); }

.gate-delay {
  font-size: 0.85rem;
  color: var(--warning);
  font-weight: 600;
}

.gate-device {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.gate-actions {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.gate-card.empty .gate-actions {
  display: none;
}

.btn {
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.12s;
}

.btn:active { transform: scale(0.98); }

.btn-edit {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.btn-edit:hover { background: rgba(255,255,255,0.15); }

.btn-depart {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #fff;
}

/* ── Pending Gate Card (undo countdown) ───────────────────────────────── */
.gate-card.pending {
  position: relative;
  overflow: hidden;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.07);
}

.pending-bar-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(255,255,255,0.08);
}

.pending-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
  transition: width 0.2s linear;
}

.pending-countdown {
  font-size: 0.85rem;
  color: #fca5a5;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gate-card.pending .gate-route,
.gate-card.pending .gate-destination {
  opacity: 0.85;
}

.btn-undo {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  font-size: 1rem;
  padding: 0.9rem;
  width: 100%;
  margin-top: 0.25rem;
}

.btn-undo:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop,
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-backdrop.hidden,
.confirm-backdrop.hidden { display: none; }

.modal-card,
.confirm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  margin-bottom: 1.25rem;
}

.modal-route {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-dest {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 0.25rem;
}

.modal-gate {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.modal-section {
  margin-bottom: 1.25rem;
}

.modal-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}

.modal-status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.modal-status-btn,
.modal-timing-btn {
  padding: 0.8rem 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}

.modal-status-btn:hover,
.modal-timing-btn:hover { background: rgba(255,255,255,0.08); }

.modal-status-btn.active,
.modal-timing-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.modal-timing-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.modal-delay-row {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--card);
  border-radius: 10px;
}

.modal-delay-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.modal-delay-stepper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}

.stepper-val {
  min-width: 2rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal-actions,
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: rgba(255,255,255,0.05); }

/* Confirm modal */
.confirm-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.confirm-body {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  white-space: pre-line;
}

.confirm-note {
  font-size: 0.85rem;
  color: var(--warning);
}

/* ── Last Updated Footer ──────────────────────────────────────────────── */
.last-updated {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(0,0,0,0.2);
}

/* ── Debug Overlay ─────────────────────────────────────────────────────── */
.debug-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.debug-overlay.active { display: flex; }

.debug-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.debug-panel h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.debug-panel input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  color: var(--text);
}

.debug-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.debug-actions button {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  cursor: pointer;
}

.debug-actions button:first-child {
  background: var(--accent);
  border-color: var(--accent);
}

/* Debug bar */
.debug-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  text-align: center;
  padding: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 50;
}

/* Responsive */
@media (max-width: 640px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .dash-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .dash-header-right {
    width: 100%;
    justify-content: space-between;
  }
}
