/* SG Chat — base/shared UI styles.
   Colors/spacing/type come from tokens.css (loaded first in index.html) —
   see docs/wave7-design-system.md for the full design-system rationale
   and migration status of each feature CSS file. */

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--font-display); }
.hidden { display: none !important; }
.muted { color: var(--color-text-muted); }

/* --- Header / nav --- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
header h1 { font-size: var(--text-lg); margin: 0; color: var(--color-accent); }
header nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-bg-alt);
  border-radius: var(--radius-pill);
  padding: 4px;
}
header nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
header nav a.active, header nav a:hover {
  color: #fff;
  background: var(--color-accent);
}

main { padding: var(--space-5); max-width: 1100px; margin: 0 auto; }

/* --- Login --- */
#login-screen .login-wrap {
  max-width: 380px;
  margin: 80px auto;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  box-shadow: var(--shadow-card);
}
.login-wrap h1 {
  font-size: var(--text-2xl);
  margin: 0 0 var(--space-6);
  color: var(--color-text);
  font-weight: 600;
}
label {
  display: block;
  margin: var(--space-3) 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
input, select {
  width: 100%;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.error-box {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: #fdecea;
  border: 1px solid #f3b8b3;
  color: #8a2f28;
  font-size: var(--text-sm);
}

/* --- Buttons --- */
button {
  cursor: pointer;
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-base);
  transition: opacity var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
}
button:hover { opacity: 0.88; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
button.danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* --- Panels / toolbars (roster, call, etc.) --- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-5);
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.form-row {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.form-row > div { flex: 1; min-width: 160px; }
.call-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--color-warm);
  border: 1px solid var(--color-warm);
}
/* Role tags (parent/child) — purple, distinct from status meaning */
.badge--role {
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  background: var(--color-accent-soft);
}
/* Positive/active status (active, accepted) — mint */
.badge--success {
  color: var(--color-success);
  border: 1px solid var(--color-success);
  background: var(--color-success-soft);
}
/* Disabled/inactive/negative status — muted, visually de-emphasized */
.badge--muted {
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}
/* Cross-family / attention-worthy — pink, reserved per tokens.css comment */
.badge--warm {
  color: var(--color-warm);
  border: 1px solid var(--color-warm);
  background: var(--color-warm-soft);
}
#global-banner:not(:empty) {
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

/* --- Family roster list --- */
.roster-list { list-style: none; margin: 0; padding: 0; }
.roster-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--duration-fast) var(--ease-standard);
}
.roster-list li:last-child { border-bottom: none; }
.roster-list li:hover { background: var(--color-bg-alt); }
.roster-name { font-weight: 600; color: var(--color-text); }
.roster-meta { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Card-row treatment (mockup .row-hover + divider): avatar + name/badges
 * on one row, hairline divider between rows rather than boxed cards. */
.roster-row-avatar { flex-shrink: 0; }
.roster-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* WhatsApp/Messenger-Kids contact-list IA: each row is a flex row with
   the avatar+info on the left and inline call/message icon buttons on the
   right (no dedicated Call/Messages nav tabs; actions live on each row). */
.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.roster-row-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}
.roster-row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}
.action-icon {
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.action-icon:hover {
  background: var(--color-bg-alt);
  color: var(--color-accent, #3f6ad6);
}
.action-icon:active {
  background: var(--color-border);
}

.role-child::after {
  content: "";
}

/* --- Avatar + presence ring (borrowed-from-001 treatment, see tokens.css) --- */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: linear-gradient(160deg, var(--color-accent-soft), var(--color-success-soft));
  border: 1.5px solid var(--color-border);
  flex-shrink: 0;
}
.avatar-ring {
  background: var(--ring-gradient);
  padding: 3px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  position: relative;
  flex-shrink: 0;
}
.avatar-ring .avatar { border: 2px solid var(--color-surface); }

/* --- Toasts (incoming call etc.) --- */
@keyframes sg-toast-in {
  from { transform: translateY(-120%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast { animation: sg-toast-in var(--duration-toast) var(--ease-bounce) both; }
@keyframes sg-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(138, 92, 246, 0.4); }
  100% { box-shadow: 0 0 0 18px rgba(138, 92, 246, 0); }
}
.pulse-ring { animation: sg-pulse-ring 1.6s ease-out infinite; }

/* --- Incoming-call toast (in #global-banner) --- */
.toast-call {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-success);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-card);
  max-width: 420px;
  width: 100%;
  box-sizing: border-box;
}
.toast-call .pulse-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-alt);
}
.toast-call-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.toast-call-name {
  font-weight: 600;
  color: var(--color-text);
}
.toast-call-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.toast-call-actions {
  display: flex;
  gap: var(--space-1);
}
.toast-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.toast-btn:hover {
  background: var(--color-bg-alt);
}
.toast-answer { color: var(--color-success); }
.toast-decline { color: var(--color-warm); }
