/* SturzWächter App CSS - Senior-Friendly, Touch-Optimized */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0a0e27;
  --bg-card: #111936;
  --bg-input: #1a2340;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --red: #ef4444;
  --green: #10b981;
  --blue: #3b82f6;
  --yellow: #f59e0b;
  --purple: #8b5cf6;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 18px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* AUTH SCREEN */
#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 30px 20px;
}

.auth-logo { font-size: 48px; margin-bottom: 8px; }
.auth-title { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 16px; }

.auth-form {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 15px; font-weight: 600; color: var(--text-muted); }

input, select, textarea {
  background: var(--bg-input);
  border: 2px solid #2a3560;
  border-radius: 12px;
  color: var(--text);
  padding: 16px;
  font-size: 18px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }

/* BUTTONS */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 18px 24px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, opacity 0.2s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-start { background: var(--green); color: #fff; font-size: 22px; }
.btn-stop { background: var(--red); color: #fff; font-size: 22px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 2px solid #2a3560; }
.btn-small { padding: 12px 16px; font-size: 16px; min-height: 44px; }
.btn-icon { background: none; border: none; font-size: 24px; cursor: pointer; padding: 8px; min-width: 48px; min-height: 48px; display: flex; align-items: center; justify-content: center; }

.auth-toggle { text-align: center; color: var(--text-muted); font-size: 15px; margin-top: 10px; }
.auth-toggle a { color: var(--blue); text-decoration: none; font-weight: 600; }

/* APP MAIN */
#app-main {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  padding: 20px 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
  overflow-y: auto;
}

.tab-content { display: none; }

/* BOTTOM TABS */
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0d1230;
  display: flex;
  border-top: 1px solid #1e293b;
  padding-bottom: var(--safe-bottom);
  z-index: 1000;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 60px;
  transition: color 0.2s;
}
.tab-btn .tab-icon { font-size: 24px; }
.tab-btn.active { color: var(--blue); }
.tab-btn.active .tab-icon { transform: scale(1.1); }

/* STATUS CIRCLE */
.status-section { text-align: center; padding: 20px 0; }

.status-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  transition: all 0.5s;
}

.status-circle.active {
  background: radial-gradient(circle, rgba(16,185,129,0.2) 0%, rgba(16,185,129,0.05) 70%);
  border: 4px solid var(--green);
  box-shadow: 0 0 40px rgba(16,185,129,0.3), 0 0 80px rgba(16,185,129,0.1);
  animation: pulseGreen 2s infinite;
}

.status-circle.inactive {
  background: rgba(148,163,184,0.1);
  border: 4px solid #475569;
}

@keyframes pulseGreen {
  0%, 100% { box-shadow: 0 0 40px rgba(16,185,129,0.3); }
  50% { box-shadow: 0 0 60px rgba(16,185,129,0.5), 0 0 100px rgba(16,185,129,0.2); }
}

#status-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
}

.status-circle.active #status-text { color: var(--green); }
.status-circle.inactive #status-text { color: #475569; }

/* SENSOR GAUGES */
.sensor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin: 20px 0;
}

.sensor-gauge { text-align: center; }

/* PANIC BUTTON */
.panic-section { margin-top: 20px; }
.panic-btn {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 20px;
  font-size: 20px;
  font-weight: 800;
  width: 100%;
  cursor: pointer;
  min-height: 64px;
  box-shadow: 0 4px 20px rgba(239,68,68,0.3);
}
.panic-btn:active { transform: scale(0.97); }

/* CARDS */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* STAT CARDS */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.stat-card {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
}
.stat-value { font-size: 28px; font-weight: 800; color: var(--blue); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* EVENT CARDS */
.event-card {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.event-time { font-size: 14px; color: var(--text-muted); }
.severity-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.response-badge {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* CONTACT CARDS */
.contact-card {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contact-name { font-size: 18px; font-weight: 700; }
.contact-phone { font-size: 15px; color: var(--text-muted); }
.contact-relation { font-size: 13px; color: var(--text-muted); }
.contact-notify { font-size: 16px; margin-top: 4px; }
.contact-actions { display: flex; gap: 4px; }

/* CONTACT FORM */
#contact-form {
  display: none;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.checkbox-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--blue);
}

/* SETTINGS */
.setting-group {
  margin-bottom: 20px;
}
.setting-label {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.setting-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #2a3560;
  outline: none;
  padding: 0;
  border: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}

/* TOGGLE SWITCH */
.toggle-wrap { display: flex; align-items: center; gap: 12px; }
.toggle {
  position: relative;
  width: 56px;
  height: 32px;
  background: #2a3560;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.3s;
  border: none;
  padding: 0;
}
.toggle.on { background: var(--green); }
.toggle::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.3s;
}
.toggle.on::after { transform: translateX(24px); }

.section-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
}

.empty-text {
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
  font-size: 16px;
}

/* LAST EVENT */
.last-event {
  background: var(--bg-input);
  border-radius: 12px;
  padding: 14px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

/* RESPONSIVE */
@media (max-width: 380px) {
  html { font-size: 16px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .sensor-grid { grid-template-columns: 1fr 1fr; }
}

/* Prevent zoom on input focus (iOS) */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select, textarea, input { font-size: 16px !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* ABOUT SECTION */
.about-section { color: var(--text-muted); font-size: 14px; text-align: center; padding: 20px; }
.about-section h3 { color: var(--text); font-size: 18px; margin-bottom: 8px; }
.about-section p { margin-bottom: 8px; }
.about-version { font-weight: 700; color: var(--blue); }
