/* ---------------------------------------
   TTS / Voice Studio – layout & styling
   Matches Mojoe dark style / Image Studio
--------------------------------------- */

.tts-panel {
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.tts-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tts-header-main h1 {
  margin: 0;
  font-size: 20px;
}

.tts-header-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--sub, #94a3b8);
}

.tts-current-voice {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.6);
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
}

/* Layout */

.tts-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
  align-items: start;
}

.tts-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.tts-column-left {
  grid-column: 1;
}

.tts-column-right {
  grid-column: 2;
}

.tts-column-full {
  grid-column: 1 / -1;
}

/* Cards */

.tts-card {
  border-radius: 18px;
  padding: 12px 14px;
  background: radial-gradient(
    circle at 0 0,
    rgba(15, 23, 42, 1),
    rgba(2, 6, 23, 1)
  );
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.tts-card-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.tts-card-header h2 {
  margin: 0;
  font-size: 15px;
}

.tts-card-sub {
  margin: 0;
  font-size: 12px;
  color: var(--sub, #94a3b8);
}

/* Collapsible cards (match credits animation style) */

.tts-card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tts-card-body {
  max-height: 600px;
  opacity: 1;
  overflow: hidden;
  transition:
    max-height 220ms ease-out,
    opacity 180ms ease-out;
}

.tts-card.tts-collapsible.collapsed .tts-card-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Toggle button (chevron) */

.tts-card-toggle {
  margin-left: 10px;
  border: none;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.5);
}

.tts-card.tts-collapsible .tts-card-toggle {
  transform: rotate(0deg);
  transition: transform 160ms ease-out;
}

.tts-card.tts-collapsible.collapsed .tts-card-toggle {
  transform: rotate(-90deg);
}

/* Voice source tabs */

.tts-voice-source-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(51, 65, 85, 0.9);
  margin-bottom: 10px;
}

.tts-source-tab {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  color: #e5e7eb;
}

.tts-source-tab.active {
  background: radial-gradient(circle at 0 0, #fb37a0, #38bdf8);
  color: #f9fafb;
}

/* Voice lists */

.tts-voice-lists {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tts-voice-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tts-voice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
  cursor: pointer;
}

.tts-voice-item-main {
  display: flex;
  flex-direction: column;
}

.tts-voice-name {
  font-size: 13px;
  color: #e5e7eb;
}

.tts-voice-meta {
  font-size: 11px;
  color: var(--sub, #94a3b8);
}

.tts-voice-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tts-voice-play-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  cursor: pointer;
}

.tts-voice-item.selected {
  border-color: rgba(248, 113, 113, 0.9);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.4);
}

/* Empty state */

.tts-empty-state {
  font-size: 12px;
  color: var(--sub, #94a3b8);
  padding: 4px 0;
}

/* Voice cloning */

.tts-field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #e5e7eb;
  margin-bottom: 8px;
}

.tts-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
  color: #f9fafb;
  font-size: 13px;
  padding: 7px 9px;
  outline: none;
}

.tts-input:focus {
  border-color: rgba(59, 130, 246, 0.9);
}

.tts-dropzone {
  position: relative;
  border-radius: 14px;
  border: 1px dashed rgba(71, 85, 105, 0.9);
  background: rgba(15, 23, 42, 0.96);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.tts-dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.tts-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.tts-dropzone-title {
  margin: 0;
  font-size: 13px;
  color: #e5e7eb;
}

.tts-dropzone-sub {
  margin: 0;
  font-size: 11px;
  color: var(--sub, #94a3b8);
}

.tts-dropzone-file {
  margin: 4px 0 0;
  font-size: 11px;
  color: #a5b4fc;
}

.tts-clone-btn {
  margin-top: 6px;
}

.tts-hint {
  margin-top: 6px;
  color: var(--sub, #94a3b8);
}

.tts-status {
  margin-top: 4px;
  min-height: 14px;
}

/* Prompt & settings */

.tts-textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
  color: #f9fafb;
  font-size: 13px;
  padding: 8px 10px;
  min-height: 300px;
  max-height: 360px;
  resize: none;
  outline: none;
}

.tts-textarea:focus {
  border-color: rgba(59, 130, 246, 0.9);
}

.tts-word-counter {
  margin-top: 4px;
  font-size: 11px;
  color: var(--sub, #94a3b8);
  text-align: right;
}

.tts-settings-row {
  display: flex;
  flex-direction: row;
  gap: 12px;
  margin-top: 10px;
}

.tts-setting {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tts-setting-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #e5e7eb;
}

.tts-setting-value {
  color: #a5b4fc;
}

.tts-setting input[type="range"] {
  width: 100%;
}

.tts-setting-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--sub, #94a3b8);
}

/* Generate strip */

.tts-generate-strip {
  display: inline-flex;            /* shrink to content like Video/I2V */
  align-items: center;
  gap: 10px;
  row-gap: 10px;
  flex-wrap: wrap;                 /* mobile-safe */
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: radial-gradient(
    circle at 0 0,
    rgba(248, 113, 113, 0.22),
    rgba(15, 23, 42, 0.96)
  );
  border: 1px solid rgba(55, 65, 81, 0.9);
  max-width: 100%;
}


.tts-generate-btn {
  flex: 0 0 auto;
  min-width: 130px;
  justify-content: center;
  text-align: center;
}

.tts-generate-strip .tts-status {
  flex: 1;
}
.tts-price-pill {
  flex: 0 0 auto;
  font-size: 11px;
  color: #a5b4fc;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
  white-space: nowrap;
}


/* Gallery */

.tts-audio-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.tts-audio-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
}

.tts-audio-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.tts-audio-label {
  color: #e5e7eb;
}

.tts-audio-meta {
  font-size: 11px;
  color: var(--sub, #94a3b8);
}

.tts-audio-player {
  width: 100%;
}

.tts-audio-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.tts-audio-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 3px 9px;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  cursor: pointer;
}

.tts-audio-btn.danger {
  border-color: rgba(248, 113, 113, 0.9);
  color: #fecaca;
}
/* Voice dropdown + selected preview */

.tts-field-label.small {
  font-size: 11px;
  margin-bottom: 4px;
}

.tts-voice-select-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.tts-select {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  background: rgba(15, 23, 42, 0.96);
  color: #f9fafb;
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
}

.tts-select:focus {
  border-color: rgba(59, 130, 246, 0.9);
}

.tts-selected-voice-preview {
  margin-top: 4px;
}

.tts-selected-voice-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.9);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.4),
    0 0 18px rgba(248, 113, 113, 0.35);
}



