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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #252836;
  --border: #2e3347;
  --accent: #4f8ef7;
  --accent-hover: #3a78e8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Auth Page ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }

.btn-full { width: 100%; }

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

.toggle-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.toggle-link button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
}

/* ── App Page ── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

header .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

header .user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

header .user-name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.app-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* ── Add Contact ── */
.add-contact-section {
  margin-bottom: 1.5rem;
}

.add-contact-form {
  display: flex;
  gap: 0.5rem;
}

.add-contact-form input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.add-contact-form input:focus { border-color: var(--accent); }

/* ── Section Labels ── */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ── Contact Cards ── */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: #fff;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-online  { background: var(--green); }
.dot-offline { background: var(--text-muted); }

.contact-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Call Overlay ── */
#call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

#call-overlay.hidden { display: none; }

.call-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  width: 100%;
  max-width: 340px;
}

.call-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 auto 1rem;
  color: #fff;
}

.call-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.call-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
}

.call-timer {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.call-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

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

/* Pulse animation for incoming call */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Notification banner */
#notification {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  z-index: 200;
  max-width: 300px;
  transition: opacity 0.3s;
}

#notification.hidden { display: none; }
#notification.error { border-color: var(--red); color: var(--red); }
#notification.success { border-color: var(--green); color: var(--green); }
