/* ==========================================================================
   Demo viva "link-editor" (sección "Tu perfil" de /link): el modal "Editar
   Módulo" de Links con su panel "Vista previa", igual que en el constructor.
   Markup: resources/views/web/partials/anim/link-editor.blade.php
   Estados en la raíz:
     data-tab      links | design        (pestaña del editor)
     data-new      ya existe el tercer link (solo en el editor: la vista previa
                   real no recarga los links hasta reabrir el modal)
     data-focus    title | url           (campo enfocado)
     data-outline  estilo de botones "Contorno" (sí se ve en vivo en la vista previa)
     data-saving   "Guardar cambios" con spinner
     data-cursor   puntero visible
   El panel no tiene modo oscuro: solo halo y sombra.
   ========================================================================== */

/* ---------- Paleta ---------- */
.lla-link-editor {
  --lla-bg: #ffffff;
  --lla-surface: #f8f9fa;
  --lla-text: #1e2022;
  --lla-muted: #677788;
  --lla-border: #e7eaf3;
  --lla-border-2: #d0d7e2;
  --lla-primary: #377dff;
  --lla-primary-soft: rgba(55, 125, 255, .1);
  --lla-success: #198754;
  --lla-shadow: 0 32px 64px -24px rgba(22, 34, 58, .38), 0 10px 24px -10px rgba(22, 34, 58, .18);
  --lla-glow-a: rgba(55, 125, 255, .16);
  --lla-glow-b: rgba(124, 58, 237, .15);
  --lla-dot-r: #ff5f57;
  --lla-dot-y: #febc2e;
  --lla-dot-g: #28c840;
  --lla-cursor-fill: #1e2022;
  --lla-cursor-edge: #ffffff;
  --lla-cursor-ring: rgba(55, 125, 255, .55);

  /* Color de la página (accentColor del módulo): paleta "Púrpura" */
  --lla-brand: #7c3aed;
  --lla-brand-soft: #faf5ff;
}

html[data-theme="dark"] .lla-link-editor {
  --lla-glow-a: rgba(77, 159, 255, .14);
  --lla-glow-b: rgba(167, 139, 250, .14);
  --lla-shadow: 0 32px 64px -24px rgba(0, 0, 0, .8), 0 10px 24px -10px rgba(0, 0, 0, .55);
}

/* ---------- Escena ---------- */
.lla-link-editor { max-width: 680px; margin-inline: auto; color: var(--lla-text); line-height: 1.3; text-align: left; }
.lla .lla-link-editor__stage { --lla-w: 680; --lla-h: 440; }
.lla-link-editor :where(b, small, strong, em, i) { margin: 0; font-size: inherit; font-style: normal; color: inherit; }
.lla-link-editor .bi::before { vertical-align: 0; }
.lla-link-editor__muted { color: var(--lla-muted); }

.lla-link-editor__glow { position: absolute; border-radius: 50%; pointer-events: none; }
.lla-link-editor__glow--a { left: -40px; top: 0; width: 440px; height: 440px; background: radial-gradient(closest-side, var(--lla-glow-a), transparent); }
.lla-link-editor__glow--b { left: 340px; top: 40px; width: 400px; height: 400px; background: radial-gradient(closest-side, var(--lla-glow-b), transparent); }

/* ---------- Ventana ---------- */
.lla-link-editor__win {
  position: absolute;
  left: 0;
  top: 4px;
  width: 680px;
  height: 432px;
  overflow: hidden;
  border: 1px solid var(--lla-border);
  border-radius: 14px;
  background: var(--lla-bg);
  box-shadow: var(--lla-shadow);
}
.lla-link-editor__chrome { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 12px; border-bottom: 1px solid var(--lla-border); background: var(--lla-surface); }
.lla-link-editor__dots { display: flex; flex: none; gap: 5px; }
.lla-link-editor__dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--lla-dot-r); }
.lla-link-editor__dots i:nth-child(2) { background: var(--lla-dot-y); }
.lla-link-editor__dots i:nth-child(3) { background: var(--lla-dot-g); }
.lla-link-editor__url { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; padding: 3px 9px; border-radius: 6px; background: var(--lla-bg); color: var(--lla-muted); font-size: 10.5px; white-space: nowrap; }
.lla-link-editor__url > span { overflow: hidden; text-overflow: ellipsis; }
.lla-link-editor__url .bi { flex: none; font-size: 8.5px; color: var(--lla-success); }

/* ---------- Modal ---------- */
.lla-link-editor__modal { display: flex; flex-direction: column; height: calc(100% - 32px); font-size: 11px; }
.lla-link-editor__mhead { display: flex; flex: none; align-items: center; justify-content: space-between; height: 40px; padding: 0 16px; border-bottom: 1px solid var(--lla-border); }
.lla-link-editor__mhead b { font-size: 13.5px; font-weight: 600; }
.lla-link-editor__mhead span { color: var(--lla-muted); font-size: 18px; line-height: 1; }
.lla-link-editor__mbody { display: flex; flex: 1; min-height: 0; }
.lla-link-editor__mfoot { display: flex; flex: none; justify-content: flex-end; gap: 6px; padding: 8px 16px; border-top: 1px solid var(--lla-border); background: var(--lla-surface); }

