/* ── Selection Popup & Image Generator Modal ─────────────────────────── */

/* Toolbar flutuante ao selecionar texto */
#cc-selection-toolbar {
  position: fixed;
  z-index: 99999;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 6px 10px;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transform: translateX(-50%);
  pointer-events: auto;
}
#cc-selection-toolbar.visible {
  display: flex;
}
#cc-selection-toolbar::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1a1a2e;
}
#cc-selection-toolbar button {
  background: linear-gradient(135deg, #6c63ff, #4299e1);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: opacity .2s;
}
#cc-selection-toolbar button:hover { opacity: .85; }
#cc-selection-toolbar .cc-tb-label {
  color: #a0aec0;
  font-size: 11px;
  white-space: nowrap;
}

/* Overlay do modal */
#cc-imggen-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0,0,0,.75);
  overflow-y: auto;
  padding: 20px;
}
#cc-imggen-overlay.open { display: flex; align-items: flex-start; justify-content: center; }

/* Modal container */
#cc-imggen-modal {
  background: #0f0f1a;
  border-radius: 12px;
  width: 100%;
  max-width: 1200px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
  position: relative;
}

/* Header do modal */
#cc-imggen-modal .cc-mg-header {
  background: #1a1a2e;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2d2d4e;
}
#cc-imggen-modal .cc-mg-header h2 {
  margin: 0;
  font-size: 16px;
  color: #e2e8f0;
  font-weight: 600;
}
#cc-imggen-modal .cc-mg-close {
  background: none;
  border: none;
  color: #718096;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .2s;
}
#cc-imggen-modal .cc-mg-close:hover { color: #e2e8f0; }

/* Body 3 colunas */
#cc-imggen-modal .cc-mg-body {
  display: grid;
  grid-template-columns: 200px 1fr 260px;
  min-height: 600px;
}

/* Coluna esquerda — templates */
.cc-mg-templates {
  background: #13132a;
  padding: 16px;
  border-right: 1px solid #2d2d4e;
  overflow-y: auto;
}
.cc-mg-templates h3 {
  color: #a0aec0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 0 0 12px;
}
.cc-tpl-card {
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .2s, transform .15s;
  position: relative;
  overflow: hidden;
}
.cc-tpl-card:hover { transform: scale(1.02); }
.cc-tpl-card.active { border-color: #6c63ff; }
.cc-tpl-card .cc-tpl-preview {
  height: 60px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  text-align: center;
  padding: 6px;
  line-height: 1.3;
  margin-bottom: 6px;
  font-style: italic;
}
.cc-tpl-card .cc-tpl-name {
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  text-align: center;
}

/* Coluna central — canvas */
.cc-mg-canvas-col {
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 12px;
}
.cc-mg-canvas-wrap {
  position: relative;
  display: inline-block;
}
#cc-main-canvas {
  display: block;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  border-radius: 4px;
}
.cc-canvas-meta {
  color: #718096;
  font-size: 11px;
  letter-spacing: .08em;
  text-align: center;
}
.cc-verse-inputs {
  width: 100%;
  max-width: 540px;
}
.cc-verse-inputs textarea,
.cc-verse-inputs input[type="text"] {
  width: 100%;
  background: #0f0f1a;
  border: 1px solid #2d2d4e;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 10px 12px;
  font-size: 14px;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
  box-sizing: border-box;
  font-family: inherit;
}
.cc-verse-inputs textarea:focus,
.cc-verse-inputs input[type="text"]:focus { border-color: #6c63ff; }
.cc-verse-inputs textarea { min-height: 90px; margin-bottom: 8px; }
.cc-canvas-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.cc-btn-download {
  background: linear-gradient(135deg, #6c63ff, #4299e1);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s;
}
.cc-btn-download:hover { opacity: .85; }

/* Coluna direita — controles */
.cc-mg-controls {
  background: #13132a;
  border-left: 1px solid #2d2d4e;
  overflow-y: auto;
  max-height: 680px;
}

/* Accordion */
.cc-accordion {
  border-bottom: 1px solid #2d2d4e;
}
.cc-accordion-toggle {
  width: 100%;
  background: none;
  border: none;
  color: #cbd5e0;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color .2s;
}
.cc-accordion-toggle:hover { color: #fff; }
.cc-accordion-toggle .cc-acc-arrow {
  transition: transform .25s;
  font-size: 10px;
}
.cc-accordion.open .cc-acc-arrow { transform: rotate(180deg); }
.cc-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
  padding: 0 16px;
}
.cc-accordion.open .cc-accordion-body {
  max-height: 500px;
  padding: 0 16px 14px;
}

/* Controles genéricos */
.cc-ctrl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.cc-ctrl-row label {
  color: #a0aec0;
  font-size: 11px;
  min-width: 80px;
}
.cc-ctrl-row input[type="range"] {
  flex: 1;
  accent-color: #6c63ff;
}
.cc-ctrl-row input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid #2d2d4e;
  border-radius: 4px;
  padding: 2px;
  background: #0f0f1a;
  cursor: pointer;
}
.cc-ctrl-row select {
  flex: 1;
  background: #0f0f1a;
  border: 1px solid #2d2d4e;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
}
.cc-ctrl-row input[type="text"],
.cc-ctrl-row input[type="file"] {
  flex: 1;
  background: #0f0f1a;
  border: 1px solid #2d2d4e;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.cc-ctrl-val {
  color: #718096;
  font-size: 11px;
  min-width: 28px;
  text-align: right;
}

/* Botões de grupo (formato, alinhamento) */
.cc-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.cc-btn-group button {
  background: #1a1a2e;
  border: 1px solid #2d2d4e;
  color: #a0aec0;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.cc-btn-group button.active,
.cc-btn-group button:hover {
  background: #6c63ff;
  border-color: #6c63ff;
  color: #fff;
}

/* Toggle switch */
.cc-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.cc-toggle-row label { color: #a0aec0; font-size: 12px; }
.cc-switch {
  position: relative;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}
.cc-switch input { opacity: 0; width: 0; height: 0; }
.cc-switch-slider {
  position: absolute;
  inset: 0;
  background: #2d2d4e;
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s;
}
.cc-switch-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.cc-switch input:checked + .cc-switch-slider { background: #6c63ff; }
.cc-switch input:checked + .cc-switch-slider::before { transform: translateX(18px); }

/* Imagens de fundo temáticas */
.cc-bg-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.cc-bg-img-btn {
  height: 40px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .2s;
  background-size: cover;
  background-position: center;
}
.cc-bg-img-btn.active { border-color: #6c63ff; }

/* Responsivo */
@media (max-width: 900px) {
  #cc-imggen-modal .cc-mg-body {
    grid-template-columns: 1fr;
  }
  .cc-mg-templates {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid #2d2d4e;
    padding-bottom: 12px;
  }
  .cc-tpl-card { min-width: 110px; margin-bottom: 0; }
  .cc-mg-controls { max-height: none; }
}
