/**
 * Enhanced Chapter Templates Styling
 * This CSS ensures proper display of chapter templates in the Chapters tab
 */

/* Template container styling */
.template-script-container {
  background: #1e293b !important;
  border: 1px solid #4b5563 !important;
  border-radius: 6px !important;
  padding: 15px !important;
  margin-top: 10px !important;
  margin-bottom: 15px !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Header row with title and toggle button */
.template-header-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 10px !important;
}

/* Template header text */
.template-header {
  font-weight: 700 !important;
  color: #38bdf8 !important;
  font-size: 14px !important;
}

/* Toggle button for expand/collapse */
.btn-toggle-template {
  background: none !important;
  border: 1px solid #4b5563 !important;
  color: #d1d5db !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-size: 16px !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.btn-toggle-template:hover {
  background: #374151 !important;
  border-color: #6b7280 !important;
}

/* Collapsible content area */
.template-collapsible {
  transition: max-height 0.3s ease-out !important;
  overflow: hidden !important;
  max-height: 500px !important; /* Default expanded state */
}

.template-collapsible.collapsed {
  max-height: 0 !important;
  display: none !important; /* Added to ensure it's hidden */
}

/* Template content area */
.template-content {
  background: #111827 !important;
  border: 1px solid #374151 !important;
  border-radius: 6px !important;
  padding: 12px !important;
  white-space: pre-wrap !important;
  font-family: monospace !important;
  margin-bottom: 10px !important;
  color: #e2e8f0 !important;
  line-height: 1.5 !important;
  text-align: left !important;
}

/* Template variables highlight */
.template-var {
  color: #f59e0b !important;
  font-weight: 700 !important;
  background: rgba(245, 158, 11, 0.1) !important;
  padding: 2px 4px !important;
  border-radius: 4px !important;
}

/* Copy template button */
.btn-copy-template {
  background: #4f46e5 !important;
  color: white !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
}

.btn-copy-template:hover {
  background: #4338ca !important;
}

/* Special styling for intro/outro chapters */
.metadata-generated-chapter {
  background: linear-gradient(135deg, #2d1b4e, #1e293b) !important;
  border: 1px solid #7c3aed !important;
  border-radius: 8px !important;
  padding: 12px !important;
  margin-bottom: 8px !important;
}

.metadata-generated-note {
  font-size: 0.875rem !important;
  color: #9ca3af !important;
  font-style: italic !important;
  display: block !important;
  margin-top: 4px !important;
  font-weight: 400 !important;
}

/* Chapter actions styling */
.chapter-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.btn-edit, .btn-audio, .btn-delete, .btn-plan, .btn-retry {
  padding: 4px 8px !important;
  border-radius: 4px !important;
  font-size: 13px !important;
  cursor: pointer !important;
  border: none !important;
}

.btn-edit {
  background-color: #4f46e5 !important;
  color: white !important;
}

.btn-audio {
  background-color: #10b981 !important;
  color: white !important;
}

.btn-delete {
  background-color: #ef4444 !important;
  color: white !important;
}

.btn-plan {
  background-color: #f59e0b !important;
  color: white !important;
}

.btn-retry {
  background-color: #6366f1 !important;
  color: white !important;
}

/* Audio status indicators */
.audio-status {
  display: flex !important;
  align-items: center !important;
  margin-right: 8px !important;
}

.audio-duration-badge {
  background-color: #10b981 !important;
  color: white !important;
  padding: 2px 6px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
}

.no-audio-badge {
  background-color: #94a3b8 !important;
  color: white !important;
  padding: 2px 6px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
}

/* Chapter error styling */
.chapter-error {
  background-color: #372122 !important;
  border-left: 3px solid #ef4444 !important;
}

/* Fix for chapter items */
.chapter-item {
  margin-bottom: 12px !important;
  border: 1px solid #374151 !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}

.chapter-content-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 12px !important;
  background-color: #1e293b !important;
}

.chapter-title {
  font-weight: 600 !important;
  color: #e2e8f0 !important;
  font-size: 15px !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.drag-handle {
  cursor: grab !important;
  color: #94a3b8 !important;
}

/* Special styles for intro and outro chapters */
.chapter-item[data-chapter-id*="intro_"] .chapter-content-row,
.chapter-item[data-chapter-id^="intro_"] .chapter-content-row {
  background-color: #143829 !important;
  border-left: 3px solid #10b981 !important;
}

.chapter-item[data-chapter-id*="outro_"] .chapter-content-row,
.chapter-item[data-chapter-id^="outro_"] .chapter-content-row {
  background-color: #312215 !important;
  border-left: 3px solid #f97316 !important;
}

/* Emergency fix for the Save Chapter Structure button */
#save-chapter-structure {
  background-color: #22c55e !important;
  color: white !important;
  border: none !important;
  padding: 8px 16px !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: background-color 0.2s !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

#save-chapter-structure:hover {
  background-color: #16a34a !important;
}

#save-chapter-structure:disabled {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}