/* Helpers */

.hidden {
  display: none !important;
}

/* Mobile */

@media (max-width: 768px) {
  .tts-layout {
    grid-template-columns: 1fr;
  }

  .tts-column-left,
  .tts-column-right,
  .tts-column-full {
    grid-column: 1;
  }

  .tts-settings-row {
    flex-direction: column;
  }

  .tts-audio-list {
    max-height: 260px;
  }
}

/* Fix mobile wrapping for TTS status text */
.tts-generate-strip {
  flex-wrap: wrap; /* Allow wrapping */
  justify-content: space-between;
  height: auto;
  min-height: 50px;
  padding-right: 16px; /* Ensure space for right-aligned text */
}

.tts-btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto; /* don't stretch - keeps Cost close to Generate */
}

/* Force text to new line */
.tts-status.small {
  width: 100%;
  margin-top: 10px;
  text-align: right;
  order: 3;
  line-height: 1.4;
  color: #fb37a0; /* Make status text pink/accent color */
}

/* Desktop: reset to single line */
@media (min-width: 600px) {
  .tts-status.small {
    width: auto;
    margin-top: 0;
    text-align: left;
    order: 0;
  }
}

/* --- Cool Selected Voice Panel --- */
.tts-voice-preview-card {
  margin-top: 12px;
  background: rgba(10, 14, 28, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tts-preview-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.tts-preview-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
}

.tts-preview-badge {
  font-size: 10px;
  text-transform: uppercase;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.tts-preview-mute {
  font-size: 11px;
  padding: 4px;
  text-align: center;
}

/* --- Custom Dark Audio Player (No more white bars) --- */
.custom-audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 14, 28, 0.8); /* Dark Navy */
  border: 1px solid rgba(56, 189, 248, 0.3); /* Subtle Blue Border */
  border-radius: 12px;
  padding: 8px 12px;
  width: 100%;
  min-width: 240px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: border-color 0.2s;
}

.custom-audio-player:hover {
  border-color: rgba(56, 189, 248, 0.6);
}

/* The Play/Pause Button */
.cap-play-btn {
  background: none;
  border: none;
  color: #38bdf8; /* Neon Blue */
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  transition: all 0.2s ease;
}

.cap-play-btn:hover {
  color: #fff;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
  transform: scale(1.05);
}

/* The Progress Bar Track */
.cap-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* The Progress Fill (Gradient) */
.cap-progress {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #fb37a0); /* Blue to Pink */
  width: 0%;
  border-radius: 999px;
  transition: width 0.1s linear;
}

/* Time Label */
.cap-time {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace; /* Digital clock look */
  min-width: 35px;
  text-align: right;
}

/* --- Cool Selected Voice Panel (Preview) --- */
.tts-voice-preview-card {
  margin-top: 12px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(10, 14, 28, 0.9));
  border: 1px solid rgba(251, 113, 133, 0.4); /* Pink/Red tint for active selection */
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

.tts-preview-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tts-preview-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.tts-preview-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(251, 113, 133, 0.15);
  color: #fb7185;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(251, 113, 133, 0.3);
}

.tts-preview-mute {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  padding: 8px;
  border: 1px dashed rgba(100, 116, 139, 0.3);
  border-radius: 8px;
}

/* Fix Gallery Action Buttons Alignment */
.tts-audio-actions-row {
  margin-left: 10px;
  display: flex;
  align-items: center;
}

/* ---------------------------------------------------
   Mobile (match Image Studio): stack Generate/Stop/Cost/Status
   Only affects small screens.
--------------------------------------------------- */
@media (max-width: 680px) {
  .tts-generate-strip {
    flex-wrap: wrap;
    border-radius: 18px;
    justify-content: flex-start;
    padding-right: 12px; /* undo desktop tweak */
  }

  .tts-btn-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .tts-generate-btn,
  .tts-stop-btn {
    width: 100%;
    min-width: 0;
  }

  .tts-price-pill {
    width: 100%;
    white-space: normal; /* allow wrap instead of overflow */
  }

  /* Status behaves like Image Studio credit line */
  .tts-status.small {
    width: 100%;
    margin-top: 0;
    text-align: left;
    order: 0;
  }
}