/* ═══════════════════════════════════════════════════════════════════
   Legacy — Conversation Page Styles
   Uses design tokens from legacy-brand.css
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Setup Screen ─────────────────────────────────────────────── */

.setup-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}

.setup-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2rem;
  font-weight: 300;
  color: var(--legacy-accent);
  letter-spacing: 0.08em;
  text-decoration: none;
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}

.setup-card {
  background: white;
  border: 1px solid var(--legacy-border-light);
  border-radius: var(--legacy-radius-lg);
  padding: 2.5rem 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--legacy-shadow-lg);
  text-align: center;
  opacity: 0;
  animation: fadeUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

.setup-card h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--legacy-text);
  margin-bottom: 0.35rem;
}

.setup-subtitle {
  color: var(--legacy-text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.setup-field {
  text-align: left;
  margin-bottom: 1.25rem;
}

.setup-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--legacy-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.setup-select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--legacy-bg);
  border: 1px solid var(--legacy-border);
  border-radius: var(--legacy-radius-sm);
  color: var(--legacy-text);
  font-size: 0.95rem;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236B6560' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.setup-select:focus {
  outline: none;
  border-color: var(--legacy-accent);
}

.setup-start-btn {
  width: 100%;
  padding: 0.85rem;
  margin-top: 0.5rem;
  background: var(--legacy-accent);
  border: none;
  border-radius: var(--legacy-radius-sm);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.setup-start-btn:hover {
  background: var(--legacy-accent-hover);
  transform: scale(1.01);
}

.setup-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.setup-hint {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--legacy-text-muted);
  font-style: italic;
  line-height: 1.5;
}

/* ─── Conversation Screen ──────────────────────────────────────── */

.conversation-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--legacy-bg);
}

/* Header */
.conv-header {
  background: white;
  border-bottom: 1px solid var(--legacy-border-light);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.conv-header .logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--legacy-accent);
  text-decoration: none;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.conv-persona-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.conv-persona-name {
  font-family: var(--legacy-font-heading);
  font-size: 0.95rem;
  color: var(--legacy-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-status {
  font-size: 0.75rem;
  color: var(--legacy-success);
  white-space: nowrap;
}

.conv-header-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  background: transparent;
  border: 1px solid var(--legacy-border);
  border-radius: var(--legacy-radius-sm);
  color: var(--legacy-text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-sm:hover {
  border-color: var(--legacy-accent);
  color: var(--legacy-accent);
}

/* ─── Mode Tabs ────────────────────────────────────────────────── */

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  background: var(--legacy-bg-alt);
  border-bottom: 1px solid var(--legacy-border-light);
  flex-shrink: 0;
}

.mode-tab {
  padding: 0.45rem 1.5rem;
  border-radius: 20px;
  border: 1px solid var(--legacy-border);
  background: white;
  color: var(--legacy-text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.mode-tab:hover {
  border-color: var(--legacy-accent-light);
  color: var(--legacy-text);
}

.mode-tab.active {
  background: var(--legacy-accent);
  color: white;
  border-color: var(--legacy-accent);
}

/* ─── Voice Mode ───────────────────────────────────────────────── */

.mode-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.voice-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  gap: 1rem;
  min-height: 0;
}

.voice-orb-container {
  width: 200px;
  height: 200px;
  position: relative;
  flex-shrink: 0;
}

#voiceOrbCanvas {
  width: 100%;
  height: 100%;
}

.voice-state-label {
  font-family: var(--legacy-font-heading);
  font-size: 1rem;
  color: var(--legacy-text-secondary);
  letter-spacing: 0.02em;
  transition: color 0.3s;
  flex-shrink: 0;
}

.voice-state-label.listening { color: var(--legacy-accent); }
.voice-state-label.thinking { color: var(--legacy-accent); }
.voice-state-label.speaking { color: var(--legacy-info); }

/* Mic button */
.voice-mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--legacy-accent);
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.voice-mic-btn svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.voice-mic-btn:hover {
  transform: scale(1.05);
  background: var(--legacy-accent-hover);
}

.voice-mic-btn.recording {
  background: var(--legacy-error);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 92, 74, 0.35); }
  50% { box-shadow: 0 0 0 18px rgba(196, 92, 74, 0); }
}

.voice-mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  animation: none;
}

/* Voice transcript area */
.voice-transcript {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
}

.voice-transcript .v-msg {
  padding: 0.4rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--legacy-text-secondary);
  border-bottom: 1px solid var(--legacy-border-light);
}

.voice-transcript .v-msg:last-child { border-bottom: none; }
.voice-transcript .v-msg.user { color: var(--legacy-text); }
.voice-transcript .v-msg .v-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--legacy-text-muted);
  margin-bottom: 0.1rem;
}

/* ─── Chat Mode ────────────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
}

.chat-msg {
  display: flex;
  gap: 0.6rem;
  max-width: 85%;
  animation: msgIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chat-msg.persona .chat-avatar {
  background: linear-gradient(135deg, var(--legacy-accent-light), var(--legacy-accent));
  color: white;
}

.chat-msg.user .chat-avatar {
  background: var(--legacy-panel);
  color: var(--legacy-text-secondary);
}

.chat-bubble {
  border-radius: 16px;
  padding: 0.7rem 1rem;
  line-height: 1.55;
  font-size: 0.92rem;
}

.chat-msg.persona .chat-bubble {
  background: white;
  border: 1px solid var(--legacy-border-light);
  color: var(--legacy-text);
  border-top-left-radius: 4px;
}

.chat-msg.user .chat-bubble {
  background: var(--legacy-accent);
  color: white;
  border-top-right-radius: 4px;
}

.chat-time {
  font-size: 0.65rem;
  color: var(--legacy-text-muted);
  margin-top: 0.2rem;
}

/* Audio play button inside messages */
.chat-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: var(--legacy-accent-light);
  border: 1px solid var(--legacy-accent);
  border-radius: 16px;
  color: var(--legacy-accent-hover);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-audio-btn:hover {
  background: var(--legacy-accent);
  color: white;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 0.7rem 1rem;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--legacy-accent);
  opacity: 0.4;
  animation: dotPulse 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* Chat input */
