/* ═══════════════════════════════════════════════════════════════
   Components — Chat, Voice, Material, Account
   ═══════════════════════════════════════════════════════════════ */

/* ── Chat Layout ──────────────────────────────────────────── */
.chat-app { display: flex; flex-direction: column; min-height: calc(100vh - var(--nav-h)); }
.chat-app main { flex: 1; display: flex; }

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 12px;
  flex-shrink: 0;
}

/* ── Mode Toggle ──────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-tertiary);
  transition: all var(--transition);
}
.mode-btn.active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.mode-btn:hover:not(.active):not(:disabled) { color: var(--ink-secondary); }
.mode-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Chat Status ──────────────────────────────────────────── */
.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-quaternary);
  font-weight: 500;
}
.chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* ── Chat Messages ────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 16px 0 24px;
  scroll-behavior: smooth;
}

.chat-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.65;
  animation: bubbleIn 0.3s ease;
}
.chat-bubble.bot {
  background: var(--bg-subtle);
  color: var(--ink);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
}
.chat-bubble.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}

.chat-bubble.bot h3 { font-size: 15px; margin: 10px 0 6px; font-weight: 700; }
.chat-bubble.bot h3:first-child { margin-top: 0; }
.chat-bubble.bot p { margin: 6px 0; color: var(--ink-secondary); }
.chat-bubble.bot ul, .chat-bubble.bot ol { margin: 6px 0 6px 18px; padding: 0; }
.chat-bubble.bot li { margin: 4px 0; }
.chat-bubble.bot strong { font-weight: 700; color: var(--ink); }

@keyframes bubbleIn {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Typing Indicator ─────────────────────────────────────── */
.chat-bubble.typing {
  color: var(--ink-tertiary);
  border-style: dashed;
  border-color: var(--border);
}
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-right: 6px;
  vertical-align: middle;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-quaternary);
  animation: typingDot 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 typingDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-5px); opacity: 1; }
}
.typing-label { font-weight: 600; font-size: 12px; color: var(--ink-quaternary); }

.chat-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  border-radius: 1px;
  transform: translateY(2px);
  animation: cursorBlink 1s steps(2) infinite;
}
@keyframes cursorBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ── Chat Input ───────────────────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  padding: 12px 0 24px;
  background: linear-gradient(to bottom, transparent, var(--bg) 12px);
}
.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 6px 6px 6px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 14px;
  outline: none;
  color: var(--ink);
}
.chat-input-wrapper input::placeholder { color: var(--ink-quaternary); }

/* ── Chat Suggestions ─────────────────────────────────────── */
.chat-suggestions { padding: 0 0 8px; }
.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggestion-link {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  color: var(--ink-secondary);
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.suggestion-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── Mic Button ───────────────────────────────────────────── */
.mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.mic-btn:hover { background: var(--accent-soft); }
.mic-btn.active {
  background: var(--accent);
  animation: micPulse 2s ease-in-out infinite;
}
.mic-btn.active .mic-icon { color: #fff; }
.mic-icon { width: 16px; height: 16px; color: var(--ink-secondary); }
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.3); }
  70% { box-shadow: 0 0 0 8px rgba(0, 113, 227, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0); }
}

/* ── Send Button ──────────────────────────────────────────── */
.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }

/* ── Voice Status ─────────────────────────────────────────── */
.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}
.voice-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-quaternary);
  font-weight: 500;
}
.voice-status.active { color: var(--accent); }
.voice-wave {
  display: inline-block;
  width: 14px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.3;
}
.voice-status.active .voice-wave {
  opacity: 1;
  animation: voicePulse 1.2s ease-in-out infinite;
}
@keyframes voicePulse {
  0% { transform: scaleX(0.6); opacity: 0.4; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(0.6); opacity: 0.4; }
}
.chat-voice-note { font-size: 11px; color: var(--ink-quaternary); }

/* ── MaterialWerkstatt ────────────────────────────────────── */
.atelier-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}
.atelier-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.atelier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.atelier-pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
}
.atelier-section-title {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}
.atelier-step {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-tertiary);
  background: var(--bg-subtle);
  margin-top: 16px;
}
.atelier-token-group { margin-top: 8px; }
.atelier-token-title { font-size: 12px; font-weight: 600; color: var(--ink-secondary); margin-bottom: 6px; }

/* ── Chips ────────────────────────────────────────────────── */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink-secondary);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chip.secondary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.atelier-composition {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--ink-tertiary);
  background: var(--bg-subtle);
}

.atelier-generate {
  margin-top: 16px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: all var(--transition);
}
.atelier-generate:hover { background: var(--accent-hover); }
.atelier-generate:disabled { opacity: 0.4; cursor: not-allowed; }
.atelier-generate-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
}
.atelier-generate-icon svg { width: 14px; height: 14px; }

/* ── Material Preview ─────────────────────────────────────── */
.material-preview {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-subtle);
  min-height: 400px;
}
.material-placeholder {
  height: 400px;
  background: linear-gradient(135deg, var(--bg-subtle), var(--bg-wash));
}
.material-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.material-progress {
  position: absolute;
  bottom: 12px;
  right: 14px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
}
.material-result { position: relative; border-radius: var(--radius-md); overflow: hidden; }
.material-result img { width: 100%; display: block; }
.material-download {
  position: absolute;
  right: 12px;
  bottom: 12px;
  opacity: 0;
  transform: translateY(4px);
  transition: all var(--transition);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.material-result:hover .material-download { opacity: 1; transform: translateY(0); }
.material-preview-error {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 59, 48, 0.15);
  background: rgba(255, 59, 48, 0.05);
  color: var(--error);
  font-size: 13px;
}

/* ── History ──────────────────────────────────────────────── */
.atelier-history { margin-top: 40px; }
.atelier-history-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.atelier-history-item {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.atelier-history-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.atelier-history-item img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; }
.atelier-history-caption { margin-top: 6px; font-size: 11px; color: var(--ink-tertiary); line-height: 1.3; }

/* ── Checkout ─────────────────────────────────────────────── */
.checkout-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}
.checkout-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
}
.checkout-summary .summary-list {
  margin: 16px 0;
  display: grid;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 13px;
}
.checkout-summary .summary-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
  font-weight: 700;
}

/* ── Account Dashboard ────────────────────────────────────── */
.account-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}
.account-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}
.account-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: all var(--transition);
}
.account-nav a:hover, .account-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.stat-label { font-size: 12px; color: var(--ink-tertiary); font-weight: 500; margin-top: 2px; }
.usage-bar {
  height: 6px;
  background: var(--bg-wash);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}
.usage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.usage-bar-fill.warning { background: var(--warning); }
.usage-bar-fill.critical { background: var(--error); }

/* ── Clinical Study ───────────────────────────────────────── */
.study-consent {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 640px;
}
.study-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: rgba(48, 209, 88, 0.08);
  color: #1a7a2e;
  border: 1px solid rgba(48, 209, 88, 0.2);
}
.progress-ring {
  width: 120px;
  height: 120px;
}
.progress-ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}
.progress-ring .bg { stroke: var(--bg-wash); }
.progress-ring .fill {
  stroke: var(--accent);
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.6s ease;
}

/* ── Responsive overrides ─────────────────────────────────── */
@media (max-width: 980px) {
  .atelier-grid { grid-template-columns: 1fr; }
  .atelier-history-grid { grid-template-columns: repeat(2, 1fr); }
  .checkout-grid { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .account-sidebar { position: static; }
  .account-nav { flex-direction: row; overflow-x: auto; gap: 4px; }
}
