/* AlertAm – Clean White & Blue Design */

:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --primary-blue: #2563eb;
  --primary-blue-hover: #1d4ed8;
  --blue-light: #eff6ff;
  --blue-border: #bfdbfe;
  --text-heading: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --red-alert: #ef4444;
  --red-dark: #dc2626;
  --red-light: #fef2f2;
  --green-active: #16a34a;
  --green-light: #f0fdf4;
  --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.07), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --radius-card: 16px;
  --radius-btn: 10px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  background: var(--bg-app);
  color: var(--text-body);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

/* ─────────────────────────────────────────────
   SETUP WIZARD
───────────────────────────────────────────── */
.wizard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-height: 700px) {
  .wizard-overlay { align-items: center; padding: 20px; }
}

.wizard-card {
  background: #ffffff;
  border-radius: 24px 24px 0 0;
  padding: 32px 24px 40px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-height: 700px) {
  .wizard-card { border-radius: 24px; animation: fadeScaleIn 0.3s ease; }
}

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

@keyframes fadeScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wiz-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 4px;
}
.wiz-icon-wrap.blue { background: var(--blue-light); }
.wiz-icon-wrap.green { background: var(--green-light); }

.wiz-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-heading);
  text-align: center;
  letter-spacing: -0.4px;
}

.wiz-desc {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.wiz-step-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary-blue);
  text-align: center;
}

.wiz-btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.full-btn { width: 100%; margin-top: 8px; }

/* ─────────────────────────────────────────────
   MAIN APP LAYOUT
───────────────────────────────────────────── */
.app-layout {
  max-width: 580px;
  width: 100%;
  min-height: 100vh;
  flex-direction: column;
  background: var(--bg-app);
  position: relative;
}

.app-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 13px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-icon {
  width: 34px; height: 34px;
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.brand-title { font-size: 17px; font-weight: 800; color: var(--text-heading); letter-spacing: -0.4px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.status-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  background: var(--green-light); color: var(--green-active);
  border: 1px solid #bbf7d0;
}

.dot-green { width: 7px; height: 7px; background: var(--green-active); border-radius: 50%; }

.app-content {
  flex: 1;
  padding: 16px 16px 90px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-pane { display: none; flex-direction: column; gap: 16px; }
.tab-pane.active { display: flex; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────────
   CARDS
───────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card h2 {
  font-size: 17px; font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

.section-subtitle { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.section-title-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px; gap: 10px;
}

/* ─────────────────────────────────────────────
   ACTIVE ALERT BANNER
───────────────────────────────────────────── */
.active-alert-card {
  background: var(--red-light);
  border: 1px solid #fecaca;
  border-left: 4px solid var(--red-alert);
}

.alert-banner-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}

.alert-title-row {
  display: flex; align-items: center; gap: 8px;
  color: var(--red-dark); font-size: 13px; font-weight: 700;
}

.pulsing-badge {
  width: 9px; height: 9px;
  background: var(--red-alert);
  border-radius: 50%;
  animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
  100% { transform: scale(0.9); opacity: 1; }
}

.alert-desc { font-size: 12px; color: #7f1d1d; line-height: 1.4; }

/* ─────────────────────────────────────────────
   EMERGENCY HERO
───────────────────────────────────────────── */
.emergency-hero-card { text-align: center; padding: 28px 20px; }

.hero-header h2 { font-size: 20px; font-weight: 800; color: var(--text-heading); }
.hero-header p { font-size: 13px; color: var(--text-muted); max-width: 300px; margin: 4px auto 20px; line-height: 1.4; }

.panic-btn-container {
  display: flex; justify-content: center; align-items: center;
  margin: 8px 0 24px;
}

.panic-btn {
  width: 185px; height: 185px;
  border-radius: 50%; border: none;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white; cursor: pointer;
  box-shadow: 0 10px 30px -4px rgba(239, 68, 68, 0.45), 0 0 0 12px rgba(239, 68, 68, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  outline: none; position: relative; user-select: none; touch-action: none;
}

.panic-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 15px -2px rgba(239, 68, 68, 0.6), 0 0 0 6px rgba(239, 68, 68, 0.2);
}

.panic-btn-content { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.btn-main-text { font-size: 14px; font-weight: 800; letter-spacing: 0.5px; }
.btn-sub-text { font-size: 10px; font-weight: 700; opacity: 0.9; letter-spacing: 0.6px; }

/* Safe phrase */
.safe-phrase-box {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; text-align: left;
}

.safe-phrase-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--text-heading);
  margin-bottom: 8px;
}

.phrase-tag { color: var(--red-alert); font-size: 12px; font-weight: 700; font-style: italic; }

.phrase-input-group { display: flex; gap: 8px; margin-bottom: 6px; }

.field-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* Summary card */
.summary-card { display: flex; flex-direction: column; gap: 12px; }

.summary-item { display: flex; align-items: flex-start; gap: 12px; }
.summary-icon { font-size: 18px; line-height: 1.2; }
.summary-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.summary-value { font-size: 13px; font-weight: 600; color: var(--text-heading); margin-top: 1px; }

/* ─────────────────────────────────────────────
   LOCATION TAB
───────────────────────────────────────────── */
.gps-status-card {
  background: var(--blue-light); border: 1px solid var(--blue-border);
  color: var(--primary-blue); padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}

.dot-blue { width: 8px; height: 8px; background: var(--primary-blue); border-radius: 50%; }

.map-preview-container {
  width: 100%; height: 220px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
}

#miniMap { width: 100%; height: 100%; }

/* ─────────────────────────────────────────────
   SETTINGS / PERMISSIONS
───────────────────────────────────────────── */
.perm-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
}

.perm-item--inline { padding: 8px 0; }

.perm-icon { font-size: 22px; flex-shrink: 0; }

.perm-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.perm-body strong { font-size: 14px; color: var(--text-heading); font-weight: 700; }
.perm-body span { font-size: 12px; color: var(--text-muted); }

.perm-btn {
  background: var(--primary-blue); color: white;
  border: none; padding: 7px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  flex-shrink: 0; transition: background 0.15s;
}

.perm-btn:hover { background: var(--primary-blue-hover); }

.perm-btn--done {
  background: var(--green-light); color: var(--green-active);
  border: 1px solid #bbf7d0;
}

/* Device toggles */
.device-toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.device-info { flex: 1; }
.device-title-row { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-heading); margin-bottom: 2px; }
.device-icon { font-size: 16px; }
.device-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1; transition: .3s; border-radius: 28px;
}

