/**
 * Course Wizard — Stepper editorial
 * v3 — panels ocultados via position:absolute (não display:none)
 */

/* ─── TOKENS ─── */
#createCourseModal {
  --cw-ink:     #0d0d0d;
  --cw-cream:   #ede8dc;
  --cw-accent:  #e8ff47;
  --cw-muted:   #7a7570;
  --cw-rule:    rgba(13,13,13,.10);
  --cw-error:   #e53e3e;
  --cw-green:   #22c55e;
  --cw-f-display: 'DM Serif Display', Georgia, serif;
  --cw-f-mono:    'DM Mono', monospace;
  --cw-f-body:    'DM Sans', system-ui, sans-serif;
  --cw-ease:  cubic-bezier(.22,.68,0,1.2);
  --cw-speed: .26s;
}

/* ─── MODAL ─── */
#createCourseModal .modal-content {
  border-radius: 0 !important;
  box-shadow: 0 12px 56px rgba(0,0,0,.14) !important;
  max-width: 860px !important;
  overflow: hidden !important;
  background: #fff !important;
}

/* ─── HEADER ─── */
#createCourseModal .modal-header {
  background: var(--cw-ink) !important;
  border-bottom: none !important;
  padding: 18px 28px !important;
}
#createCourseModalTitle {
  font-family: var(--cw-f-display) !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  font-style: italic !important;
  color: rgba(255,255,255,.7) !important;
}
#closeCourseModal {
  color: rgba(255,255,255,.4) !important;
  font-size: 20px !important;
  background: none !important;
  border: none !important;
  cursor: pointer;
}
#closeCourseModal:hover { color: #fff !important; }

/* ─── STEPPER RAIL ─── */
.cw-stepper {
  display: flex;
  border-bottom: 1px solid var(--cw-rule);
  background: #fff;
}
.cw-step-tab {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 14px;
  cursor: pointer;
  border-right: 1px solid var(--cw-rule);
  border-bottom: 2px solid transparent;
  background: #fff;
  transition: background var(--cw-speed);
  user-select: none;
  min-width: 0;
}
.cw-step-tab:last-child { border-right: none; }
.cw-step-tab:hover:not(.active):not(.disabled) { background: #fafafa; }
.cw-step-tab.active   { border-bottom-color: var(--cw-ink); }
.cw-step-tab.disabled { opacity: .35; cursor: default; pointer-events: none; }

.cw-tab-num {
  font-family: var(--cw-f-mono);
  font-size: 10px; font-weight: 500; letter-spacing: .08em;
  color: var(--cw-muted); flex-shrink: 0;
}
.cw-step-tab.active    .cw-tab-num { color: var(--cw-ink); font-weight: 700; }
.cw-step-tab.completed .cw-tab-num { color: var(--cw-green); }

.cw-tab-label {
  font-family: var(--cw-f-body);
  font-size: 11px; font-weight: 500; color: var(--cw-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cw-step-tab.active    .cw-tab-label { color: var(--cw-ink); }
.cw-step-tab.completed .cw-tab-label { color: #444; }

.cw-tab-check {
  margin-left: auto;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--cw-green); color: #fff;
  font-size: 8px; display: none;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.cw-step-tab.completed .cw-tab-check { display: flex; }

/* ─── PROGRESS ─── */
.cw-progress-bar { height: 2px; background: var(--cw-rule); position: relative; }
.cw-progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--cw-ink);
  transition: width .4s var(--cw-ease);
}

/* ─── PANELS ─── */
.cw-body { position: relative; }

/*
 * CRÍTICO: panels inativos ficam em position:absolute (fora do fluxo)
 * MAS continuam no DOM e renderizados → EmojiPicker e ImageUpload funcionam.
 */
.cw-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--cw-speed) var(--cw-ease);
}
.cw-panel.active {
  position: relative;
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  animation: cw-in var(--cw-speed) var(--cw-ease) both;
}
.cw-panel.cw-panel-hidden {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}
@keyframes cw-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: none; }
}

/* ─── INNER ─── */
.cw-panel-inner {
  padding: 28px 32px 24px;
  max-height: calc(100vh - 280px);
  overflow-y: auto; overflow-x: hidden;
}

/* ─── FIX: Overflow visível para dropdowns abrirem para fora do painel ─── */
#createCourseModal .modal-content {
  overflow: visible !important;
}
#courseWizardWrapper,
.cw-body {
  overflow: visible !important;
}
/* Step 3 precisa de overflow visible para dropdowns subirem */
.cw-panel[data-panel="3"] {
  overflow: visible !important;
}
.cw-panel[data-panel="3"] .cw-panel-inner {
  overflow: visible !important;
}

