/* ═══════════════════════════════════════════════════════════════
   Voice Recorder Widget — Standalone reusable component
   Used by: EST, TEV, ESL, PEV (and any future consumer)
   ═══════════════════════════════════════════════════════════════ */

.voice-recorder {
  font-family: 'Outfit', sans-serif;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
}

.voice-recorder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  user-select: none;
}

.voice-recorder-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #1f2937;
}

.voice-recorder-header-left .vr-status-icon {
  font-size: 1.1rem;
}

.voice-recorder-toggle {
  font-size: 0.8rem;
  color: #6b7280;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.voice-recorder-toggle:hover {
  background: #e5e7eb;
}

.voice-recorder-body {
  padding: 16px;
}

/* Collapsed state */
.voice-recorder.collapsed .voice-recorder-body {
  display: none;
}

/* ── Customer Home Toggle ─────────────────────────────────── */

.customer-home-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.customer-home-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
}

.toggle-options {
  display: flex;
  gap: 8px;
}

.toggle-option {
  padding: 6px 16px;
  border-radius: 20px;
  border: 2px solid #d1d5db;
  background: white;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  color: #6b7280;
}

.toggle-option:hover {
  border-color: #9ca3af;
}

.toggle-option.active {
  border-color: var(--primary-green, #2d5a3d);
  background: var(--primary-green, #2d5a3d);
  color: white;
}

.customer-home-hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 4px;
  font-style: italic;
}

/* ── Record Button (idle state) ───────────────────────────── */

.record-btn {
  width: 100%;
  padding: 24px 20px;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #fafafa;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.record-btn:hover {
  border-color: var(--primary-green, #2d5a3d);
  background: #f0fdf4;
}

.record-btn:active {
  transform: scale(0.98);
}

.record-btn .mic-icon {
  font-size: 2rem;
}

.record-btn .record-label {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 500;
}

/* ── Divider ──────────────────────────────────────────────── */

.voice-recorder-divider {
  text-align: center;
  color: #9ca3af;
  font-size: 0.8rem;
  margin: 16px 0;
  position: relative;
}

.voice-recorder-divider::before,
.voice-recorder-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #e5e7eb;
}

.voice-recorder-divider::before { left: 0; }
.voice-recorder-divider::after { right: 0; }

/* ── Alt Actions (upload / type) ──────────────────────────── */

.voice-recorder-alt-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.alt-action-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: white;
  cursor: pointer;
  font-size: 0.85rem;
  color: #374151;
  font-weight: 500;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.alt-action-btn:hover {
  border-color: var(--primary-green, #2d5a3d);
  color: var(--primary-green, #2d5a3d);
}

/* ── Recording Active State ───────────────────────────────── */

.recording-active {
  background: #fef2f2;
  border: 2px solid #ef4444;
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
}

.recording-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.recording-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  animation: vr-pulse-dot 1.5s ease-in-out infinite;
}

@keyframes vr-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.recording-status-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ef4444;
}

.recording-timer {
  font-size: 1.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #ef4444;
  margin: 8px 0 16px;
}

.recording-max-hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 12px;
}

/* Stop button */
.stop-btn {
  padding: 12px 36px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s;
}

.stop-btn:hover {
  background: #dc2626;
}

.stop-btn:active {
  transform: scale(0.97);
}

/* ── Audio Playback ───────────────────────────────────────── */

.audio-playback {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 12px;
}

.play-pause-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-green, #2d5a3d);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background 0.15s;
}

.play-pause-btn:hover {
  background: #1e4a2e;
}

.audio-progress-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audio-progress {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.audio-progress-fill {
  height: 100%;
  background: var(--primary-green, #2d5a3d);
  border-radius: 3px;
  transition: width 0.1s linear;
  width: 0%;
}

.audio-time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}

.audio-duration {
  font-size: 0.85rem;
  color: #888;
  font-variant-numeric: tabular-nums;
  min-width: 45px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Transcript Display ───────────────────────────────────── */

.transcript-section {
  margin: 12px 0;
}

.transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.transcript-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.transcript-edit-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  cursor: pointer;
  font-size: 0.8rem;
  color: #6b7280;
  transition: all 0.15s;
}

.transcript-edit-btn:hover {
  border-color: var(--primary-green, #2d5a3d);
  color: var(--primary-green, #2d5a3d);
}

.transcript-display {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #374151;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.transcript-edit {
  width: 100%;
  min-height: 120px;
  border: 2px solid var(--primary-green, #2d5a3d);
  border-radius: 8px;
  padding: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

/* ── Manual Input (textarea path) ─────────────────────────── */

.manual-input-section {
  margin-top: 8px;
}

.manual-input-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.manual-input-textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.manual-input-textarea:focus {
  border-color: var(--primary-green, #2d5a3d);
}

.manual-input-textarea::placeholder {
  color: #9ca3af;
}

/* ── File Upload Info ─────────────────────────────────────── */

.file-upload-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #166534;
}

.file-upload-info .file-name {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-upload-info .file-size {
  color: #6b7280;
  flex-shrink: 0;
}

.file-upload-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 1.1rem;
  padding: 0 4px;
  flex-shrink: 0;
}

.file-upload-remove:hover {
  color: #ef4444;
}

/* ── Transcribing Spinner ─────────────────────────────────── */

.transcribing-state {
  text-align: center;
  padding: 32px 16px;
  color: #6b7280;
}

.transcribing-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--primary-green, #2d5a3d);
  border-radius: 50%;
  animation: vr-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes vr-spin {
  to { transform: rotate(360deg); }
}

.transcribing-text {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.transcribing-hint {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ── Error State ──────────────────────────────────────────── */

.voice-recorder-error {
  text-align: center;
  padding: 20px;
  color: #dc2626;
}

.voice-recorder-error .error-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.voice-recorder-error .error-message {
  font-size: 0.9rem;
  margin-bottom: 16px;
  color: #991b1b;
}

/* ── Action Buttons ───────────────────────────────────────── */

.voice-recorder-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.voice-recorder-actions button {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  border: none;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vr-btn-primary {
  background: var(--primary-green, #2d5a3d);
  color: white;
}

.vr-btn-primary:hover {
  background: #1e4a2e;
}

.vr-btn-secondary {
  background: white;
  color: #374151;
  border: 1px solid #d1d5db !important;
}

.vr-btn-secondary:hover {
  border-color: #9ca3af !important;
}

.vr-btn-danger {
  background: white;
  color: #ef4444;
  border: 1px solid #fecaca !important;
}

.vr-btn-danger:hover {
  background: #fef2f2;
}

/* ── Hidden file input ────────────────────────────────────── */

.voice-recorder input[type="file"] {
  display: none;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {
  .voice-recorder-actions {
    flex-direction: column;
  }
  .voice-recorder-actions button {
    width: 100%;
    justify-content: center;
  }
  .voice-recorder-alt-actions {
    flex-direction: column;
  }
  .alt-action-btn {
    justify-content: center;
  }
  .customer-home-toggle {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
