/* ARC-GNY DAT Companion v2 — mobile-first dark theme */

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

:root {
  --bg: #1a1a2e;
  --bg-card: #232340;
  --bg-card-alt: #2a2a4a;
  --text: #e8e8f0;
  --text-dim: #9898b0;
  --accent: #e74c3c;
  --accent-dim: #c0392b;
  --green: #2ecc71;
  --amber: #d4a843;
  --blue: #42a5f5;
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  min-height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* --- Header --- */

#header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 12px 16px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--accent);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.freshness {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(46,204,113,0.15);
  color: var(--green);
}

.freshness.stale {
  background: rgba(231,76,60,0.15);
  color: var(--accent);
}

.app-version {
  font-size: 10px;
  color: #555;
  font-family: 'SF Mono', 'Menlo', monospace;
  margin-left: 6px;
  align-self: flex-end;
  margin-bottom: 1px;
}

.countdown {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Menlo', monospace;
}

.countdown-expired {
  color: var(--accent);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

/* --- Filter bar --- */

.filter-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.filter-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #444;
  background: transparent;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}

.filter-chip.filter-active {
  background: rgba(231,76,60,0.2);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Main content --- */

main {
  padding: 8px 12px 24px;
}

/* --- Command card (RM / DPMOC) --- */

.command-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.command-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.command-row + .command-row {
  border-top: 1px solid rgba(255,255,255,0.06);
}

.command-role {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  min-width: 32px;
  text-transform: uppercase;
}

.command-info {
  flex: 1;
  min-width: 0;
}

.command-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-hours {
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Call button --- */

.btn-call {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(46,204,113,0.15);
  text-decoration: none;
  font-size: 20px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.btn-call:active {
  background: rgba(46,204,113,0.3);
}

/* --- Sections --- */

.section {
  margin-bottom: 16px;
}

.section h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 4px;
}

/* --- Event cards --- */

.event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
}

.event-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.event-id {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Menlo', monospace;
}

.event-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
}

.event-type {
  font-size: 10px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(66,165,245,0.12);
  padding: 1px 5px;
  border-radius: 3px;
}

.event-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}

.event-address {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.event-client {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.client-phone {
  color: var(--green);
  text-decoration: none;
  font-weight: 500;
}

.event-summary {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.event-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.btn-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(66,165,245,0.1);
  -webkit-tap-highlight-color: transparent;
}

.btn-action:active {
  background: rgba(66,165,245,0.25);
}

.btn-action.btn-small {
  font-size: 11px;
  padding: 3px 8px;
}

/* --- Tally chip --- */

.tally-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--amber);
  background: rgba(212,168,67,0.12);
  padding: 3px 8px;
  border-radius: 6px;
  margin: 4px 0;
  display: inline-block;
}

/* --- Responder chips --- */

.resp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.resp-chip {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-card-alt);
  border-left: 2px solid #555;
}

.resp-role {
  color: var(--text-dim);
  font-size: 10px;
}

/* --- Expand/Collapse details --- */

.event-expand-trigger {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

.expand-arrow {
  font-size: 10px;
  display: inline-block;
  transition: transform 0.15s;
}

.event-expand-body.hidden {
  display: none;
}

.event-expand-body {
  padding: 6px 0;
}

/* --- Apartment DA Grid --- */

.da-grid {
  font-size: 11px;
  margin: 6px 0;
  overflow-x: auto;
}

.da-grid-header {
  display: flex;
  gap: 2px;
  margin-bottom: 2px;
}

.da-grid-header .da-cell {
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
}

.da-grid-row {
  display: flex;
  gap: 2px;
  margin-bottom: 1px;
}

.da-cell {
  min-width: 44px;
  padding: 1px 3px;
}

.da-cell:first-child {
  min-width: 24px;
  max-width: 32px;
}

.da-fl {
  color: #889;
  font-weight: 600;
}

.da-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  margin: 1px;
}

.da-des { background: rgba(244,67,54,0.25); color: #f44336; }
.da-maj { background: rgba(255,152,0,0.25); color: #ff9800; }
.da-min { background: rgba(255,235,59,0.2); color: #fdd835; }
.da-aff { background: rgba(66,165,245,0.2); color: #42a5f5; }
.da-nvd { background: rgba(150,150,170,0.15); color: #999; }

/* --- Lodging details --- */

.lodging-details {
  margin: 6px 0;
}

.lodging-row {
  background: var(--bg-card-alt);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 4px;
}

.lodging-hotel {
  font-size: 13px;
  font-weight: 600;
}

.lodging-checkout {
  font-size: 11px;
  color: var(--amber);
}

.lodging-units {
  font-size: 11px;
  color: var(--text-dim);
  margin: 2px 0;
}

/* --- Roster --- */

.roster-group {
  margin-bottom: 10px;
}

.roster-group h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 4px;
  margin-bottom: 2px;
}

.roster-row {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.roster-info {
  flex: 1;
  min-width: 0;
}

.roster-name {
  display: block;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-hours {
  font-size: 12px;
  color: var(--text-dim);
}

.roster-id {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Menlo', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Resources --- */

.resource-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.resource-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--bg-card);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.resource-btn span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}

.resource-btn:active {
  background: var(--bg-card-alt);
}

/* --- QR Scanner overlay --- */

.scanner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  flex-direction: column;
}

.scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}

.scanner-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

/* --- Utility --- */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 20px 0;
}

.full-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.scan-prompt {
  text-align: center;
  max-width: 280px;
}

.scan-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.scan-prompt h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.scan-prompt p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
  background: var(--accent-dim);
}

.hidden {
  display: none;
}

/* --- Spinner --- */

.loading {
  text-align: center;
}

.loading p {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

/* --- Prevent overscroll bounce on iOS --- */
@media (display-mode: standalone) {
  body {
    overscroll-behavior: none;
  }
}
