/* ==========================================================
   CRM - TALLER DE DISEÑO
   Pinta js/taller.js, dentro de la pestaña Estudio. Reusa .btn,
   .btn-mini, .btn-icon, .campo, .campo-label de siempre — acá
   solo el layout propio del workspace (panel + vista previa) y
   los mini-componentes de listas editables.
   ========================================================== */

/* --- Workspace: barra + panel + vista previa ------------------- */

.taller-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 260px);
    min-height: 520px;
}

.taller-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.taller-modo-toggle {
    display: flex;
    gap: 4px;
    padding: 3px;
    border-radius: var(--radius-md, 10px);
    background: var(--surf-1, #171719);
    border: 1px solid var(--border-color);
}

.taller-modo-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: calc(var(--radius-md, 10px) - 3px);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: color 140ms ease, background 140ms ease;
}

.taller-modo-btn:hover:not(.es-elegido) { color: var(--text-main); }

.taller-modo-btn.es-elegido {
    color: #17140d;
    background: linear-gradient(135deg, var(--primary), rgba(var(--acento-rgb), 0.75));
}

.taller-dispositivo-toggle {
    display: flex;
    gap: 4px;
}

.taller-dispositivo-toggle .btn-icon {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.taller-dispositivo-toggle .btn-icon.es-activo {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(var(--acento-rgb), 0.1);
}

.taller-toolbar__spacer { flex: 1 1 auto; }

.taller-cuerpo {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 14px;
    flex: 1 1 auto;
    min-height: 0;
}

.taller-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.taller-panel::-webkit-scrollbar { width: 6px; }
.taller-panel::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.taller-subtabs {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 2;
    padding-bottom: 4px;
}

.taller-subtab {
    flex: 1 1 0;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.taller-subtab:hover { color: var(--text-main); border-color: rgba(var(--acento-rgb), 0.4); }

.taller-subtab.es-elegida {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(var(--acento-rgb), 0.1);
}

.taller-panel-seccion { display: flex; flex-direction: column; gap: 4px; }
.taller-panel-seccion > .campo-label { margin-top: 12px; }
.taller-panel-seccion > .campo-label:first-child { margin-top: 0; }
.taller-panel-seccion > .campo,
.taller-panel-seccion > select.campo,
.taller-panel-seccion > textarea.campo { margin-bottom: 2px; }

.taller-preview-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 14px;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--border-color);
    background: var(--surf-1, #171719);
    overflow: auto;
}

.taller-preview {
    border: none;
    border-radius: 10px;
    background: #fff;
    height: 100%;
    min-height: 480px;
    transition: width 220ms cubic-bezier(.4,0,.2,1), border-radius 220ms ease, box-shadow 220ms ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.taller-preview--desktop { width: 100%; }
.taller-preview--mobile { width: 390px; max-width: 100%; border-radius: 26px; box-shadow: 0 0 0 8px #111, 0 0 0 9px var(--border-color), 0 12px 32px rgba(0, 0, 0, 0.4); }

/* --- Marca -------------------------------------------------- */

.taller-logo-fila {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.taller-logo-preview {
    width: 42px; height: 42px; border-radius: 8px; object-fit: cover;
    border: 1px solid var(--border-color);
}

.taller-logo-vacio {
    width: 42px; height: 42px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surf-1, #171719); color: var(--text-dim);
    border: 1px dashed var(--border-color);
}

.taller-file-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.78rem; padding: 7px 12px; cursor: pointer;
}

.taller-color { padding: 3px !important; height: 34px; cursor: pointer; }

.taller-rango-fila { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.taller-rango-fila input[type="range"] { flex: 1 1 0; accent-color: var(--primary); }
.taller-rango-valor { flex: 0 0 auto; font-size: 0.76rem; color: var(--text-muted); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* Al tocar un texto/ícono/celda en la vista previa, el campo que le
   corresponde en el panel se resalta un instante — así se ve
   claramente adónde saltó, sobre todo si el panel tuvo que hacer
   scroll para mostrarlo. */
.taller-campo-resaltado {
    outline: 2px solid var(--primary) !important;
    outline-offset: 2px;
    animation: tallerResaltado 1.4s ease;
}
@keyframes tallerResaltado {
    0%, 40% { box-shadow: 0 0 0 4px rgba(var(--acento-rgb), 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(var(--acento-rgb), 0); }
}

/* --- Bloques / secciones: lista ordenable ------------------- */

.taller-agregar-bloques {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.taller-chip-bloque {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--surf-1, #171719);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.taller-chip-bloque { transition: border-color 140ms ease, color 140ms ease, transform 100ms ease; }
.taller-chip-bloque:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.taller-chip-bloque:active { transform: translateY(0); }

.taller-lista-bloques {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.taller-bloque-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--surf-1, #171719);
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease;
}

.taller-bloque-item:hover { border-color: rgba(var(--acento-rgb), 0.4); }
.taller-bloque-item.es-elegido { border-color: var(--primary); background: rgba(var(--acento-rgb), 0.08); }
.taller-bloque-item > i:not(.taller-bloque-item__handle):first-of-type { color: var(--primary); flex: 0 0 auto; }
.taller-bloque-item span { flex: 1 1 0; min-width: 0; font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.taller-bloque-item__acciones { display: flex; gap: 2px; flex: 0 0 auto; }
.taller-bloque-item__acciones .btn-icon { width: 26px; height: 26px; padding: 0; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; }
.taller-bloque-item__acciones .btn-icon:disabled { opacity: 0.3; cursor: default; }

.taller-bloque-item__handle {
    flex: 0 0 auto;
    color: var(--text-dim);
    cursor: grab;
    opacity: 0.55;
    transition: opacity 120ms ease, color 120ms ease;
}
.taller-bloque-item:hover .taller-bloque-item__handle { opacity: 0.9; color: var(--text-muted); }
.taller-bloque-item__handle:active { cursor: grabbing; }
.taller-bloque-item.taller-arrastrando { opacity: 0.4; border-style: dashed; }

/* --- Selector visual de íconos ------------------------------- */

.taller-icono-picker { position: relative; }

.taller-icono-picker__actual {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--surf-1, #171719);
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 140ms ease;
}
.taller-icono-picker__actual:hover { border-color: rgba(var(--acento-rgb), 0.5); }
.taller-icono-picker__actual i:first-child { color: var(--primary); }
.taller-icono-picker__flecha { font-size: 0.6rem; color: var(--text-dim); }

.taller-icono-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-top: 6px;
    padding: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.taller-icono-grid__item {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--surf-1, #171719);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: border-color 120ms ease, color 120ms ease, transform 100ms ease;
}
.taller-icono-grid__item:hover { color: var(--primary); border-color: rgba(var(--acento-rgb), 0.4); transform: translateY(-1px); }
.taller-icono-grid__item.es-elegido { color: var(--primary); border-color: var(--primary); background: rgba(var(--acento-rgb), 0.1); }

.taller-form-bloque {
    padding: 12px;
    border-radius: var(--radius-md, 10px);
    border: 1px dashed var(--border-color);
    margin-top: 6px;
}

.taller-form-bloque h4 {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.86rem; margin: 0 0 10px;
}
.taller-form-bloque h4 i { color: var(--primary); }

.taller-fila-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* --- Listas editables (tarjetas, testimonios, planes, stats) - */

.taller-lista-editable, .taller-galeria-editable { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }

.taller-lista-fila { display: flex; gap: 6px; align-items: center; }
.taller-lista-fila .campo { flex: 1 1 0; }

.taller-tarjeta-editable {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    position: relative;
}
.taller-tarjeta-editable > .btn-icon { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0; font-size: 0.68rem; }

.taller-galeria-editable {
    flex-direction: row;
    flex-wrap: wrap;
}
.taller-galeria-editable__item { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; }
.taller-galeria-editable__item img { width: 100%; height: 100%; object-fit: cover; }
.taller-galeria-editable__item .btn-icon {
    position: absolute; top: 0; right: 0; width: 20px; height: 20px; padding: 0;
    font-size: 0.62rem; background: rgba(0,0,0,.6); color: #fff; border-radius: 0 0 0 6px;
}

/* --- Lienzo libre: artboard interactivo (modo lienzo) ---------- */

.taller-lienzo-artboard {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border-color);
    flex: 0 0 auto;
}

.taller-el {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: move;
    user-select: none;
    border: 1px dashed transparent;
}

.taller-el:hover { border-color: rgba(var(--acento-rgb), 0.5); }
.taller-el.es-elegido { border: 1px solid var(--primary); box-shadow: 0 0 0 2px rgba(var(--acento-rgb), 0.25); }

.taller-el--boton {
    border-radius: 8px;
    font-weight: 700;
}

.taller-el__resize {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--primary);
    cursor: nwse-resize;
    display: none;
}

.taller-el.es-elegido .taller-el__resize { display: block; }

/* --- Responsive: el taller pasa a apilado en celular ---------- */

@media (max-width: 900px) {
    .taller-cuerpo { grid-template-columns: 1fr; }
    .taller-panel { max-height: 40vh; }
    .taller-shell { height: auto; }
    .taller-preview { min-height: 360px; }
}
