/*
 * Cape May Aerial Advertising — brand tokens
 * Pulled from https://www.capemayads.com (Webflow CSS).
 */
:root {
  --brand-primary: #f26b26;
  --brand-primary-dark: #d25006;
  --brand-tertiary: #1c7aee;
  /* Lighter sky blue for the letter-banner thumbnails — easier on the eye in
     the picker grid than the deeper brand-tertiary. */
  --banner-letters-bg: #87ceeb;
  --brand-cream: #fef3ea;
  --brand-ink: #181717;
  --brand-stale: #d32f2f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--brand-cream);
  color: var(--brand-ink);
}

h1, h2, h3, .login-box h1, .top-bar h1 {
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  letter-spacing: -0.01em;
}

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-tertiary));
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 360px;
}

.login-box h1 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--brand-primary);
  font-size: 24px;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}

.login-box button:hover { background: var(--brand-primary-dark); }

.login-error {
  color: #d32f2f;
  text-align: center;
  margin-bottom: 12px;
  font-size: 14px;
}

/* Main layout */
.app-container { display: none; }

.top-bar {
  background: white;
  color: var(--brand-ink);
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.top-bar h1 { font-size: 18px; font-weight: 600; color: var(--brand-ink); }

.top-bar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar .user-info span { font-size: 14px; color: #555; }

.top-bar button {
  background: var(--brand-primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.top-bar button:hover { background: var(--brand-primary-dark); }

/* Tabs */
.tab-bar {
  display: flex;
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 0 20px;
}

.tab-bar button {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.tab-bar button.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.tab-bar button:hover { color: var(--brand-primary); }

/* Tab content */
.tab-content { display: none; padding: 20px; }
.tab-content.active { display: block; }

/* Map */
#admin-map {
  height: calc(100vh - 64px - 49px);
  width: 100%;
}

.tab-content.active:has(#admin-map) {
  padding: 0;
}

/* Tables */
.crud-section { max-width: 100%; }

.crud-section h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

.crud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th { background: #f8f9fa; font-weight: 600; font-size: 13px; color: #555; text-transform: uppercase; }
td { font-size: 14px; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.btn-primary { background: var(--brand-primary); color: white; }
.btn-primary:hover { background: var(--brand-primary-dark); }
.btn-danger { background: #d32f2f; color: white; }
.btn-danger:hover { background: #c62828; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.action-btns { display: flex; gap: 6px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

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

.modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}

.modal h2 { margin-bottom: 20px; }

.modal label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.modal input, .modal select, .modal textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.modal textarea { resize: vertical; min-height: 60px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* Permalink */
.permalink {
  font-family: monospace;
  font-size: 12px;
  color: var(--brand-primary);
  word-break: break-all;
}

/* Plane markers */
.plane-icon {
  background: none !important;
  border: none !important;
}

.plane-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
}

.plane-marker .fa-plane {
  font-size: 24px;
  color: var(--brand-primary);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
  transition: color 0.3s;
}

.plane-marker.stale .fa-plane {
  color: #d32f2f;
}

.plane-marker.stale .plane-marker-label {
  background: #d32f2f;
}

.plane-marker-label {
  background: var(--brand-primary);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
  text-align: center;
  line-height: 1.4;
}

/* Map popups */
.plane-popup {
  font-size: 13px;
  line-height: 1.5;
}

.plane-popup strong { font-size: 15px; }

.plane-popup-ago {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: #999;
}

/* Track page */
.track-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#track-map { flex: 1; }

.track-header {
  background: white;
  color: var(--brand-ink);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.track-header h1 { font-size: 18px; color: var(--brand-ink); }

.track-status {
  font-size: 14px;
  color: #666;
}

.track-offline {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 24px 36px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  text-align: center;
  z-index: 500;
}

.track-offline h2 { margin-bottom: 8px; color: #666; }
.track-offline p { color: #999; }

.qr-wrapper { text-align: center; padding: 8px 0; }
.qr-wrapper canvas { background: #fff; }
.qr-tail { font-size: 24px; font-weight: 600; margin-top: 8px; }
.qr-help { font-size: 13px; color: #666; margin: 8px 0 16px; }
.qr-actions { display: flex; gap: 8px; justify-content: center; }

.sessions-table-wrap { max-height: 60vh; overflow-y: auto; }
.sessions-table { width: 100%; border-collapse: collapse; }
.sessions-table th, .sessions-table td { padding: 6px 10px; border-bottom: 1px solid #eee; text-align: left; font-size: 13px; }
.sessions-table th { background: #f5f5f5; position: sticky; top: 0; }
.session-active { color: #2e7d32; font-weight: 600; }

.key-warning { color: #c62828; font-weight: 600; margin-bottom: 8px; }
.api-key-box { background: #f5f5f5; padding: 10px; border-radius: 6px; font-size: 14px; word-break: break-all; }
.key-hint { font-size: 12px; color: #666; margin-top: 12px; }
.key-hint code { background: #eee; padding: 2px 4px; border-radius: 3px; }

.beacon-status { padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.beacon-status.assigned { background: #e8f5e9; color: #1b5e20; }
.beacon-status.unassigned { background: #fff3e0; color: #e65100; }

.conn-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f0f0f0; color: var(--brand-ink); }
.conn-badge .conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #ffb74d; }
.conn-badge[data-state="live"] .conn-dot { background: #4caf50; box-shadow: 0 0 6px #4caf50; }
.conn-badge[data-state="reconnecting"] .conn-dot { background: #ff7043; animation: pulse-dot 1s infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.track-header-right { display: flex; align-items: center; gap: 12px; }

.empty-row { text-align: center; color: #888; padding: 20px !important; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #333; color: white; padding: 12px 20px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 10000; max-width: 400px; }
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-success { background: #2e7d32; }
.toast-error { background: #c62828; }

/* Brand logo */
.login-logo {
  display: block;
  margin: 0 auto 20px;
  max-width: 200px;
  width: 100%;
  height: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.track-header .brand-logo { height: 36px; }

/* Last seen column */
.muted { color: #888; font-style: italic; }
.last-seen-recent { color: #2e7d32; font-weight: 600; }

/* Banner display preview (admin table) */
.banner-thumb {
  width: 84px; height: 48px; object-fit: contain; background: #f5f5f5;
  border-radius: 4px; vertical-align: middle;
  border: 1px solid #ddd;
}
.banner-letters-preview {
  font-family: 'Doto', system-ui, sans-serif;
  font-weight: 900;
  background: var(--banner-letters-bg);
  color: black;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 16px;
  letter-spacing: 0.05em;
  display: inline-block;
}

/* Banner letters preview in modal */
.banner-letters-preview-large {
  font-family: 'Doto', system-ui, sans-serif;
  font-weight: 900;
  background: var(--banner-letters-bg);
  color: black;
  padding: 14px 20px;
  border-radius: 6px;
  font-size: 28px;
  letter-spacing: 0.06em;
  text-align: center;
  margin: 12px 0 16px;
  word-break: break-word;
}

.display-mode-toggle {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.radio-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: 1px solid #ddd; border-radius: 999px;
  cursor: pointer; font-size: 13px;
  transition: background 0.15s;
}
.radio-pill:has(input:checked) {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}
.radio-pill input { margin: 0; }

.banner-current-image {
  margin-bottom: 10px;
}
.banner-current-image img {
  max-width: 100%; max-height: 140px; border-radius: 6px; border: 1px solid #ddd;
}

/* Customer-page banner display hero */
.banner-display {
  display: flex; align-items: center; justify-content: center;
  padding: 18px 12px;
  background: white;
  border-bottom: 1px solid #eee;
}
.banner-display-image {
  max-height: 140px; max-width: 100%; object-fit: contain;
  border-radius: 8px;
}
.banner-display-letters {
  font-family: 'Doto', system-ui, sans-serif;
  font-weight: 900;
  background: var(--brand-tertiary);
  color: black;
  padding: 18px 28px;
  border-radius: 12px;
  font-size: 36px;
  letter-spacing: 0.08em;
  text-align: center;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Map Follow toggle */
.follow-toggle-btn {
  background: white;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--brand-ink);
  font-family: 'Open Sans', sans-serif;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.follow-toggle-btn.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}
.follow-toggle-btn:hover { filter: brightness(0.96); }

.modal-wide { width: 720px !important; max-width: 92vw; }
.replay-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.replay-controls input[type=range] { flex: 1; }
.replay-meta { font-family: monospace; font-size: 12px; color: #555; white-space: nowrap; }

/* Replay plane-towing-banner marker */
.replay-towmarker-wrap { background: none !important; border: none !important; }
.replay-towmarker {
  position: relative;
  display: inline-flex;
  align-items: center;
  transform-origin: 12px 12px;
  height: 24px;
  white-space: nowrap;
}
.replay-towmarker .fa-plane {
  font-size: 24px;
  color: var(--brand-primary);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
  z-index: 2;
}
.replay-towmarker .replay-towline {
  display: inline-block;
  width: 12px;
  height: 2px;
  background: rgba(0,0,0,0.5);
  margin-left: 2px;
}
.replay-towmarker .replay-towbanner {
  display: inline-block;
  background: var(--brand-tertiary);
  color: black;
  font-family: 'Doto', system-ui, sans-serif;
  font-weight: 900;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

/* Flight replay arrow nav row — sits above the embedded Leaflet map. */
.replay-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.replay-nav .muted {
  margin: 0 4px;
}

/* Tracking-link column: ellipsize the URL so a long /track/...?k=... link
   doesn't blow out the table width; copy icon sits flush to the right. */
.cell-track {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 360px;
}
.permalink-link {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--brand-tertiary);
  text-decoration: none;
}
.permalink-link:hover { text-decoration: underline; }
/* Icon-only buttons (copy, download arrow, etc.) — fixed-width so they line
   up next to the labelled buttons. */
.btn-icon {
  min-width: 36px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 16px;
  line-height: 1;
}

/* Read-only chip used in the edit-pilot dialog so Chrome's password manager
   can't silently overwrite the visible username. Looks like a disabled input. */
.readonly-chip {
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f0f0f0;
  color: #444;
  font-family: monospace;
  font-size: 14px;
}

/* Readability footprint controls on the flight replay modal — sits below the
   scrubber and stays out of the map's way. */
.replay-readable-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
  color: #444;
}
.replay-readable-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.replay-readable-row input[type="number"] {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}
