/* ============================================================
   Voice AI Demo Container — style.css
   Thème light · Branding Rendez-vous.ai
   Bleu idle/listening · Vert speaking · Jaune thinking
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand colors */
  --blue:         #2563EB;
  --blue-light:   #60A5FA;
  --blue-glow:    rgba(37, 99, 235, 0.22);
  --blue-dim:     rgba(37, 99, 235, 0.10);

  --green:        #10B981;
  --green-light:  #34D399;
  --green-glow:   rgba(16, 185, 129, 0.22);
  --green-dim:    rgba(16, 185, 129, 0.10);

  --yellow:       #F59E0B;
  --yellow-light: #FCD34D;
  --yellow-glow:  rgba(245, 158, 11, 0.22);
  --yellow-dim:   rgba(245, 158, 11, 0.10);

  --red:          #EF4444;
  --red-dim:      rgba(239, 68, 68, 0.12);

  /* Light theme surfaces */
  --bg:           #F1F5F9;
  --card-bg:      #FFFFFF;
  --card-border:  rgba(0, 0, 0, 0.07);
  --section-sep:  rgba(0, 0, 0, 0.06);

  /* Typography */
  --text-dark:    #0F172A;
  --text-medium:  #475569;
  --text-muted:   #94A3B8;

  --radius-lg:    1.25rem;
  --radius-md:    0.75rem;
  --radius-sm:    0.5rem;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
  width: 100%;
  height: 100%;
  background: transparent;
  font-family: var(--font);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Wrapper ── */
.demo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg);
}

/* ── Card ── */
.demo-container {
  width: 100%;
  max-width: 540px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.05),
    0 10px 30px -5px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.4s ease;
}

/* State-aware card glow (subtle) */
.demo-container.state-speaking  { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 10px 30px -5px rgba(0,0,0,0.08), 0 0 0 2px var(--green-dim); }
.demo-container.state-listening { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 10px 30px -5px rgba(0,0,0,0.08), 0 0 0 2px var(--blue-dim); }
.demo-container.state-thinking  { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 10px 30px -5px rgba(0,0,0,0.08), 0 0 0 2px var(--yellow-dim); }

/* ============================================================
   TEMPLATE SELECTOR
   ============================================================ */
.template-selector {
  padding: 1.1rem 0.75rem 0.9rem;
  border-bottom: 1px solid var(--section-sep);
  animation: fadeIn 0.35s ease both;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.template-card {
  background: #F8FAFC;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem 0.6rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  transition: var(--transition);
  color: var(--text-dark);
}

.template-card:hover {
  background: var(--blue-dim);
  border-color: rgba(37, 99, 235, 0.25);
  transform: translateY(-1px);
}

.template-card.active {
  background: var(--blue-dim);
  border-color: rgba(37, 99, 235, 0.35);
}

.template-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.template-logo {
  width: 80px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
}

.template-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.template-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-desc {
  font-size: 0.58rem;
  color: var(--text-muted);
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   ORB / VISUALIZER SECTION
   ============================================================ */
.orb-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem 1rem;
  gap: 0.75rem;
  min-height: 240px;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(37,99,235,0.55) 0%, rgba(37,99,235,0.28) 38%, rgba(130,177,255,0.10) 65%, rgba(255,255,255,0) 100%);
  transition: background 0.6s ease;
}

.orb-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#orbCanvas {
  width: 200px;
  height: 200px;
  display: block;
  position: relative;
  z-index: 1;
}

/* ── Anneau CSS masqué — le canvas dessine le cercle verre ── */
.orb-ring {
  display: none;
}

/* ── Connected badge & timer ── */
.call-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  animation: fadeIn 0.3s ease both;
}

.call-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(16, 185, 129, 0.09);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

.call-duration {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* ── Agent state label ── */
.agent-state-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  height: 1em;
  opacity: 0;
  transition: color 0.3s ease, opacity 0.3s ease;
}

.agent-state-label.visible  { opacity: 1; }
.agent-state-label.speaking  { color: var(--green); }
.agent-state-label.listening { color: var(--blue); }
.agent-state-label.thinking  { color: var(--yellow); }

/* ============================================================
   CALL CONTROLS
   ============================================================ */
.call-controls {
  padding: 1.5rem 1.25rem 1.75rem;
  border-top: 1px solid var(--section-sep);
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Pre-call ── */
.precall-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  animation: fadeIn 0.35s ease both;
}

.btn-start {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, var(--blue), #1D4ED8);
  color: #fff;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  justify-content: center;
  box-shadow: 0 4px 14px var(--blue-glow);
  transition: var(--transition);
  animation: btn-pulse 2.8s ease-in-out infinite;
}

.btn-start:hover {
  background: linear-gradient(135deg, #3B82F6, var(--blue));
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.40);
  animation-play-state: paused;
}

.btn-start:active { transform: translateY(0); }

.btn-start-icon { display: flex; align-items: center; opacity: 0.9; }

.mic-note {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.mic-error {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.72rem;
  color: #dc2626;
  line-height: 1.4;
  text-align: left;
  margin-bottom: 0.25rem;
}

/* badges removed */

/* ── Connecting ── */
.connecting-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  animation: fadeIn 0.25s ease both;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(37, 99, 235, 0.15);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.connecting-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Active call ── */
.active-call {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  animation: fadeIn 0.3s ease both;
}

.active-controls-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-mic {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--card-border);
  background: #F8FAFC;
  color: var(--text-medium);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-mic:hover {
  background: var(--blue-dim);
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--blue);
  transform: scale(1.05);
}

.btn-mic.muted {
  background: var(--red-dim);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.btn-end {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.4rem;
  background: var(--red-dim);
  border: 1.5px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  color: var(--red);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-end:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  transform: translateY(-1px);
}

.btn-end:active { transform: translateY(0); }

.muted-label {
  font-size: 0.72rem;
  color: var(--red);
  animation: fadeIn 0.2s ease both;
}

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

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.3); }
}

@keyframes ring-idle-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--blue-glow); }
  50%       { box-shadow: 0 0 12px 2px var(--blue-glow); }
}

@keyframes ring-active-pulse {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 1; }
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 4px 14px var(--blue-glow); }
  50%       { box-shadow: 0 4px 22px rgba(37, 99, 235, 0.40); }
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 400px) {
  .demo-wrapper { padding: 0.5rem; }
  .template-grid { grid-template-columns: repeat(2, 1fr); }
  .btn-start { font-size: 0.82rem; padding: 0.75rem 1rem; }
}

@media (min-width: 600px) {
  .demo-container { max-width: 560px; }
}

@media (max-height: 600px) {
  .orb-section { min-height: 180px; padding: 0.75rem 1.25rem 0.5rem; }
  #orbCanvas { width: 160px; height: 160px; }
  .orb-container { width: 160px; height: 160px; }
}
