/* SOVCOM V3 Base Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #root {
  height: 100%; width: 100%;
  background: var(--bg0);
  color: var(--text0);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: var(--fs-md);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Screens */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg0);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast);
  overflow: hidden;
}
.screen.active { opacity: 1; pointer-events: all; }

/* Navigation shell */
.app-shell { display: flex; flex-direction: column; height: 100%; }
.main-content { flex: 1; overflow-y: auto; overflow-x: hidden; }
.tab-bar {
  display: flex; background: var(--bg1);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--sp-sm) 0; gap: 2px;
  color: var(--text2); font-size: var(--fs-xs);
  cursor: pointer; border: none; background: none;
  transition: color var(--t-fast);
}
.tab-item.active, .tab-item:hover { color: var(--accent); }
.tab-item svg { width: 22px; height: 22px; }

/* Header */
.header {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: var(--sp-md);
  padding-top: calc(var(--sp-md) + env(safe-area-inset-top));
  background: var(--bg1); border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.header-title { font-size: var(--fs-lg); font-weight: 600; flex: 1; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-sm); padding: 12px var(--sp-lg);
  border-radius: var(--r-full); border: none; cursor: pointer;
  font-size: var(--fs-md); font-weight: 500;
  transition: all var(--t-fast);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--bg3); color: var(--text0); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-icon { background: none; border: none; cursor: pointer; padding: var(--sp-sm); color: var(--text1); border-radius: var(--r-full); transition: background var(--t-fast); }
.btn-icon:hover { background: var(--bg3); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

/* Inputs */
.input {
  width: 100%; padding: 14px var(--sp-md);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text0);
  font-size: var(--fs-md); outline: none;
  transition: border-color var(--t-fast);
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text3); }

/* Cards */
.card {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-md);
}

/* Lists */
.list-item {
  display: flex; align-items: center; gap: var(--sp-md);
  padding: var(--sp-md); cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.list-item:hover { background: var(--bg2); }
.list-item:last-child { border-bottom: none; }

/* Avatar */
.avatar {
  width: 44px; height: 44px; border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #fff; font-size: var(--fs-md);
  flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: var(--fs-xl); }

/* Messages */
.msg-bubble {
  max-width: 75%; padding: 10px 14px;
  border-radius: var(--r-lg); font-size: var(--fs-md);
  line-height: 1.5; word-break: break-word;
}
.msg-bubble.sent { background: var(--sent-bg); margin-left: auto; border-bottom-right-radius: 4px; }
.msg-bubble.recv { background: var(--recv-bg); margin-right: auto; border-bottom-left-radius: 4px; }
.msg-row { display: flex; flex-direction: column; margin-bottom: var(--sp-sm); }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: var(--z-modal);
}
.modal-sheet {
  background: var(--bg1); border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%; max-width: 600px; padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-lg) + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto;
}

/* Toasts */
.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--bg3); color: var(--text0);
  padding: 10px 20px; border-radius: var(--r-full);
  font-size: var(--fs-sm); z-index: var(--z-toast);
  animation: toast-in var(--t-mid) ease;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* Search bar */
.search-bar {
  display: flex; align-items: center; gap: var(--sp-sm);
  background: var(--bg2); border-radius: var(--r-full);
  padding: 10px var(--sp-md); margin: var(--sp-md);
}
.search-bar input { flex: 1; background: none; border: none; outline: none; color: var(--text0); font-size: var(--fs-md); }
.search-bar svg { color: var(--text2); flex-shrink: 0; }

/* PIN pad */
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-md); max-width: 280px; margin: 0 auto; }
.pin-dot-row { display: flex; gap: 12px; justify-content: center; margin-bottom: var(--sp-xl); }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); transition: background var(--t-fast); }
.pin-dot.filled { background: var(--accent); }
.pin-key { aspect-ratio: 1; border-radius: var(--r-full); background: var(--bg2); border: none; color: var(--text0); font-size: var(--fs-xl); font-weight: 500; cursor: pointer; transition: background var(--t-fast), transform var(--t-fast); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pin-key:active { background: var(--bg3); transform: scale(0.95); }
.pin-key.del { font-size: var(--fs-lg); }
.pin-key.empty { background: none; pointer-events: none; }

/* Call screen */
.call-screen { background: linear-gradient(160deg, #0d1a2e, #1a0d2e); }
.call-avatar-lg { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto var(--sp-lg); display: flex; align-items: center; justify-content: center; font-size: 48px; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.2); }
.call-controls { display: flex; gap: var(--sp-xl); justify-content: center; margin-top: var(--sp-2xl); }
.call-btn { width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--t-fast); }
.call-btn.end { background: var(--danger); }
.call-btn.mute, .call-btn.video, .call-btn.speaker { background: rgba(255,255,255,0.15); }
.call-btn svg { color: #fff; width: 24px; height: 24px; }

/* Utility */
.flex { display: flex; } .col { flex-direction: column; } .gap-sm { gap: var(--sp-sm); } .gap-md { gap: var(--sp-md); }
.center { align-items: center; justify-content: center; }
.flex-1 { flex: 1; }
.p-md { padding: var(--sp-md); }
.text-center { text-align: center; }
.text-sub { color: var(--text2); font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); color: var(--text3); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.bold { font-weight: 600; }
.w-full { width: 100%; }
.mt-md { margin-top: var(--sp-md); }
.mb-md { margin-bottom: var(--sp-md); }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: var(--sp-md) 0; }
.badge { background: var(--danger); color: #fff; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-full); padding: 2px 6px; min-width: 18px; text-align: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.dot.ok { background: var(--green); }

/* Architecture B React root — always receives pointer events regardless of
   the .screen opacity rule, since React controls its own visibility. */
#sovcom-sdk-root { pointer-events: all; }
#sovcom-sdk-root .screen { pointer-events: all; opacity: 1; }