.toggle-slider:before {
  position: absolute; content: "";
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background: white; transition: .3s;
  border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider { background: var(--primary-blue); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

.divider { border: none; height: 1px; background: var(--border); margin: 10px 0; }

/* ─────────────────────────────────────────────
   FORMS
───────────────────────────────────────────── */
.form-block { display: flex; flex-direction: column; gap: 6px; }

.input-label { font-size: 13px; font-weight: 600; color: var(--text-heading); }

.clean-input {
  width: 100%; background: #fff;
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: 14px;
  color: var(--text-heading); font-family: inherit;
  outline: none; transition: border-color 0.2s;
}

.clean-input:focus { border-color: var(--border-focus); }

.form-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ─────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────── */
.btn-primary {
  background: var(--primary-blue); color: white;
  border: none; padding: 11px 22px; border-radius: var(--radius-btn);
  font-weight: 700; font-size: 14px; cursor: pointer;
  font-family: inherit; transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-blue-hover); }

.btn-primary-sm {
  background: var(--primary-blue); color: white;
  border: none; padding: 5px 12px; border-radius: 6px;
  font-weight: 600; font-size: 12px; cursor: pointer; font-family: inherit;
}

.btn-blue-outline {
  background: #fff; color: var(--primary-blue);
  border: 1.5px solid var(--primary-blue);
  padding: 8px 14px; border-radius: var(--radius-btn);
  font-weight: 600; font-size: 13px; cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}

.btn-blue-outline:hover { background: var(--blue-light); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn-ghost {
  background: none; border: none; color: var(--text-muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; font-family: inherit;
}

.btn-ghost:hover { color: var(--text-body); }

/* ─────────────────────────────────────────────
   BOTTOM NAV
───────────────────────────────────────────── */
.app-bottom-nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%); max-width: 580px; width: 100%;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  box-shadow: 0 -4px 15px rgba(0,0,0,0.04); z-index: 100;
}

.nav-item {
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-muted); cursor: pointer;
  padding: 4px 18px; border-radius: 8px;
  font-size: 11px; font-weight: 600; font-family: inherit;
  transition: color 0.15s;
}

.nav-item svg { stroke: var(--text-muted); transition: stroke 0.15s; }
.nav-item.active { color: var(--primary-blue); }
.nav-item.active svg { stroke: var(--primary-blue); }

/* ─────────────────────────────────────────────
   TOAST
───────────────────────────────────────────── */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #0f172a; color: white;
  padding: 10px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999; white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ─────────────────────────────────────────────
   STOP ALARM & RESET BUTTONS
───────────────────────────────────────────── */
.btn-stop-alarm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.28);
  transition: all 0.2s ease;
  font-family: inherit;
}
.btn-stop-alarm:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}
.btn-stop-alarm:active {
  transform: scale(0.98);
}

.btn-danger-sm {
  padding: 6px 12px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.btn-danger-sm:hover {
  background: #b91c1c;
}

.panic-btn.panic-btn--active {
  background: #dc2626 !important;
  box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.2), 0 12px 32px rgba(220, 38, 38, 0.4) !important;
}
