/* ========================================================
   DISEÑADOR VISUAL DE ETIQUETAS (DRAG & DROP WYSIWYG)
   ======================================================== */

.designer-modal {
  position: fixed;
  inset: 0;
  background: #f8fafc;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1e293b;
}

.designer-modal.open {
  opacity: 1;
  pointer-events: auto;
}

/* Header superior */
.designer-header {
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.designer-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.designer-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.designer-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.designer-breadcrumb {
  font-size: 14px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.designer-breadcrumb strong {
  color: #0f172a;
  font-weight: 600;
}

.designer-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.designer-btn-save {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 7px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.designer-btn-save:hover {
  background: #1d4ed8;
}

/* Cuerpo del editor (3 columnas) */
.designer-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* 1. Panel Izquierdo */
.designer-sidebar-left {
  width: 250px;
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.designer-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.designer-form-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.designer-form-label .req {
  color: #ef4444;
}

.designer-input, .designer-select {
  width: 100%;
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  color: #1e293b;
  outline: none;
  background: #ffffff;
}

.designer-input:focus, .designer-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.designer-dim-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.designer-dim-box {
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  height: 32px;
}

.designer-dim-box input {
  width: 100%;
  height: 100%;
  border: none;
  padding: 0 8px;
  font-size: 13px;
  text-align: center;
  outline: none;
}

.designer-dim-box span {
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  border-left: 1px solid #cbd5e1;
}

/* Herramientas de inserción */
.designer-tools-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

.designer-elements-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.designer-add-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.designer-add-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.designer-add-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #e2e8f0;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
  color: #1e293b;
}

/* 2. Área Central: Canvas */
.designer-canvas-area {
  flex: 1;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Toolbar flotante */
.designer-toolbar {
  height: 44px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.designer-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.designer-zoom-box {
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.designer-zoom-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

.designer-zoom-btn:hover {
  background: #f1f5f9;
}

.designer-zoom-val {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  padding: 0 8px;
  min-width: 50px;
  text-align: center;
}

.designer-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: none;
  color: #475569;
  cursor: pointer;
  transition: all 0.12s ease;
}

.designer-tool-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.designer-tool-btn.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #2563eb;
}

/* Contenedor del lienzo */
.designer-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 16px 16px;
}

.designer-label-canvas {
  background: #ffffff;
  border: 1px solid #94a3b8;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  position: relative;
  box-sizing: border-box;
  overflow: visible;
  transition: width 0.15s ease, height 0.15s ease;
}

/* Elementos dentro del canvas */
.canvas-element {
  position: absolute;
  box-sizing: border-box;
  cursor: move;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: normal;
  overflow-wrap: break-word;
}

.canvas-element.selected {
  outline: 1.5px solid #2563eb;
  z-index: 100;
}

/* Tiradores de redimensionado (8 puntos) */
.canvas-resize-handle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #ffffff;
  border: 1.5px solid #2563eb;
  border-radius: 1px;
  display: none;
  z-index: 101;
}

.canvas-element.selected .canvas-resize-handle {
  display: block;
}

.handle-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.handle-n  { top: -4px; left: calc(50% - 3.5px); cursor: ns-resize; }
.handle-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 3.5px); right: -4px; cursor: ew-resize; }
.handle-se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.handle-s  { bottom: -4px; left: calc(50% - 3.5px); cursor: ns-resize; }
.handle-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 3.5px); left: -4px; cursor: ew-resize; }

/* Botón de eliminar en el elemento seleccionado */
.canvas-element-delete {
  position: absolute;
  right: -24px;
  top: -10px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  color: #ffffff;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 102;
}

.canvas-element.selected .canvas-element-delete {
  display: flex;
}

.canvas-element-delete:hover {
  background: #dc2626;
  transform: scale(1.1);
}

/* 3. Panel Derecho (Inspector / Propiedades) */
.designer-sidebar-right {
  width: 270px;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.designer-sidebar-right.empty {
  opacity: 0.5;
  pointer-events: none;
}

.designer-prop-header {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.designer-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px;
  background: #f8fafc;
}

.designer-toggle-btn {
  flex: 1;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.designer-toggle-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.designer-toggle-btn.active {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