/* ─── FIX: Dropdowns de categorias/instrutores abrem para CIMA ─── */
#newCourseCategoriesContainer,
#newCourseInstructorsContainer,
#editCourseCategoriesContainer,
#editCourseInstructorsContainer {
  position: relative !important;
}

/* Selectors para dropdowns de CategoryTagsInput e similares */
#newCourseCategoriesContainer .dropdown,
#newCourseCategoriesContainer [class*="dropdown"]:not(button):not(input),
#newCourseCategoriesContainer [class*="options"]:not(button):not(input),
#newCourseCategoriesContainer [class*="suggestions"],
#newCourseInstructorsContainer .dropdown,
#newCourseInstructorsContainer [class*="dropdown"]:not(button):not(input),
#newCourseInstructorsContainer [class*="options"]:not(button):not(input),
#newCourseInstructorsContainer [class*="suggestions"],
/* tambem garantir no editModal */
#editCourseCategoriesContainer .dropdown,
#editCourseCategoriesContainer [class*="dropdown"]:not(button):not(input),
#editCourseInstructorsContainer .dropdown,
#editCourseInstructorsContainer [class*="dropdown"]:not(button):not(input) {
  position: absolute !important;
  bottom: 100% !important;
  top: auto !important;
  margin-bottom: 4px !important;
  margin-top: 0 !important;
  z-index: 99999 !important;
  max-height: 220px !important;
  overflow-y: auto !important;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15) !important;
}
/* O dropdown do CategoryTagsInput é relativo ao .search-container 
   Garantir que o pai direto (.search-container) repasse o posicionamento */
#newCourseCategoriesContainer .search-container,
#newCourseInstructorsContainer .search-container,
#editCourseCategoriesContainer .search-container,
#editCourseInstructorsContainer .search-container {
  position: relative !important;
}

/* Override direto no .dropdown para subir */
#newCourseCategoriesContainer .dropdown,
#newCourseInstructorsContainer .dropdown,
#editCourseCategoriesContainer .dropdown,
#editCourseInstructorsContainer .dropdown {
  top: auto !important;
  bottom: calc(100% + 8px) !important;
  z-index: 99999 !important;
  animation: slideUp 0.2s ease-out !important;
}

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

.cw-panel-inner::-webkit-scrollbar { width: 3px; }
.cw-panel-inner::-webkit-scrollbar-thumb { background: rgba(13,13,13,.1); border-radius: 2px; }

/* ─── HEADER EDITORIAL ─── */
.cw-panel-header {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 24px; padding-bottom: 18px;
  border-bottom: 1px solid var(--cw-rule);
}
.cw-panel-num {
  font-family: var(--cw-f-display);
  font-size: 64px; font-weight: 700; line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(13,13,13,.13);
  letter-spacing: -.04em; margin-top: -4px;
  flex-shrink: 0; user-select: none;
}
.cw-panel-eyebrow {
  font-family: var(--cw-f-mono);
  font-size: 10px; font-weight: 500; letter-spacing: .12em;
  text-transform: uppercase; color: var(--cw-muted); margin-bottom: 3px;
}
.cw-panel-title {
  font-family: var(--cw-f-display);
  font-size: 21px; font-weight: 700;
  letter-spacing: -.025em; color: var(--cw-ink); line-height: 1.1;
}
.cw-panel-title em { font-style: italic; font-weight: 400; color: var(--cw-muted); }

/* ─── FIELDS ─── */
.cw-panel .form-group { margin-bottom: 16px; }
.cw-panel .form-group:last-child { margin-bottom: 0; }

.cw-panel .form-label {
  font-family: var(--cw-f-mono) !important;
  font-size: 10px !important; font-weight: 500 !important;
  letter-spacing: .09em !important; text-transform: uppercase !important;
  color: var(--cw-muted) !important;
  display: block !important; margin-bottom: 6px !important;
}
.cw-panel .form-control {
  border-radius: 0 !important;
  border: 1px solid rgba(13,13,13,.16) !important;
  font-family: var(--cw-f-body) !important;
  font-size: 15px !important; color: var(--cw-ink) !important;
  background: #fff !important; padding: 10px 13px !important;
  transition: border-color var(--cw-speed) !important;
  width: 100% !important; box-sizing: border-box !important;
}
.cw-panel .form-control:focus {
  border-color: var(--cw-ink) !important;
  outline: none !important; box-shadow: none !important;
}
.cw-panel .form-control::placeholder { color: rgba(13,13,13,.3) !important; }
.cw-panel .form-control.error { border-color: var(--cw-error) !important; }

