/* public/css/components.css */
/* Visual components: Cards, Upload Panel, Audio Player, Beat Cards, Dialogs */

/* 1. Card container */
.panel-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.panel-card:hover {
  border-color: var(--border-strong);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-2);
}

.panel-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.panel-subtitle {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* 2. Workflow Stage Progress Indicator */
.workflow-progress-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  gap: var(--space-2);
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

.step-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: var(--font-bold);
}

.workflow-step.active {
  color: var(--accent-primary);
  font-weight: var(--font-semibold);
}

.workflow-step.active .step-number {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}

.workflow-step.completed {
  color: var(--status-success);
}

.workflow-step.completed .step-number {
  background-color: var(--status-success);
  color: var(--text-inverse);
  border-color: var(--status-success);
}

.step-connector {
  flex: 1;
  height: 2px;
  background-color: var(--border-subtle);
  min-width: 16px;
  margin: 0 var(--space-1);
}

.step-connector.completed {
  background-color: var(--status-success);
}

/* 3. Audio Upload Dropzone */
.dropzone-container {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  background-color: var(--bg-surface-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.dropzone-container:hover, .dropzone-container.dragover {
  border-color: var(--accent-primary);
  background-color: var(--accent-primary-subtle);
}

.dropzone-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto var(--space-3);
  color: var(--accent-primary);
}

.dropzone-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.dropzone-hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Audio File Info Card */
.audio-file-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-top: var(--space-3);
}

.file-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow: hidden;
}

.file-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.file-stats {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Audio Player Bar */
.audio-player-bar {
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.player-scrubber {
  flex: 1;
  height: 6px;
  appearance: none;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.player-scrubber::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
}

.player-time {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}

/* 4. Form Controls & Sliders */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* Slider with live count display */
.slider-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.slider-input {
  flex: 1;
  height: 6px;
  appearance: none;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  outline: none;
}

.slider-input::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
}

.slider-value-input {
  width: 56px;
  text-align: center;
  font-weight: var(--font-semibold);
  font-family: var(--font-mono);
}

/* Aspect Ratio Selector */
.aspect-ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
}

.ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-1);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
  transition: all var(--transition-fast);
}

.ratio-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.ratio-btn.active {
  background-color: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: var(--font-semibold);
}

.ratio-box {
  border: 1.5px solid currentColor;
  border-radius: 2px;
}
.ratio-box.r-16-9 { width: 22px; height: 12px; }
.ratio-box.r-9-16 { width: 12px; height: 22px; }
.ratio-box.r-1-1  { width: 16px; height: 16px; }
.ratio-box.r-4-3  { width: 20px; height: 15px; }
.ratio-box.r-3-2  { width: 21px; height: 14px; }

/* Switch Toggle */
.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
}

.switch-label-wrap {
  display: flex;
  flex-direction: column;
}

.switch-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.switch-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.switch-input {
  appearance: none;
  width: 40px;
  height: 22px;
  background-color: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background-color var(--transition-fast);
}

.switch-input:checked {
  background-color: var(--accent-primary);
}

.switch-input::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  background-color: var(--text-inverse);
  transition: transform var(--transition-fast);
}

.switch-input:checked::before {
  transform: translateX(18px);
}

/* 5. Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-subtle);
  border-color: var(--text-secondary);
}

.btn-danger-outline {
  background-color: transparent;
  border: 1px solid var(--status-error);
  color: var(--status-error);
}

.btn-danger-outline:hover:not(:disabled) {
  background-color: var(--status-error-bg);
}

.btn-danger-solid {
  background-color: var(--status-error);
  color: var(--text-inverse);
}

.btn-danger-solid:hover:not(:disabled) {
  background-color: #991B1B;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn-icon {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

/* 6. Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  font-family: var(--font-mono);
}

.badge-neutral {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-accent {
  background-color: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}

.badge-success {
  background-color: var(--status-success-bg);
  color: var(--status-success);
}

.badge-warning {
  background-color: var(--status-warning-bg);
  color: var(--status-warning);
}

.badge-error {
  background-color: var(--status-error-bg);
  color: var(--status-error);
}

/* 7. Timeline & Beat Cards */
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.continuity-guide-banner {
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-secondary);
  border-left: 4px solid var(--accent-secondary);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
}

.continuity-guide-title {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.continuity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
}

.continuity-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.continuity-label {
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.continuity-value {
  color: var(--text-secondary);
}

/* Individual Story Beat Card */
.beat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.beat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.beat-card.playing {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

.beat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-2);
}

.beat-meta-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.beat-index-badge {
  background-color: var(--text-primary);
  color: var(--text-inverse);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.beat-timing-badge {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.beat-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.beat-narration-box {
  background-color: var(--bg-surface-subtle);
  border-left: 3px solid var(--border-strong);
  padding: var(--space-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-style: italic;
  line-height: 1.5;
}

.beat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.beat-prompt-box {
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  position: relative;
}

.prompt-text {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.negative-prompt-text {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border-subtle);
}

.prompt-actions-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

/* Scripture & Word Cards */
.extra-card-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-primary-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-size: var(--text-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.scripture-card-box {
  border-color: #FCD34D;
  background-color: #FFFBEB;
  color: #78350F;
}

[data-theme="dark"] .scripture-card-box {
  background-color: #2D2006;
  border-color: #78350F;
  color: #FDE68A;
}

.word-card-box {
  border-color: #99F6E4;
  background-color: #F0FDFA;
  color: #115E59;
}

[data-theme="dark"] .word-card-box {
  background-color: #062826;
  border-color: #115E59;
  color: #99F6E4;
}

/* 8. Modals & Dialogs */
.dialog-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 17, 23, 0.65);
  z-index: 100;
  display: none; /* Crucial: do not render, composite, or filter when closed */
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.dialog-backdrop.open {
  display: flex !important;
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog-modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 1;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-fast);
}

.dialog-backdrop.open .dialog-modal {
  transform: translateY(0) scale(1);
}

.dialog-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-title {
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.dialog-body {
  padding: var(--space-5);
  overflow-y: auto;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.dialog-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  background-color: var(--bg-surface-subtle);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  max-width: 400px;
  animation: toastIn 200ms ease-out;
}

.toast.toast-success { border-left: 4px solid var(--status-success); }
.toast.toast-error { border-left: 4px solid var(--status-error); }
.toast.toast-warning { border-left: 4px solid var(--status-warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
