/**
 * Firetell WebRTC & SMS SDK Demo — Official Firetell Design System v2.0.0
 * Softphone & Agent Workspace surface tokens (--firetell-*)
 */

:root {
  color-scheme: light;

  /* Official Firetell Portable Tokens */
  --firetell-primary: #111111;
  --firetell-primary-active: #242424;
  --firetell-primary-disabled: #e5e7eb;
  --firetell-ink: #111111;
  --firetell-body: #374151;
  --firetell-muted: #6b7280;
  --firetell-muted-soft: #898989;
  --firetell-hairline: #e5e7eb;
  --firetell-hairline-soft: #f3f4f6;
  --firetell-canvas: #ffffff;
  --firetell-surface-soft: #f8f9fa;
  --firetell-surface-card: #f5f5f5;
  --firetell-surface-strong: #e5e7eb;
  --firetell-on-primary: #ffffff;

  /* Brand Warmth (<= 5% of viewport) */
  --firetell-warm: #ea580c;
  --firetell-warm-accent: #fb923c;
  --firetell-warm-soft: #fff7ed;
  --firetell-warm-border: #fed7aa;
  --firetell-warm-ink: #9a3412;

  /* Pastel Avatar Fills */
  --firetell-avatar-apricot: #fed7aa;
  --firetell-avatar-amber: #fde68a;
  --firetell-avatar-mint: #bbf7d0;
  --firetell-avatar-pink: #fbcfe8;

  /* Strict Telecom & Operational Status Semantics */
  --firetell-success: #10b981;
  --firetell-success-soft: #ecfdf5;
  --firetell-success-border: #a7f3d0;
  --firetell-success-ink: #065f46;
  --firetell-warning: #f59e0b;
  --firetell-warning-soft: #fffbeb;
  --firetell-warning-border: #fde68a;
  --firetell-warning-ink: #92400e;
  --firetell-error: #ef4444;
  --firetell-error-soft: #fef2f2;
  --firetell-error-border: #fecaca;
  --firetell-error-ink: #991b1b;

  /* Demo Alias Mapping */
  --bg: var(--firetell-surface-soft);
  --surface: var(--firetell-canvas);
  --surface-2: var(--firetell-surface-card);
  --border: var(--firetell-hairline);
  --text: var(--firetell-ink);
  --text-muted: var(--firetell-muted);
  --primary: var(--firetell-primary);
  --primary-hover: var(--firetell-primary-active);
  --green: var(--firetell-success);
  --green-hover: #059669;
  --red: var(--firetell-error);
  --red-hover: #dc2626;
  --amber: var(--firetell-warning);
  --cyan: #374151;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 440px;
  padding: 20px;
}

/* ── Header ───────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--firetell-ink);
}

.header .badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--firetell-warm-ink);
  background: var(--firetell-warm-soft);
  padding: 3px 10px;
  border-radius: 9999px;
  border: 1px solid var(--firetell-warm-border);
  font-variant-numeric: tabular-nums;
}

/* ── Cards ────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Forms ────────────────────────────── */
.input-group {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
  color: var(--text);
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.08);
}

input[type="text"]::placeholder {
  color: var(--firetell-muted-soft);
}

/* ── Buttons ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  background: var(--firetell-primary-disabled);
  color: var(--firetell-muted);
  border-color: var(--firetell-primary-disabled);
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--firetell-on-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-green {
  background: var(--green);
  color: #fff;
}

.btn-green:hover:not(:disabled) {
  background: var(--green-hover);
}

.btn-red {
  background: var(--red);
  color: #fff;
}

.btn-red:hover:not(:disabled) {
  background: var(--red-hover);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--firetell-surface-strong);
}

.btn-ghost.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
}

.btn-icon.btn-lg {
  width: 56px;
  height: 56px;
  font-size: 22px;
}

/* ── Status Indicators ────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--firetell-surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--green);
}

.status-dot.error {
  background: var(--red);
}

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

/* ── Call UI ──────────────────────────── */
.call-info {
  text-align: center;
  padding: 16px 0;
}

.call-info .caller-name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.014em;
  color: var(--firetell-ink);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.call-info .call-status {
  font-size: 13px;
  color: var(--text-muted);
}

.call-info .call-timer {
  display: inline-block;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 10px;
  padding: 4px 14px;
  border-radius: 9999px;
  background: var(--firetell-success-soft);
  border: 1px solid var(--firetell-success-border);
  color: var(--firetell-success-ink);
}

/* ── Video Container ───────────────────── */
.video-container {
  position: relative;
  width: 100%;
  height: 240px;
  background: #101010;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 14px 0 6px 0;
}

.video-container video.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #101010;
  display: block;
}

.video-container video.local-video {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 90px;
  height: 68px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: #1a1a1a;
  z-index: 2;
  transform: scaleX(-1);
  display: block;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.call-controls .btn-icon {
  position: relative;
}

.call-controls .btn-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.call-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 36px;
}

/* ── DTMF Pad ─────────────────────────── */
.dtmf-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.dtmf-pad .btn {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 14px;
}

/* ── Incoming Banner ──────────────────── */
.incoming-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 100;
  display: none;
  min-width: 340px;
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.incoming-banner .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--firetell-avatar-apricot);
  border: 1px solid var(--firetell-warm-border);
  flex-shrink: 0;
}

.incoming-banner .caller {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.incoming-banner .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.incoming-banner .actions {
  display: flex;
  gap: 8px;
}

.incoming-banner .actions .btn {
  flex: 1;
}

/* ── Log Panel ────────────────────────── */
.log-panel {
  background: var(--firetell-surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 11.5px;
  font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
  color: var(--firetell-body);
}

.log-panel::-webkit-scrollbar {
  width: 4px;
}

.log-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.log-entry .time {
  color: var(--text-muted);
}

.log-entry.error {
  color: var(--firetell-error-ink);
}

.log-entry.success {
  color: var(--firetell-success-ink);
}

.log-entry.warn {
  color: var(--firetell-warning-ink);
}

.log-entry.info {
  color: var(--firetell-ink);
}

/* ── Agent List ───────────────────────── */
.agent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--firetell-surface-soft);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

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

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mt-12 {
  margin-top: 12px;
}

.mt-8 {
  margin-top: 8px;
}

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

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

/* ── Media elements (hidden audio) ────── */
audio {
  display: none;
}

/* ── Transfer input ───────────────────── */
.transfer-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
