/* ==========================================================================
   N4C.VN - AI VOICE STUDIO STYLESHEET
   Consistent with main N4C Design System:
     Porcelain White (#FFF / #F8FAFC) + Mint Emerald (#10B981) + 
     Warm Amber (#F59E0B) + Gradient CTA
   ========================================================================== */

/* ── Container & Layout ─────────────────────────────────────────────────── */
.tts-studio-section {
  padding: 60px 0 80px;
  background: linear-gradient(180deg, #F0FDF9 0%, #FFFFFF 40%, #F8FAFC 100%);
  min-height: 100vh;
}

.tts-studio-header {
  text-align: center;
  margin-bottom: 40px;
}

.tts-studio-header h2 {
  font-size: 2.1rem;
  font-weight: 800;
  color: #0F172A;
  line-height: 1.3;
  margin-bottom: 10px;
}
.tts-studio-header h2 .tts-gradient-text {
  background: linear-gradient(135deg, #10B981, #059669, #047857);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tts-studio-header p {
  font-size: 1.05rem;
  color: #64748B;
  max-width: 620px;
  margin: 0 auto;
}

/* ── Mode Switcher (Tab Bar) ────────────────────────────────────────────── */
.tts-mode-switcher {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 32px;
  background: #F1F5F9;
  border-radius: 14px;
  padding: 5px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.tts-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: #64748B;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}
.tts-mode-btn:hover {
  color: #334155;
  background: rgba(255,255,255,0.6);
}
.tts-mode-btn.active {
  background: #FFFFFF;
  color: #059669;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tts-mode-btn .tts-mode-icon {
  font-size: 1.15rem;
}
.tts-badge-new {
  display: inline-block;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
}

/* ── Main Workspace Grid ────────────────────────────────────────────────── */
.tts-workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .tts-workspace {
    grid-template-columns: 1fr;
  }
}

/* ── Voice Selection Sidebar ────────────────────────────────────────────── */
.tts-voice-panel {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.04);
}

.tts-voice-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

/* Voice Cards */
.tts-voice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}
.tts-voice-list::-webkit-scrollbar { width: 4px; }
.tts-voice-list::-webkit-scrollbar-track { background: #F1F5F9; border-radius: 10px; }
.tts-voice-list::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

.tts-voice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #F8FAFC;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.tts-voice-card:hover {
  background: #F0FDF9;
  border-color: #A7F3D0;
}
.tts-voice-card.active {
  background: #ECFDF5;
  border-color: #10B981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

.tts-voice-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.tts-voice-avatar.female { background: linear-gradient(135deg, #FECACA, #FDE68A); }
.tts-voice-avatar.male { background: linear-gradient(135deg, #BFDBFE, #A5F3FC); }
.tts-voice-avatar.clone { background: linear-gradient(135deg, #C4B5FD, #F9A8D4); }

.tts-voice-info {
  flex: 1;
  min-width: 0;
}
.tts-voice-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0F172A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tts-voice-desc {
  font-size: 0.75rem;
  color: #94A3B8;
  margin-top: 2px;
}

.tts-voice-preview-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #E2E8F0;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.tts-voice-preview-btn:hover {
  background: #10B981;
  color: #fff;
}

.tts-voice-tag {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.tts-voice-tag.tag-ai { background: #DBEAFE; color: #1D4ED8; }
.tts-voice-tag.tag-studio { background: #FEF3C7; color: #92400E; }
.tts-voice-tag.tag-preset { background: #E0E7FF; color: #4338CA; }

/* ── Upload Zone (Clone Mode) ───────────────────────────────────────────── */
.tts-clone-upload-zone {
  margin-top: 16px;
  display: none;
}
.tts-clone-upload-zone.visible {
  display: block;
}

.tts-upload-dropzone {
  border: 2px dashed #CBD5E1;
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: #FAFBFC;
}
.tts-upload-dropzone:hover,
.tts-upload-dropzone.drag-over {
  border-color: #10B981;
  background: #F0FDF9;
}

.tts-upload-icon { font-size: 2rem; margin-bottom: 8px; }
.tts-upload-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}
.tts-upload-hint {
  font-size: 0.75rem;
  color: #94A3B8;
}

.tts-uploaded-file {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: #ECFDF5;
  border: 1.5px solid #10B981;
  border-radius: 14px;
  margin-top: 10px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
}
.tts-uploaded-file.visible {
  display: flex;
}
.tts-uploaded-file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.tts-uploaded-file-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: #065F46;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tts-uploaded-file-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #FEE2E2;
  color: #DC2626;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.2s;
}
.tts-uploaded-file-remove:hover {
  background: #EF4444;
  color: #FFFFFF;
}

.tts-ref-player-wrap {
  width: 100%;
  display: flex;
  align-items: center;
}
.tts-ref-player {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  outline: none;
}

.tts-ref-text-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  font-size: 0.82rem;
  color: #334155;
  background: #fff;
  resize: none;
  height: 56px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.tts-ref-text-input:focus {
  outline: none;
  border-color: #10B981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}
.tts-ref-text-input::placeholder { color: #94A3B8; }

/* ── Main Editor Panel ──────────────────────────────────────────────────── */
.tts-editor-panel {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.04);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Text Input Area */
.tts-text-area-wrap {
  position: relative;
}
.tts-text-area {
  width: 100%;
  min-height: 180px;
  padding: 18px 18px 40px;
  border: 2px solid #E2E8F0;
  border-radius: 14px;
  font-size: 1rem;
  line-height: 1.7;
  color: #0F172A;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  resize: vertical;
  transition: border-color 0.2s;
  background: #FAFBFC;
}
.tts-text-area:focus {
  outline: none;
  border-color: #10B981;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(16,185,129,0.08);
}
.tts-text-area::placeholder { color: #94A3B8; }

.tts-char-count {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.75rem;
  color: #94A3B8;
  pointer-events: none;
}
.tts-char-count.warning { color: #F59E0B; }
.tts-char-count.danger { color: #EF4444; }

/* ── Controls Row ───────────────────────────────────────────────────────── */
.tts-controls-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.tts-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tts-control-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748B;
  white-space: nowrap;
}

.tts-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 6px;
  border-radius: 6px;
  background: #E2E8F0;
  outline: none;
  transition: background 0.2s;
}
.tts-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #10B981;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16,185,129,0.3);
}
.tts-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #10B981;
  cursor: pointer;
  border: none;
}

.tts-slider-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0F172A;
  min-width: 36px;
  text-align: center;
}

/* ── Generate Button ────────────────────────────────────────────────────── */
.tts-generate-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tts-btn-generate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 20px rgba(16,185,129,0.35);
  min-height: 52px;
}
.tts-btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(16,185,129,0.45);
}
.tts-btn-generate:active {
  transform: translateY(0);
}
.tts-btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.tts-btn-generate .tts-btn-icon {
  font-size: 1.2rem;
}

/* Loading Spinner */
.tts-btn-generate .spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tts-spin 0.8s linear infinite;
}
.tts-btn-generate.loading .spinner { display: block; }
.tts-btn-generate.loading .tts-btn-icon { display: none; }
.tts-btn-generate.loading .tts-btn-label { display: none; }

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

/* ── Audio Player Result ────────────────────────────────────────────────── */
.tts-result-panel {
  display: none;
  background: #F0FDF9;
  border: 1px solid #A7F3D0;
  border-radius: 16px;
  padding: 20px;
}
.tts-result-panel.visible {
  display: block;
  animation: tts-fadeIn 0.4s ease;
}

@keyframes tts-fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.tts-result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.tts-result-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #065F46;
}
.tts-result-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: #10B981;
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.tts-audio-player {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  outline: none;
}

.tts-result-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.tts-btn-action {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border: 1px solid #D1FAE5;
  border-radius: 10px;
  background: #FFFFFF;
  color: #065F46;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tts-btn-action:hover {
  background: #ECFDF5;
  border-color: #10B981;
}
.tts-btn-action.primary {
  background: #10B981;
  color: #fff;
  border-color: #059669;
}
.tts-btn-action.primary:hover {
  background: #059669;
}

/* ── Status / Error Messages ────────────────────────────────────────────── */
.tts-status-msg {
  display: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.5;
}
.tts-status-msg.visible { display: block; }
.tts-status-msg.info {
  background: #EFF6FF;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}
.tts-status-msg.error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}
.tts-status-msg.success {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

/* ── Feature Badges Row ─────────────────────────────────────────────────── */
.tts-features-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.tts-feature-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.tts-feature-badge-icon { font-size: 1.2rem; }
.tts-feature-badge-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

/* ── Mic Recording Indicator ────────────────────────────────────────────── */
.tts-mic-recording {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 12px;
  margin-top: 10px;
}
.tts-mic-recording.visible {
  display: flex;
}
.tts-mic-pulse {
  width: 12px;
  height: 12px;
  background: #EF4444;
  border-radius: 50%;
  animation: tts-pulse 1s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}
.tts-mic-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #991B1B;
  flex: 1;
}
.tts-mic-timer {
  font-size: 0.88rem;
  font-weight: 700;
  color: #EF4444;
  font-variant-numeric: tabular-nums;
}
.tts-mic-stop-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: #EF4444;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tts-studio-section { padding: 30px 0 50px; }
  .tts-studio-header h2 { font-size: 1.5rem; }
  .tts-mode-switcher { max-width: 100%; }
  .tts-voice-list { max-height: 280px; }
  .tts-text-area { min-height: 140px; font-size: 0.92rem; }
  .tts-controls-row { gap: 10px; }
  .tts-slider { width: 90px; }
}

@media (max-width: 480px) {
  .tts-studio-header h2 { font-size: 1.3rem; }
  .tts-mode-btn { font-size: 0.8rem; padding: 10px 12px; }
  .tts-voice-card { padding: 10px 12px; gap: 10px; }
  .tts-voice-avatar { width: 38px; height: 38px; font-size: 1.1rem; }
  .tts-editor-panel { padding: 16px; }
  .tts-text-area { min-height: 120px; padding: 14px 14px 36px; }
  .tts-features-row { gap: 10px; }
  .tts-feature-badge { padding: 8px 12px; }
}
