/**
 * Iron Route GPS — UI Fixes P0/P1/P2 Styles
 * 2026-05-03 — paired with js/ui-fixes-p0.js
 */

/* =========================================================
 * TOAST (singleton) — replaces dual systems visually
 * ========================================================= */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10003;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  pointer-events: auto;
  background: rgba(15, 18, 24, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s ease;
  letter-spacing: 0.1px;
  max-width: 92vw;
  text-align: center;
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast.removing { opacity: 0; transform: translateY(8px); }
.toast.toast-success { background: rgba(34, 153, 84, 0.92); }
.toast.toast-error   { background: rgba(176, 35, 35, 0.92); }
.toast.toast-warning { background: rgba(176, 116, 35, 0.92); }
.toast.toast-info    { background: rgba(15, 18, 24, 0.92); }

/* Hide the legacy permissions-flow .ir-toast — we intercept and re-route via singleton */
.ir-toast { display: none !important; }

/* =========================================================
 * LOCATE BUTTON SPINNER
 * ========================================================= */
.map-ctrl-btn .ir-spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(0,0,0,0.18);
  border-top-color: var(--accent, #d4a84b);
  animation: ir-spin 0.85s linear infinite;
  display: inline-block;
}
.map-ctrl-btn.locating { pointer-events: none; opacity: 0.85; }
@keyframes ir-spin { to { transform: rotate(360deg); } }

/* =========================================================
 * QUICK ACTIONS — desktop arrows
 * ========================================================= */
.qa-arrow {
  position: absolute;
  top: 50%;
  width: 36px; height: 36px;
  background: var(--glass, rgba(255,255,255,0.85));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(0,0,0,0.08));
  border-radius: 50%;
  color: var(--text, #1a1a1a);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 12;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  transform: translateY(-50%);
  transition: transform .15s ease, background .15s ease;
}
.qa-arrow:hover { background: var(--accent, #d4a84b); color: #051d2c; }
.qa-arrow:active { transform: translateY(-50%) scale(0.92); }
.qa-arrow-left  { left: 4px; }
.qa-arrow-right { right: 4px; }

/* hide arrows on touch devices */
@media (hover: none) and (pointer: coarse) {
  .qa-arrow { display: none !important; }
}

/* =========================================================
 * FAB COLLAPSE TOGGLE + collapsed state
 * ========================================================= */
.fab-collapse-toggle {
  position: fixed;
  right: 12px;
  bottom: calc(var(--nav-height, 64px) + var(--safe-bottom, 0px) + 350px);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--glass, rgba(255,255,255,0.85));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(0,0,0,0.08));
  color: var(--text, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 902;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform .25s ease;
}
.fab-collapse-toggle.is-collapsed { transform: rotate(180deg); }
.fab-collapse-toggle:hover { background: var(--accent, #d4a84b); color: #051d2c; }

.map-controls.collapsed { transform: scale(0); opacity: 0; pointer-events: none; transform-origin: bottom right; }
.map-controls { transition: transform .25s ease, opacity .25s ease; transform-origin: bottom right; }

/* =========================================================
 * REPORT-ALERT MODAL
 * ========================================================= */
.ir-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 10010;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.ir-modal-card {
  background: var(--bg-surface, #fff);
  color: var(--text, #1a1a1a);
  width: 100%; max-width: 420px;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.ir-modal-card h3 { margin: 0 0 14px; font-size: 18px; font-weight: 700; }
.ir-alert-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.ir-alert-chip {
  background: var(--glass, rgba(0,0,0,0.04));
  border: 1px solid var(--glass-border, rgba(0,0,0,0.08));
  border-radius: 12px;
  padding: 14px 10px;
  font-weight: 600;
  text-align: center;
  color: var(--text, #1a1a1a);
  cursor: pointer;
  font-size: 14px;
  min-height: 48px;
}
.ir-alert-chip:hover { background: var(--accent-dim, rgba(212,168,75,0.18)); border-color: var(--accent, #d4a84b); }
.ir-modal-close {
  width: 100%;
  background: transparent;
  color: var(--text-muted, #6b7280);
  border: 1px solid var(--glass-border, rgba(0,0,0,0.08));
  border-radius: 10px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* =========================================================
 * RESPONSIVE BREAKPOINTS — xs/sm/md/lg/xl
 * ========================================================= */

/* xs <480 — phone portrait */
@media (max-width: 479px) {
  .search-container { width: calc(100% - 16px); }
  .map-ctrl-btn { width: 40px; height: 40px; }
  .fab { height: 44px; padding: 0 14px 0 10px; font-size: 12px; }
  .tile { min-width: 76px; padding: 10px 10px; }
  .tile-icon { width: 36px; height: 36px; }
  .qa-arrow { display: none !important; }
  .fab-collapse-toggle { right: 8px; bottom: calc(var(--nav-height, 64px) + var(--safe-bottom, 0px) + 320px); }
}

/* sm 480-767 — phablet */
@media (min-width: 480px) and (max-width: 767px) {
  .search-container { max-width: 92%; }
  .map-ctrl-btn { width: 44px; height: 44px; }
  .fab { height: 48px; }
}

/* md 768-1023 — tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .search-container { max-width: 600px; margin-left: auto; margin-right: auto; }
  .map-ctrl-btn { width: 48px; height: 48px; }
  .fab { height: 52px; }
}

/* lg 1024-1439 — laptop */
@media (min-width: 1024px) and (max-width: 1439px) {
  .search-container { max-width: 700px; }
  .map-ctrl-btn { width: 50px; height: 50px; }
  .fab { height: 54px; }
}

/* xl >=1440 — desktop */
@media (min-width: 1440px) {
  .search-container { max-width: 760px; }
  .map-ctrl-btn { width: 52px; height: 52px; }
  .fab { height: 56px; }
}

/* Map viewport — make sure container fills available space and never collapses */
#map.map-container, .map-container { min-height: 240px; }
.map-wrapper { min-height: 240px; }

/* Prevent horizontal overflow at all widths */
html, body { overflow-x: hidden; max-width: 100%; }

/* Touch target minimum on every breakpoint */
button, .tile, .map-ctrl-btn, .fab, .nav-tab, .menu-item { min-height: 44px; }
@media (pointer: coarse) {
  button, .tile, .map-ctrl-btn, .fab, .nav-tab, .menu-item { min-height: 48px; }
}
