/* ── Voice Assistant Panel ── */

.voice-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
}

/* ── Transcript area ── */
.voice-transcript {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 8px;
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  font-size: 0.9rem;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* History loading spinner */
.transcript-loading {
  text-align: center;
  padding: 12px;
  color: #666;
  font-size: 0.8rem;
}

.transcript-history-sep {
  text-align: center;
  font-size: 0.75rem;
  color: #555;
  padding: 4px 0;
  border-bottom: 1px solid #2a2a4a;
  margin-bottom: 4px;
}

.transcript-msg {
  display: flex;
  line-height: 1.5;
  max-width: 85%;
}

.transcript-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  word-break: break-word;
}

/* User messages — right aligned, magenta bubble */
.transcript-user {
  align-self: flex-end;
  justify-content: flex-end;
  cursor: pointer;
  transition: opacity 0.15s;
}

.transcript-user .transcript-bubble {
  background: #3a3a5a;
  color: #e0e0e0;
  border-bottom-right-radius: 4px;
}

/* Attachment indicators inside bubbles */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.msg-attachment {
  display: inline-block;
}
.msg-attach-thumb {
  max-width: 120px;
  max-height: 80px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.1);
}
.msg-attach-thumb:hover {
  border-color: rgba(255,255,255,0.3);
}
.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #aaa;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 3px 8px;
}

.transcript-user:hover {
  opacity: 0.85;
}

.transcript-user:active {
  opacity: 0.7;
}

/* Agent messages — left aligned, dark bubble */
.transcript-agent {
  align-self: flex-start;
  justify-content: flex-start;
}

.transcript-agent .transcript-bubble {
  background: #2a2a4a;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

/* System messages — centered, no bubble */
.transcript-system {
  align-self: center;
  max-width: 100%;
  opacity: 0.6;
  font-size: 0.8rem;
  font-style: italic;
  color: #888;
  text-align: center;
}

.transcript-system .transcript-bubble {
  background: none;
  padding: 2px 8px;
}

/* Interim (partial STT) */
.transcript-interim .transcript-bubble {
  background: #1e1e2e;
  color: #666;
  font-style: italic;
  border: 1px dashed #3a3a5a;
}

/* ── Input area ── */
.voice-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.voice-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#voice-input {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: 0.9rem;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  font-family: inherit;
  transition: border-color 0.2s;
}

#voice-input:focus {
  outline: none;
  border-color: #e91e8c;
}

#voice-input::placeholder {
  color: #555;
}

/* Attachment preview pills */
#voice-attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attach-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #2a2a4a;
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: #ccc;
}

.attach-thumb {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
}

.attach-remove {
  background: none;
  border: none;
  color: #e91e8c;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  line-height: 1;
}

/* Buttons */
.voice-btn {
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 8px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 8px 12px;
  transition: all 0.2s;
  min-width: 42px;
  text-align: center;
}

.voice-btn:hover {
  background: #3a3a5a;
  border-color: #e91e8c;
}

.voice-btn.muted {
  background: #4a1a2e;
  border-color: #e91e8c;
}

#voice-send {
  background: #e91e8c;
  border-color: #e91e8c;
  color: #fff;
  font-weight: 600;
  padding: 8px 16px;
}

#voice-send:hover {
  background: #c4186f;
}

/* ── TTS Output Visualizer (header) ── */
.tts-viz-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 44px;
  flex: 1;
  margin: 0 12px;
  opacity: 0.2;
  transition: opacity 0.3s ease;
}

.tts-viz-bars.active {
  opacity: 1;
}

.tts-viz-bars.thinking .tts-bar {
  background: #f5a623;
}

.tts-viz-bars.done .tts-bar {
  background: #555;
}

.tts-bar {
  width: 4px;
  height: 4px;
  background: #e91e8c;
  border-radius: 2px;
  transition: height 0.08s ease;
}

/* Thinking bounce animation */
@keyframes thinking-bounce {
  0%, 100% { height: 4px; }
  50% { height: 18px; }
}

.tts-viz-bars.thinking .tts-bar {
  animation: thinking-bounce 1.2s ease-in-out infinite;
}