.lla-link-editor__btn { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border: 1px solid var(--lla-primary); border-radius: 6px; background: var(--lla-primary); color: #fff; font-size: 10.5px; font-weight: 600; transition: transform .15s var(--lla-ease); }
.lla-link-editor__btn.is-pressed { transform: scale(.95); }
.lla-link-editor__btn--ghost { border-color: #6c757d; background: #6c757d; }
.lla-link-editor__save-b { display: none; align-items: center; gap: 5px; }
.lla-link-editor__save-b .lla-spinner { width: 10px; height: 10px; }
.lla-link-editor[data-saving] .lla-link-editor__save-a { display: none; }
.lla-link-editor[data-saving] .lla-link-editor__save-b { display: inline-flex; }

/* Menú lateral (list-group) */
.lla-link-editor__side { display: flex; flex: none; flex-direction: column; width: 120px; padding-top: 6px; border-right: 1px solid var(--lla-border); background: var(--lla-surface); }
.lla-link-editor__nav { display: flex; align-items: center; gap: 6px; padding: 9px 12px; transition: background-color .2s var(--lla-ease), color .2s var(--lla-ease); }
.lla-link-editor__nav.is-pressed { background: var(--lla-primary-soft); }
.lla-link-editor[data-tab="links"] .lla-link-editor__nav--links,
.lla-link-editor[data-tab="design"] .lla-link-editor__nav--design { background: var(--lla-primary); color: #fff; }
.lla-link-editor__count { margin-left: 2px; padding: 0 5px; border-radius: 4px; background: #6c757d; color: #fff; font-size: 9px; font-weight: 700; }
.lla-link-editor__add { display: flex; align-items: center; justify-content: center; gap: 4px; margin: auto 8px 8px; padding: 6px 0; border-radius: 6px; background: var(--lla-primary); color: #fff; font-size: 10px; font-weight: 600; transition: transform .15s var(--lla-ease); }
.lla-link-editor__add.is-pressed { transform: scale(.94); }

/* Contenido */
.lla-link-editor__content { flex: 1; min-width: 0; padding: 12px 14px; overflow: hidden; }
.lla-link-editor__pane { display: none; }
.lla-link-editor[data-tab="links"] .lla-link-editor__pane--links,
.lla-link-editor[data-tab="design"] .lla-link-editor__pane--design { display: block; animation: lla-le-in .3s var(--lla-ease) both; }
.lla-link-editor__h { display: block; margin-bottom: 8px !important; font-size: 13px; font-weight: 600; }
.lla-link-editor__label { display: block; margin: 10px 0 6px !important; font-size: 10.5px; font-weight: 600; }
.lla-link-editor__check { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-weight: 600; }

/* Tarjetas de link */
.lla-link-editor__card { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; padding: 7px 9px; border: 1px solid var(--lla-border); border-radius: 8px; background: var(--lla-bg); }
.lla-link-editor__card--new { display: none; }
.lla-link-editor[data-new] .lla-link-editor__card--new { display: flex; border-color: var(--lla-primary); animation: lla-le-in .4s var(--lla-ease) both; }
.lla-link-editor__card-top { display: flex; align-items: center; gap: 6px; }
.lla-link-editor__card-top > .bi-grip-vertical { color: var(--lla-muted); }
.lla-link-editor__select { display: inline-flex; align-items: center; gap: 10px; padding: 2px 7px; border: 1px solid var(--lla-border-2); border-radius: 5px; font-size: 10px; }
.lla-link-editor__select .bi { font-size: 7.5px; color: var(--lla-muted); }
.lla-link-editor__active { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 9.5px; }
.lla-link-editor__switch { position: relative; display: inline-block; flex: none; width: 22px; height: 12px; border-radius: 999px; background: var(--lla-primary); }
.lla-link-editor__switch::after { content: ''; position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.lla-link-editor__trash { color: #dc3545; font-size: 10px; }

.lla-link-editor__input {
  position: relative;
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  overflow: hidden;
  border: 1px solid var(--lla-border-2);
  border-radius: 5px;
  font-size: 10px;
  white-space: nowrap;
  transition: border-color .2s var(--lla-ease), box-shadow .2s var(--lla-ease);
}
.lla-link-editor__input--num { width: 70px; }
.lla-link-editor__ph { position: absolute; left: 8px; color: #adb5bd; }
[data-ref]:not(:empty) + .lla-link-editor__ph { display: none; }
.lla-link-editor[data-focus="title"] .lla-link-editor__input--title,
.lla-link-editor[data-focus="url"] .lla-link-editor__input--url { border-color: var(--lla-primary); box-shadow: 0 0 0 2px var(--lla-primary-soft); }

/* Estilos de botón */
.lla-link-editor__styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lla-link-editor__style {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 1px solid var(--lla-border);
  border-radius: 6px;
  background: var(--lla-bg);
  transition: border-color .2s var(--lla-ease), background-color .2s var(--lla-ease), transform .15s var(--lla-ease);
}
.lla-link-editor__style.is-pressed { transform: scale(.95); }
.lla-link-editor__style i { padding: 2px 12px; background: var(--lla-brand); color: #fff; font-size: 9.5px; }
.lla-link-editor__style b { font-size: 10px; font-weight: 700; }
.lla-link-editor__style--rounded i { border-radius: 50px; }
.lla-link-editor__style--square i { border-radius: 8px; }
.lla-link-editor__style--outline i { border: 2px solid var(--lla-brand); border-radius: 50px; background: transparent; color: var(--lla-brand); }
.lla-link-editor:not([data-outline]) .lla-link-editor__style--rounded,
.lla-link-editor[data-outline] .lla-link-editor__style--outline { border-color: var(--lla-primary); background: var(--lla-primary-soft); }

/* ---------- Vista previa (ll-config-live-preview) ---------- */
.lla-link-editor__preview { display: flex; flex: none; flex-direction: column; width: 214px; border-left: 1px solid var(--lla-border); background: var(--lla-surface); }
.lla-link-editor__ptitle { display: flex; align-items: center; gap: 5px; padding: 8px 10px; border-bottom: 1px solid var(--lla-border); color: var(--lla-muted); font-size: 9.5px !important; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.lla-link-editor__pwin { margin: 8px; border: 1px solid var(--lla-border); background: #fff; }

/* El módulo a 1440 px reducido: se ve pequeño y centrado como en el iframe real */
.lla-link-editor__module { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 30px; font-size: 7px; }
.lla-link-editor__mtitle { margin-bottom: 3px !important; font-size: 10px; font-weight: 700; }
.lla-link-editor__lk {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 18px;
  padding: 3px 8px;
  border: 1.5px solid var(--lla-brand);
  border-radius: 50px;
  background: var(--lla-brand);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .35s var(--lla-ease), color .35s var(--lla-ease);
}
.lla-link-editor[data-outline] .lla-link-editor__lk { background: transparent; color: var(--lla-brand); }
.lla-link-editor__lk--img { justify-content: flex-start; padding-left: 3px; }
.lla-link-editor__lk--img > b { flex: 1; text-align: left; }
.lla-link-editor__lk--img > em { opacity: .5; }
.lla-link-editor__lk--img > i { display: flex; flex: none; align-items: center; justify-content: center; width: 13px; height: 13px; border-radius: 50%; background: rgba(255, 255, 255, .25); font-size: 6.5px; }
.lla-link-editor[data-outline] .lla-link-editor__lk--img > i { background: var(--lla-brand-soft); }

/* ---------- Puntero ---------- */
.lla-link-editor__cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  transform: translate(240px, 420px);
  transition: transform .6s var(--lla-ease), opacity .3s var(--lla-ease);
  will-change: transform, opacity;
}
.lla-link-editor[data-cursor] .lla-link-editor__cursor { opacity: 1; }
.lla-link-editor__cursor svg { position: relative; display: block; width: 22px; height: 22px; fill: var(--lla-cursor-fill); stroke: var(--lla-cursor-edge); stroke-width: 1.4; stroke-linejoin: round; }
.lla-link-editor__cursor-ring { position: absolute; left: -10px; top: -12px; width: 28px; height: 28px; border: 2px solid var(--lla-cursor-ring); border-radius: 50%; opacity: 0; }
.lla-link-editor__cursor.is-tap svg { animation: lla-le-press .3s var(--lla-ease); }
.lla-link-editor__cursor.is-tap .lla-link-editor__cursor-ring { animation: lla-le-ripple .5s var(--lla-ease); }

/* ---------- Celular: la vista previa pasa debajo del editor ---------- */
@container (max-width: 479px) {
  .lla .lla-link-editor__stage { --lla-w: 440; --lla-h: 600; }
  .lla-link-editor__win { width: 440px; height: 592px; }
  .lla-link-editor__mbody { flex-wrap: wrap; }
  .lla-link-editor__side { width: 104px; }
  .lla-link-editor__content { flex-basis: 0; }
  .lla-link-editor__preview { order: 3; width: 100%; border-top: 1px solid var(--lla-border); border-left: 0; }
  .lla-link-editor__module { padding: 10px 60px; }
}

/* ---------- Keyframes ---------- */
@keyframes lla-le-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes lla-le-press { 50% { transform: scale(.85); } }
@keyframes lla-le-ripple {
  0% { opacity: .9; transform: scale(.4); }
  100% { opacity: 0; transform: scale(1.4); }
}
