/* =========================================================
   ProTect EAP — Emergency Action Planner
   Design System & App CSS
   ========================================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- CSS Custom Properties --- */
:root {
  --bg-primary:    #0F1923;
  --bg-surface:    #1A2535;
  --bg-card:       #1E2D40;
  --bg-input:      #243347;
  --accent:        #FF6B35;
  --accent-dark:   #CC5525;
  --accent-glow:   rgba(255,107,53,0.15);
  --success:       #22C55E;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;
  --text-primary:  #F0F4F8;
  --text-secondary:#94A3B8;
  --text-muted:    #64748B;
  --border:        rgba(255,255,255,0.08);
  --border-focus:  rgba(255,107,53,0.5);
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-xl:     24px;
  --shadow-card:   0 4px 24px rgba(0,0,0,0.3);
  --shadow-glow:   0 0 20px rgba(255,107,53,0.2);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --nav-h:         64px;
  --bottom-nav-h:  72px;
  --transition:    0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- App Shell --- */
#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Top Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(15,25,35,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: white;
}

.app-header .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.app-header .logo-text span {
  color: var(--accent);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--warning); box-shadow: 0 0 6px var(--warning); }

/* --- Main Content --- */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--bottom-nav-h) + 16px);
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: rgba(26,37,53,0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  padding: 8px 4px;
  transition: color var(--transition);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

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

.nav-item.active {
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

/* ---- Emergency FAB ---- */
.emergency-fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--danger);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(239,68,68,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.emergency-fab:active { transform: scale(0.94); }

/* --- Screens (tab panels) --- */
.screen { display: none; padding: 16px; }
.screen.active { display: block; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Form Elements --- */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }

/* --- Chip Selectors --- */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.chip:hover, .chip.selected {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.chip.danger.selected {
  background: rgba(239,68,68,0.15);
  border-color: var(--danger);
  color: var(--danger);
}

.chip.warning.selected {
  background: rgba(245,158,11,0.15);
  border-color: var(--warning);
  color: var(--warning);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}
.btn-primary:active { background: var(--accent-dark); transform: scale(0.98); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-danger {
  background: var(--danger);
  color: white;
  width: 100%;
}

.btn-ghost {
  background: rgba(0, 0, 0, 0.02); /* Ensures the entire box is clickable */
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* --- Onboarding Screen --- */
#screen-onboarding {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}

.onboarding-hero {
  background: linear-gradient(135deg, #0F1923 0%, #1A2535 100%);
  padding: 60px 24px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.onboarding-logo {
  width: 80px;
  height: 80px;
  background: var(--accent);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 24px;
  box-shadow: var(--shadow-glow);
}

.onboarding-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.onboarding-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.onboarding-body { padding: 32px 24px; flex: 1; }

.disclaimer-box {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.disclaimer-box strong {
  color: var(--danger);
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

/* --- Active Event Banner --- */
.event-banner {
  background: linear-gradient(90deg, rgba(255,107,53,0.15), rgba(255,107,53,0.05));
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  cursor: pointer;
}

.event-banner-info { flex: 1; }
.event-banner-label { font-size: 11px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }
.event-banner-value { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.event-banner-arrow { color: var(--accent); font-size: 18px; }

/* --- EAP Card --- */
.eap-card {
  background: linear-gradient(135deg, #1E2D40, #243347);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.eap-card-header {
  background: var(--accent);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.eap-role-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.eap-role-row:last-child { border-bottom: none; }

.eap-role-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.eap-role-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.eap-role-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.action-btn.call { border-color: var(--success); color: var(--success); }
.action-btn.sms  { border-color: var(--info);    color: var(--info); }
.action-btn:active { transform: scale(0.9); }

/* --- Section header --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.section-badge {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 100px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* --- Incident type selector --- */
.incident-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.incident-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.incident-type-btn .type-icon { font-size: 32px; }

.incident-type-btn.selected-injury {
  border-color: var(--danger);
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.incident-type-btn.selected-nearmiss {
  border-color: var(--warning);
  background: rgba(245,158,11,0.1);
  color: var(--warning);
}

/* --- Toast notification --- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 80px);
  left: 16px;
  right: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  z-index: 200;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }

/* --- Progress steps --- */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--transition);
}
.step-dot.active   { background: var(--accent); transform: scale(1.3); }
.step-dot.complete { background: var(--success); }

/* --- Utility --- */
.text-muted    { color: var(--text-muted); font-size: 13px; }
.text-accent   { color: var(--accent); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* --- Responsive desktop adjustments --- */
@media (min-width: 768px) {
  .app-content { max-width: 640px; margin: 0 auto; }
  .bottom-nav  { max-width: 640px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .emergency-fab { right: calc(50% - 320px + 16px); }
  .screen { padding: 24px; }
}

/* --- Feedback --- */
.feedback-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 999;
}

.feedback-fab {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.2s;
}

/* ── SOS Siren ── */
@keyframes flash-red {
  0% { background-color: rgba(255,0,0,0.9); }
  50% { background-color: rgba(0,0,0,0.8); }
  100% { background-color: rgba(255,0,0,0.9); }
}
.sos-flashing {
  animation: flash-red 1s infinite;
}


/* --- Modals & Overlays --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 25, 35, 0.85);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 1;
  transition: opacity var(--transition);
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-card);
  transform: translateY(0);
  transition: transform var(--transition);
}
.modal-overlay.hidden .modal-content {
  transform: translateY(20px);
}