/* Stagger animation delay across bars */
.tts-viz-bars.thinking .tts-bar:nth-child(1)  { animation-delay: 0.00s; }
.tts-viz-bars.thinking .tts-bar:nth-child(2)  { animation-delay: 0.05s; }
.tts-viz-bars.thinking .tts-bar:nth-child(3)  { animation-delay: 0.10s; }
.tts-viz-bars.thinking .tts-bar:nth-child(4)  { animation-delay: 0.15s; }
.tts-viz-bars.thinking .tts-bar:nth-child(5)  { animation-delay: 0.20s; }
.tts-viz-bars.thinking .tts-bar:nth-child(6)  { animation-delay: 0.25s; }
.tts-viz-bars.thinking .tts-bar:nth-child(7)  { animation-delay: 0.30s; }
.tts-viz-bars.thinking .tts-bar:nth-child(8)  { animation-delay: 0.35s; }
.tts-viz-bars.thinking .tts-bar:nth-child(9)  { animation-delay: 0.40s; }
.tts-viz-bars.thinking .tts-bar:nth-child(10) { animation-delay: 0.45s; }
.tts-viz-bars.thinking .tts-bar:nth-child(11) { animation-delay: 0.50s; }
.tts-viz-bars.thinking .tts-bar:nth-child(12) { animation-delay: 0.55s; }
.tts-viz-bars.thinking .tts-bar:nth-child(13) { animation-delay: 0.60s; }
.tts-viz-bars.thinking .tts-bar:nth-child(14) { animation-delay: 0.65s; }
.tts-viz-bars.thinking .tts-bar:nth-child(15) { animation-delay: 0.70s; }
.tts-viz-bars.thinking .tts-bar:nth-child(16) { animation-delay: 0.75s; }
.tts-viz-bars.thinking .tts-bar:nth-child(17) { animation-delay: 0.80s; }
.tts-viz-bars.thinking .tts-bar:nth-child(18) { animation-delay: 0.85s; }
.tts-viz-bars.thinking .tts-bar:nth-child(19) { animation-delay: 0.90s; }
.tts-viz-bars.thinking .tts-bar:nth-child(20) { animation-delay: 0.95s; }
.tts-viz-bars.thinking .tts-bar:nth-child(21) { animation-delay: 1.00s; }

/* ── Mic Input Visualizer (bottom) ── */
.voice-viz-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.voice-viz-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 44px;
}

.viz-bar {
  width: 4px;
  height: 4px;
  background: #e91e8c;
  border-radius: 2px;
  transition: height 0.08s ease;
}

.voice-state {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #aaa;
  margin-left: 10px;
  white-space: nowrap;
}

.voice-state-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
  transition: background-color 0.3s;
}

.voice-state-dot.pulse {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px currentColor; }
  50% { opacity: 0.6; box-shadow: 0 0 12px currentColor; }
}

/* Start button */
#voice-start {
  background: #e91e8c;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 24px;
  transition: all 0.2s;
}

#voice-start:hover {
  background: #c4186f;
  transform: translateY(-1px);
}

/* ── Voice Settings Modal ── */
.voice-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.voice-modal-overlay.active {
  display: flex;
}

.voice-modal {
  background: #1e1e2e;
  border: 1px solid #3a3a5a;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.voice-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a4a;
}

.voice-modal-header h3 {
  margin: 0;
  color: #e0e0e0;
}

.voice-modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  cursor: pointer;
}

.voice-modal-close:hover {
  color: #e91e8c;
}

.voice-modal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid #2a2a4a;
}

.voice-filter {
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 6px 10px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 120px;
}

.voice-filter:focus {
  outline: none;
  border-color: #e91e8c;
}

/* ── Voice Style Panel ── */

.voice-style-panel {
  padding: 12px 20px;
  border-bottom: 1px solid #2a2a4a;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-style-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-style-degree {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-style-label {
  color: #aaa;
  font-size: 0.85rem;
  min-width: 60px;
}

.voice-style-panel .voice-filter {
  flex: 1;
}

.voice-degree-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #2a2a4a;
  outline: none;
}

.voice-degree-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e91e8c;
  cursor: pointer;
  border: 2px solid #1a1a2e;
}

.voice-degree-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e91e8c;
  cursor: pointer;
  border: 2px solid #1a1a2e;
}

#voice-style-degree-val {
  color: #e0e0e0;
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 35px;
  text-align: right;
}

.voice-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.voice-list-loading, .voice-list-more {
  text-align: center;
  color: #888;
  padding: 20px;
  font-size: 0.9rem;
}

.voice-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.voice-item:hover {
  background: #2a2a4a;
}

