/* Frontline Response, shared styles */

:root {
  --navy: #0E1B2C;
  --navy-2: #16283F;
  --navy-3: #1E3450;
  --white: #FFFFFF;
  --paper: #F4F6F9;
  --ink: #14202E;
  --ink-soft: #4B5A6B;
  --line: #DDE3EA;
  --red: #E8352E;
  --red-dark: #C2241E;
  --amber: #F5A623;
  --amber-dark: #B87500;
  --green: #1FA05A;
  --green-dark: #157A44;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 24px rgba(14, 27, 44, 0.12);
  --shadow-sm: 0 2px 8px rgba(14, 27, 44, 0.08);
  --tap: 52px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; }

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 96px;
}
.container-wide {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* Header */
.app-header {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}
.app-header-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.container-wide + .app-header-inner,
.app-header.wide .app-header-inner { max-width: 1080px; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--red), var(--red-dark));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { font-size: 17px; }
.brand-sub { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.65); margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--white);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
}
.header-btn:hover { background: rgba(255,255,255,0.18); }
.pill-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
}

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  padding: 18px;
  margin-top: 16px;
}
.card h2, .card h3 { margin-top: 0; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-red { background: var(--red); color: var(--white); }
.btn-red:hover { filter: brightness(1.08); }
.btn-green { background: var(--green); color: var(--white); }
.btn-amber { background: var(--amber); color: var(--navy); }
.btn-outline { background: var(--white); color: var(--navy); border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 14px; width: auto; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(14,27,44,0.12);
}
.help-text { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }
.error-text { font-size: 13px; color: var(--red-dark); font-weight: 600; margin-top: 8px; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--paper);
  border-radius: 10px;
  border: 1.5px solid var(--line);
}
.checkbox-row input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }
.checkbox-row label { font-size: 14px; font-weight: 500; color: var(--ink); }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--white);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}
.chip.active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* Severity picker */
.severity-row { display: flex; gap: 8px; }
.severity-btn {
  flex: 1;
  padding: 12px 6px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--white);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-height: 48px;
}
.severity-btn.active[data-sev="minor"] { background: #FFF4E4; border-color: var(--amber); color: var(--amber-dark); }
.severity-btn.active[data-sev="moderate"] { background: #FFE9E4; border-color: var(--red); color: var(--red-dark); }
.severity-btn.active[data-sev="severe"] { background: var(--red); border-color: var(--red); color: var(--white); }

/* Status colors */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-new, .status-acknowledged { background: #FFE9E4; color: var(--red-dark); }
.status-accepted, .status-enroute { background: #FFF4E0; color: var(--amber-dark); }
.status-onsite { background: #E4F3EC; color: var(--green-dark); }
.status-resolved { background: #E4F3EC; color: var(--green-dark); }
.status-cancelled { background: #EAEDF1; color: var(--ink-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Danger banner */
.danger-banner {
  background: var(--red);
  color: var(--white);
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* The red button */
.hold-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px;
  margin-top: 16px;
}
.hold-btn {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  box-shadow: 0 12px 32px rgba(232, 53, 46, 0.4);
}
.hold-btn svg.ring {
  position: absolute;
  top: 0; left: 0; width: 200px; height: 200px;
  transform: rotate(-90deg);
  pointer-events: none;
}
.hold-btn svg.ring circle {
  fill: none;
  stroke: rgba(255,255,255,0.85);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 578;
  stroke-dashoffset: 578;
  transition: stroke-dashoffset 0.05s linear;
}
.hold-btn .hold-label {
  position: relative;
  z-index: 2;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  padding: 0 24px;
  line-height: 1.3;
}
.hold-btn.arming { animation: pulse-arm 0.9s ease-in-out infinite; }
.hold-btn.armed-flash { animation: flash-armed 0.35s ease; }
@keyframes pulse-arm {
  0%, 100% { box-shadow: 0 12px 32px rgba(232, 53, 46, 0.4); }
  50% { box-shadow: 0 12px 40px rgba(232, 53, 46, 0.65); }
}
@keyframes flash-armed {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.hold-caption { margin-top: 16px; font-size: 13px; color: var(--ink-soft); text-align: center; max-width: 280px; }

/* Tier cards */
.tier-grid { display: flex; flex-direction: column; gap: 12px; }
.tier-card {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  background: var(--white);
  text-align: left;
}
.tier-card.selected { border-color: var(--navy); background: #F0F3F8; }
.tier-card.selected.priority { border-color: var(--red); background: #FFF1F0; }
.tier-card h3 { margin: 0 0 6px; font-size: 16px; }
.tier-card p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.tier-fee { font-size: 20px; font-weight: 800; color: var(--red-dark); margin-top: 8px; }

/* Sticky bottom bar */
.sticky-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(14,27,44,0.08);
  z-index: 30;
}
.sticky-bar-inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }
.sticky-bar-inner.wide { max-width: 1080px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 20px 26px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
}
.timeline li:last-child { border-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--line);
  border: 2px solid var(--white);
}
.timeline li.done::before { background: var(--green); }
.timeline li.now::before { background: var(--red); box-shadow: 0 0 0 4px rgba(232,53,46,0.18); }
.timeline .t-label { font-weight: 700; font-size: 14px; }
.timeline .t-time { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* Media thread */
.thread { display: flex; flex-direction: column; gap: 12px; }
.thread-item { display: flex; gap: 10px; }
.thread-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--navy); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.thread-item.team .thread-avatar { background: var(--green-dark); }
.thread-body { flex: 1; }
.thread-meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; }
.thread-text { font-size: 14px; background: var(--paper); padding: 10px 12px; border-radius: 10px; }
.thread-media img, .thread-media video { border-radius: 10px; margin-top: 6px; max-height: 240px; width: auto; }

/* Contacts */
.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.contact-row:last-child { border-bottom: none; }
.contact-name { font-weight: 700; font-size: 14px; }
.contact-role { font-size: 12.5px; color: var(--ink-soft); }
.call-btn {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  min-height: 40px;
  text-decoration: none;
  color: var(--navy);
  flex-shrink: 0;
}

/* Login screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 18px;
  padding: 32px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; text-align: center; }
.login-brand .brand-mark { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 12px; }
.login-brand .brand-mark svg { width: 30px; height: 30px; }
.login-brand h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -0.01em; }
.login-brand p { margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.role-switch { display: flex; gap: 6px; margin-bottom: 20px; background: var(--paper); padding: 4px; border-radius: 10px; }
.role-switch a {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink-soft);
}
.role-switch a.active { background: var(--white); color: var(--navy); box-shadow: var(--shadow-sm); }

/* Empty / loading states */
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .big-icon { font-size: 40px; margin-bottom: 10px; }
.loading-line { color: var(--ink-soft); font-size: 14px; padding: 20px 0; text-align: center; }

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90%;
  text-align: center;
}

/* Map */
.map-box { height: 280px; border-radius: var(--radius); overflow: hidden; margin-top: 12px; border: 1px solid var(--line); }
.eta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  margin-top: 12px;
}
.eta-strip .eta-big { font-size: 18px; font-weight: 800; }
.eta-strip .eta-small { font-size: 11px; color: rgba(255,255,255,0.7); text-transform: uppercase; letter-spacing: 0.04em; }

/* Alert cards on team dashboard */
.alert-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  padding: 16px;
  margin-top: 12px;
  cursor: pointer;
  display: block;
  text-decoration: none;
  color: inherit;
}
.alert-card.new-pulse {
  border-color: var(--red);
  animation: card-pulse 1.4s ease-in-out infinite;
}
@keyframes card-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,53,46,0.35); }
  50% { box-shadow: 0 0 0 8px rgba(232,53,46,0); }
}
.alert-card.escalated { background: #FFF1F0; }
.alert-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.alert-card h3 { margin: 0; font-size: 15.5px; }
.alert-card .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.tier-flag {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--red);
  color: white;
}
.tier-flag.standard { background: var(--navy-3); }

