/* ===== SafeCircle – Dark Theme ===== */
:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-elevated: #1c1c1c;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #e63946;          /* Strong red for SOS */
  --accent-dark: #c1121f;
  --success: #2a9d8f;
  --warning: #e9c46a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

#app {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ===== Screens ===== */
.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ===== Splash ===== */
#splash {
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

.splash-content {
  text-align: center;
}

.logo {
  font-size: 64px;
  margin-bottom: 16px;
}

#splash h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

#splash p {
  color: var(--text-muted);
  margin-top: 8px;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 32px auto 0;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Onboarding ===== */
#onboarding {
  padding: 40px 24px;
  justify-content: center;
}

#onboarding h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.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-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

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

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}

.icon-btn.small {
  font-size: 20px;
  background: var(--bg-elevated);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Header ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

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

.status-dot.offline {
  background: var(--warning);
}

/* ===== Status Banner ===== */
.status-banner {
  background: var(--accent);
  color: white;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}

.status-banner.hidden {
  display: none;
}

.status-banner.safe {
  background: var(--success);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  padding: 20px;
  padding-bottom: 90px;
  overflow-y: auto;
}

/* ===== SOS Section ===== */
.sos-section {
  text-align: center;
  margin-bottom: 28px;
}

.section-label {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.sos-button {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff4d5a, var(--accent-dark));
  border: 4px solid rgba(230, 57, 70, 0.4);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.5);
  transition: transform 0.15s, box-shadow 0.3s;
  user-select: none;
  -webkit-user-select: none;
}

.sos-button:active,
.sos-button.holding {
  transform: scale(0.95);
  box-shadow: 0 0 0 20px rgba(230, 57, 70, 0.25);
}

.sos-text {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 2px;
}

.sos-sub {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 4px;
}

.hint {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Quick Actions ===== */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.action-btn:active {
  background: var(--bg-elevated);
}

.action-btn.safe-btn {
  border-color: rgba(42, 157, 143, 0.4);
}

.action-icon {
  font-size: 24px;
}

/* ===== Cards & Sections ===== */
.info-card,
.contacts-section,
.alerts-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.info-card h3,
.contacts-section h3,
.alerts-section h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#last-location {
  font-size: 15px;
  word-break: break-all;
}

.time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.section-header h3 {
  margin-bottom: 0;
}

/* ===== Contacts ===== */
.contacts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.contact-info {
  display: flex;
  flex-direction: column;
}

.contact-name {
  font-weight: 600;
}

.contact-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.contact-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

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

/* ===== Alerts ===== */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border-left: 3px solid var(--accent);
}

.alert-item.safe {
  border-left-color: var(--success);
}

.alert-time {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  cursor: pointer;
  padding: 6px 16px;
}

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

.nav-btn span:first-child {
  font-size: 20px;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.modal-content h2 {
  margin-bottom: 20px;
  font-size: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn {
  flex: 1;
}

/* SOS Modal special */
.sos-modal-content {
  text-align: center;
  position: relative;
  overflow: hidden;
}

.sos-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  background: rgba(230, 57, 70, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 1.5s ease-out infinite;
  z-index: -1;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.sos-modal-content h2 {
  color: var(--accent);
  font-size: 24px;
  letter-spacing: 1px;
}

.sos-details {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 16px 0;
  font-size: 13px;
  text-align: left;
  word-break: break-all;
}

/* ===== Settings Panel ===== */
.panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

.panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-body {
  padding: 20px;
  flex: 1;
}

.setting-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.setting-item label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-item p {
  margin-top: 4px;
  font-size: 16px;
}

.version {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 40px;
  line-height: 1.5;
}

/* ===== Footer Branding ===== */
.app-footer {
  text-align: center;
  padding: 24px 16px 16px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.85;
}

.app-footer strong {
  color: var(--text);
  font-weight: 600;
}

/* ===== Premium Plans ===== */
.plan-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.plan-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.plan-card h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.plan-card .price {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}

.plan-card .price span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.plan-card ul {
  list-style: none;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.plan-card ul li {
  padding: 4px 0;
}

.plan-card ul li::before {
  content: "✓ ";
  color: var(--success);
}

/* ===== Utilities ===== */
.hidden {
  display: none !important;
}



/* Responsive tweaks */
@media (max-width: 360px) {
  .sos-button {
    width: 160px;
    height: 160px;
  }
  .sos-text {
    font-size: 30px;
  }
}


/* ===== Family Circle ===== */
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; width: auto; margin: 0; }
.circle-card { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; }
.circle-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.circle-card-head strong { font-size: 16px; }
.circle-card-head small { color: var(--text-muted); }
.circle-paused { background: #3a2f12; color: var(--warning); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.member-main { min-width: 0; }
.member-name { font-weight: 600; }
.member-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.member-sub a { color: var(--accent); text-decoration: none; }
.member-actions { display: flex; gap: 6px; flex-shrink: 0; }
.status-pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px; margin-top: 4px; background: #1a3a32; color: var(--success); }
.status-pill.trip { background: #16304a; color: #5aa9e6; }
.status-pill.checkin { background: #3a2f12; color: var(--warning); }
.status-pill.missed, .status-pill.sos { background: #3a1a1a; color: var(--accent); font-weight: 700; }
.status-pill.paused { background: #2a2a2a; color: var(--text-muted); }
.circle-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.invite-box { background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; padding: 10px; margin-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.invite-box code { font-size: 18px; letter-spacing: 2px; font-weight: 700; }
.sharing-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-top: 10px; }
.request-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #3a2f12; color: var(--warning); padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; }
.link-btn { background: none; border: none; color: var(--text-muted); text-decoration: underline; font-size: 12px; cursor: pointer; padding: 4px; }
#circle-input { width: 100%; padding: 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 16px; }

/* ===== Push notification prompt ===== */
.push-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px; font-size: 14px; display: flex; flex-direction: column; gap: 10px; }
.push-card-actions { display: flex; align-items: center; gap: 10px; }
