/* SOS Platform - Ultra-light Mobile-First CSS (Optimized for iPhone 13 / iOS Safari) */
:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  --police-color: #ef4444;
  --police-bg: rgba(239, 68, 68, 0.12);
  --police-border: rgba(239, 68, 68, 0.4);

  --medical-color: #0ea5e9;
  --medical-bg: rgba(14, 165, 233, 0.12);
  --medical-border: rgba(14, 165, 233, 0.4);

  --rescue-color: #8b5cf6;
  --rescue-bg: rgba(139, 92, 246, 0.12);
  --rescue-border: rgba(139, 92, 246, 0.4);
}

body.oled-mode {
  --bg-primary: #000000;
  --bg-card: #0a0a0a;
  --border-color: #222222;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.4;
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 16px));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 440px;
  margin: 0 auto;
  padding: 8px 12px;
}

/* Header - Ultra compact 1 row */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 8px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
}

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

.brand-logo {
  font-size: 20px;
  line-height: 1;
}

.brand-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.3px;
  white-space: nowrap;
  background: linear-gradient(135deg, #ef4444, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 10px;
  background: #334155;
  color: #38bdf8;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
}

/* Quick Tools Bar */
.quick-tools {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.tool-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.tool-btn.active {
  background: #ef4444;
  color: #fff;
  border-color: #dc2626;
}

/* Location Banner - Streamlined 2-Row Layout */
.location-banner {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.location-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.location-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.loc-pin {
  font-size: 16px;
  flex-shrink: 0;
}

.location-value {
  font-size: 14px;
  font-weight: 800;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-distance {
  font-size: 11px;
  color: #38bdf8;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.location-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid rgba(51, 65, 85, 0.6);
}

.location-coords {
  font-size: 11px;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.loc-btn {
  background: #0f172a;
  border: 1px solid #475569;
  color: #f8fafc;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
}

.loc-btn-primary {
  background: #0284c7;
  border-color: #0284c7;
}

/* Sleek Province Selector Bar */
.province-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 4px 8px;
}

.province-bar label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 700;
  white-space: nowrap;
}

.province-bar select {
  flex: 1;
  background: transparent;
  color: #f8fafc;
  border: none;
  font-size: 12px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

/* 3 Main Action Cards - Compact Height for Mobile Screens */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.action-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.action-card.police {
  border-color: var(--police-border);
  background: linear-gradient(180deg, var(--police-bg) 0%, var(--bg-card) 70%);
}

.action-card.medical {
  border-color: var(--medical-border);
  background: linear-gradient(180deg, var(--medical-bg) 0%, var(--bg-card) 70%);
}

.action-card.rescue {
  border-color: var(--rescue-border);
  background: linear-gradient(180deg, var(--rescue-bg) 0%, var(--bg-card) 70%);
}

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

.card-title-group {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.card-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.police .card-icon { background: rgba(239, 68, 68, 0.25); }
.medical .card-icon { background: rgba(14, 165, 233, 0.25); }
.rescue .card-icon { background: rgba(139, 92, 246, 0.25); }

.card-title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.police .card-title { color: #f87171; }
.medical .card-title { color: #38bdf8; }
.rescue .card-title { color: #a78bfa; }

.line-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid #334155;
  color: #cbd5e1;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Contact Display Box */
.contact-box {
  background: #0f172a;
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

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

.contact-name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-phone-display {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.2;
}

/* Dual Action Buttons */
.card-buttons {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: transform 0.1s ease;
}

.btn-action:active {
  transform: scale(0.97);
}

.btn-call {
  color: #ffffff;
}

.police .btn-call { background: #dc2626; box-shadow: 0 3px 10px rgba(220, 38, 38, 0.4); }
.medical .btn-call { background: #0284c7; box-shadow: 0 3px 10px rgba(2, 132, 199, 0.4); }
.rescue .btn-call { background: #7c3aed; box-shadow: 0 3px 10px rgba(124, 58, 237, 0.4); }

.btn-sms {
  background: #1e293b;
  border: 1px solid #475569;
  color: #f1f5f9;
}

/* Fallback Switch Banner */
.fallback-banner {
  margin-top: 6px;
  padding: 5px 8px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  border: 1px dashed #475569;
}

.fallback-text {
  color: #fbbf24;
  font-weight: 700;
  font-size: 11px;
}

.btn-switch-line {
  background: #334155;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  max-width: 68%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom Emergency Utilities Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #334155;
  display: flex;
  justify-content: space-around;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 8px)) 10px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.nav-item.active {
  color: #ef4444;
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

/* Telemetry Feedback Sheet */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}

.modal-sheet {
  background: #1e293b;
  border-radius: 20px 20px 0 0;
  border-top: 2px solid #475569;
  width: 100%;
  max-width: 440px;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom, 12px)) 14px;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}

.sheet-desc {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 12px;
}

.feedback-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-feedback {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f1f5f9;
  cursor: pointer;
  text-align: left;
}

.btn-feedback.success { border-color: #10b981; color: #34d399; }
.btn-feedback.busy { border-color: #f59e0b; color: #fbbf24; }
.btn-feedback.wrong { border-color: #ef4444; color: #f87171; }

/* Strobe Screen for Night Distress */
#strobe-screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: #fff;
  cursor: pointer;
}

/* Offline badge */
.offline-indicator {
  display: none;
  background: #f59e0b;
  color: #000;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  padding: 3px;
}

body.is-offline .offline-indicator {
  display: block;
}