.chat-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--legacy-border-light);
  background: white;
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
}

.chat-text-input {
  flex: 1;
  padding: 0.65rem 1rem;
  background: var(--legacy-bg);
  border: 1px solid var(--legacy-border);
  border-radius: var(--legacy-radius);
  color: var(--legacy-text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.chat-text-input:focus {
  outline: none;
  border-color: var(--legacy-accent);
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--legacy-accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--legacy-accent-hover);
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--legacy-text-muted);
}

.empty-state p { font-size: 0.9rem; line-height: 1.6; }

/* ─── History Sidebar ──────────────────────────────────────────── */

.history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.history-overlay.open { display: block; }

.history-sidebar {
  position: fixed;
  top: 0;
  left: -360px;
  width: 340px;
  height: 100vh;
  background: white;
  border-right: 1px solid var(--legacy-border);
  z-index: 100;
  transition: left 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
}

.history-sidebar.open { left: 0; }

.history-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--legacy-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--legacy-text);
}

.history-close-btn {
  background: none;
  border: none;
  color: var(--legacy-text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: color 0.2s;
}

.history-close-btn:hover { color: var(--legacy-text); }

.new-conv-btn {
  margin: 0.75rem 1rem;
  padding: 0.55rem;
  background: var(--legacy-accent);
  border: none;
  border-radius: var(--legacy-radius-sm);
  color: white;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.new-conv-btn:hover { background: var(--legacy-accent-hover); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
}

.history-card {
  background: var(--legacy-bg);
  border: 1px solid var(--legacy-border-light);
  border-radius: var(--legacy-radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.history-card:hover {
  background: var(--legacy-bg-alt);
  border-color: var(--legacy-accent-light);
}

.history-card.active {
  border-color: var(--legacy-accent);
  background: var(--legacy-accent-light);
}

.history-card-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--legacy-text);
  margin-bottom: 0.2rem;
}

.history-card-meta {
  font-size: 0.72rem;
  color: var(--legacy-text-muted);
  margin-bottom: 0.3rem;
}

.history-card-preview {
  font-size: 0.8rem;
  color: var(--legacy-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-actions {
  margin-top: 0.45rem;
}

.history-resume-btn {
  background: var(--legacy-accent-light);
  border: 1px solid var(--legacy-accent);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  color: var(--legacy-accent-hover);
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.history-resume-btn:hover {
  background: var(--legacy-accent);
  color: white;
}

.history-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--legacy-text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* ─── Transparency Panel ───────────────────────────────────────── */

.transparency-panel {
  position: fixed;
  bottom: 0.75rem;
  right: 0.75rem;
  z-index: 50;
}

.transparency-toggle {
  background: white;
  border: 1px solid var(--legacy-border);
  border-radius: var(--legacy-radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.72rem;
  color: var(--legacy-text-muted);
  cursor: pointer;
  box-shadow: var(--legacy-shadow);
  font-family: inherit;
  transition: all 0.2s;
}

.transparency-toggle:hover {
  border-color: var(--legacy-accent);
  color: var(--legacy-accent);
}

.transparency-content {
  display: none;
  background: white;
  border: 1px solid var(--legacy-border);
  border-radius: var(--legacy-radius);
  padding: 1rem;
  margin-bottom: 0.4rem;
  box-shadow: var(--legacy-shadow-lg);
  max-width: 320px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--legacy-text-secondary);
}

.transparency-content.open { display: block; }

.transparency-content h4 {
  font-family: var(--legacy-font-heading);
  color: var(--legacy-text);
  margin-bottom: 0.4rem;
  font-weight: 400;
  font-size: 0.9rem;
}

.transparency-content p { margin-bottom: 0.4rem; }
.transparency-content p:last-child { margin-bottom: 0; }

/* ─── Animations ───────────────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .conv-header {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .conv-header .logo { font-size: 1.15rem; }

  .voice-orb-container {
    width: 160px;
    height: 160px;
  }

  .voice-mic-btn {
    width: 64px;
    height: 64px;
  }

  .voice-mic-btn svg {
    width: 24px;
    height: 24px;
  }

  .voice-transcript {
    max-height: 140px;
    padding: 0.5rem 0.75rem;
  }

  .chat-messages { padding: 0.75rem; }

  .setup-card {
    padding: 2rem 1.5rem 1.5rem;
    margin: 0 0.5rem;
  }

  .history-sidebar { width: 300px; left: -310px; }
}

@media (max-width: 480px) {
  .voice-orb-container {
    width: 140px;
    height: 140px;
  }

  .voice-mic-btn {
    width: 60px;
    height: 60px;
  }

  .conv-header-actions .btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
  }

  .mode-tab {
    padding: 0.4rem 1.2rem;
    font-size: 0.8rem;
  }

  .chat-input-area {
    padding: 0.6rem 0.75rem;
  }
}