/* Tabs */
.tabbar { display: flex; gap: 4px; background: var(--paper); padding: 4px; border-radius: 10px; margin-top: 16px; }
.tabbar button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink-soft);
  min-height: 40px;
}
.tabbar button.active { background: var(--white); color: var(--navy); box-shadow: var(--shadow-sm); }

/* Tables (admin) */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.data-table th, table.data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.data-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
table.data-table tr:hover td { background: var(--paper); }

/* Grid layout helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

/* Accessibility widget */
.a11y-toggle {
  position: fixed;
  right: 16px;
  bottom: 96px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  border: none;
  box-shadow: var(--shadow);
  font-size: 22px;
  cursor: pointer;
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
}
.a11y-panel {
  position: fixed;
  right: 16px;
  bottom: 156px;
  width: 240px;
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 14px;
  z-index: 91;
  display: none;
}
.a11y-panel.open { display: block; }
.a11y-panel h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
.a11y-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.a11y-row:last-child { border-bottom: none; }
.a11y-switch { width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; border: none; cursor: pointer; }
.a11y-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: white; border-radius: 50%; transition: transform 0.15s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.a11y-switch.on { background: var(--green); }
.a11y-switch.on::after { transform: translateX(16px); }

html.a11y-large { font-size: 18px; }
html.a11y-contrast body { background: #000; color: #fff; }
html.a11y-contrast .card, html.a11y-contrast .login-card { background: #111; border-color: #444; color: #fff; }
html.a11y-contrast .field input, html.a11y-contrast .field select, html.a11y-contrast .field textarea { background: #111; color: #fff; border-color: #555; }
html.a11y-underline a { text-decoration: underline !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Utility */
.muted { color: var(--ink-soft); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge-count {
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}
hr.divider { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.small-note { font-size: 12px; color: var(--ink-soft); }