.voice-item-active {
  background: #2a1a3a;
  border: 1px solid #e91e8c;
}

.voice-item-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.voice-item-name {
  color: #e0e0e0;
  font-weight: 500;
  font-size: 0.9rem;
}

.voice-item-tier {
  color: #f5a623;
  font-size: 0.8rem;
}

.voice-item-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: #888;
}

.voice-item-styles {
  color: #bb86fc;
}

/* ── "+" attach toggle button ── */
#voice-attach-toggle {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  padding: 6px 12px;
}

/* ── TTS Replay Button ── */
.transcript-agent {
  position: relative;
}

.transcript-replay {
  position: absolute;
  bottom: -2px;
  right: -8px;
  background: #1a1a2e;
  border: 1px solid #3a3a5a;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  padding: 0;
  line-height: 1;
}

.transcript-agent:hover .transcript-replay {
  opacity: 0.7;
}

.transcript-replay:hover {
  opacity: 1 !important;
  background: #2a2a4a;
  border-color: #e91e8c;
}

.transcript-replay:disabled {
  cursor: wait;
  opacity: 0.4 !important;
}

/* ── Markdown inside agent bubbles ── */
.transcript-agent .transcript-bubble p {
  margin: 0 0 0.5em 0;
}

.transcript-agent .transcript-bubble p:last-child {
  margin-bottom: 0;
}

.transcript-agent .transcript-bubble code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.transcript-agent .transcript-bubble pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 0.85em;
}

.transcript-agent .transcript-bubble pre code {
  background: none;
  padding: 0;
}

.transcript-agent .transcript-bubble a {
  color: #bb86fc;
  text-decoration: underline;
  text-decoration-color: rgba(187, 134, 252, 0.4);
  transition: text-decoration-color 0.2s;
}

.transcript-agent .transcript-bubble a:hover {
  text-decoration-color: #bb86fc;
}

.transcript-agent .transcript-bubble ul,
.transcript-agent .transcript-bubble ol {
  margin: 4px 0;
  padding-left: 1.4em;
}

.transcript-agent .transcript-bubble li {
  margin: 2px 0;
}

.transcript-agent .transcript-bubble blockquote {
  border-left: 3px solid #e91e8c;
  margin: 6px 0;
  padding: 4px 10px;
  color: #aaa;
}

.transcript-agent .transcript-bubble h1,
.transcript-agent .transcript-bubble h2,
.transcript-agent .transcript-bubble h3,
.transcript-agent .transcript-bubble h4,
.transcript-agent .transcript-bubble h5,
.transcript-agent .transcript-bubble h6 {
  margin: 8px 0 4px 0;
  font-size: 1em;
  color: #e0e0e0;
}

.transcript-agent .transcript-bubble h1 { font-size: 1.15em; }
.transcript-agent .transcript-bubble h2 { font-size: 1.1em; }
.transcript-agent .transcript-bubble h3 { font-size: 1.05em; }

.transcript-agent .transcript-bubble hr {
  border: none;
  border-top: 1px solid #3a3a5a;
  margin: 8px 0;
}

.transcript-agent .transcript-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
  font-size: 0.85em;
}

.transcript-agent .transcript-bubble th,
.transcript-agent .transcript-bubble td {
  border: 1px solid #3a3a5a;
  padding: 4px 8px;
  text-align: left;
}

.transcript-agent .transcript-bubble th {
  background: rgba(255, 255, 255, 0.05);
}

.transcript-agent .transcript-bubble img {
  max-width: 100%;
  border-radius: 6px;
  margin: 4px 0;
}

/* ── Camera modal ── */
.camera-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-modal {
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  max-width: 640px;
  width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.camera-viewfinder {
  width: 100%;
  display: block;
  background: #000;
  min-height: 240px;
  max-height: 60vh;
  object-fit: cover;
}
.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  background: #1a1a2e;
}
.camera-snap-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s;
}
.camera-snap-btn::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
  transition: background 0.1s;
}
.camera-snap-btn:hover::after {
  background: #e0e0e0;
}
.camera-snap-btn:active {
  transform: scale(0.9);
}
.camera-switch-btn,
.camera-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.camera-switch-btn:hover,
.camera-close-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .voice-transcript {
    height: 200px;
  }

  .voice-input-row {
    flex-wrap: wrap;
  }

  .voice-btn {
    padding: 8px;
  }
}