.cw-price-input { cursor: text !important; }

/* Garante que EmojiPicker renderize corretamente */
.cw-panel .emoji-picker-wrapper {
  display: flex !important; gap: 12px !important; align-items: center !important;
}
.cw-panel .emoji-preview-container { flex-shrink: 0 !important; }

/* ImageUpload */
.cw-panel .image-upload-wrapper { width: 100%; }
.cw-panel .image-upload-wrapper input[type="url"] { box-sizing: border-box !important; }

/* ─── GRID 2 COLUNAS ─── */
.cw-col2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 640px) { .cw-col2 { grid-template-columns: 1fr; } }

/* ─── ERROS ─── */
.cw-field-error {
  font-family: var(--cw-f-mono);
  font-size: 10px; color: var(--cw-error);
  letter-spacing: .04em; margin-top: 4px; display: none;
}
.cw-field-error.visible { display: block; }

/* ─── FOOTER ─── */
.cw-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px 18px;
  border-top: 1px solid var(--cw-rule);
  background: #fafafa;
}
.cw-footer-left { display: flex; align-items: center; gap: 8px; }

.cw-step-dots { display: flex; gap: 5px; }
.cw-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(13,13,13,.15);
  transition: background var(--cw-speed), transform var(--cw-speed);
}
.cw-dot.active { background: var(--cw-ink); transform: scale(1.4); }
.cw-dot.done   { background: var(--cw-green); }

.cw-step-info {
  font-family: var(--cw-f-mono); font-size: 10px;
  color: var(--cw-muted); letter-spacing: .06em;
  text-transform: uppercase; margin-left: 6px;
}
.cw-footer-right { display: flex; align-items: center; gap: 10px; }

.cw-btn-cancel {
  background: none; border: none;
  font-family: var(--cw-f-body); font-size: 12px; color: var(--cw-muted);
  cursor: pointer; padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--cw-speed), border-color var(--cw-speed);
}
.cw-btn-cancel:hover { color: var(--cw-ink); border-bottom-color: var(--cw-ink); }

.cw-btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid rgba(13,13,13,.18);
  color: var(--cw-muted);
  font-family: var(--cw-f-body); font-size: 13px; font-weight: 500;
  padding: 8px 16px; cursor: pointer;
  transition: border-color var(--cw-speed), color var(--cw-speed), background var(--cw-speed);
}
.cw-btn-back:hover { border-color: var(--cw-ink); color: var(--cw-ink); background: #f5f5f5; }
.cw-btn-back:disabled { opacity: .3; cursor: default; pointer-events: none; }

.cw-btn-next {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cw-ink); color: #fff;
  border: 2px solid var(--cw-ink);
  font-family: var(--cw-f-body); font-size: 13px; font-weight: 600;
  padding: 8px 20px; cursor: pointer; letter-spacing: -.01em;
  transition: background var(--cw-speed), transform var(--cw-speed) var(--cw-ease), box-shadow var(--cw-speed);
}
.cw-btn-next:hover {
  background: #1a1a1a;
  transform: translate(-2px,-2px);
  box-shadow: 4px 4px 0 rgba(13,13,13,.15);
}

.cw-btn-submit {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cw-accent); color: var(--cw-ink);
  border: 2px solid var(--cw-ink);
  font-family: var(--cw-f-body); font-size: 13px; font-weight: 700;
  padding: 8px 22px; cursor: pointer; letter-spacing: -.01em;
  transition: background var(--cw-speed), transform var(--cw-speed) var(--cw-ease), box-shadow var(--cw-speed);
}
.cw-btn-submit:hover {
  background: #d4eb2f;
  transform: translate(-2px,-2px);
  box-shadow: 4px 4px 0 rgba(13,13,13,.2);
}
.cw-btn-submit:disabled { opacity: .5; cursor: default; pointer-events: none; }

/* ─── RESPONSIVE ─── */
@media (max-width: 680px) {
  .cw-tab-label { display: none; }
  .cw-panel-inner { padding: 18px 16px 14px; }
  .cw-footer { padding: 12px 16px 14px; }
  .cw-panel-num { font-size: 44px; }
  .cw-panel-title { font-size: 17px; }
}
