/* ════════════════════════════════════════════════════════
   BUILDER.CSS — Panel de personalización visual
   ════════════════════════════════════════════════════════ */

/* ── FAB (floating action button) ─────────────────────── */
.builder-fab {
  position: fixed; bottom: 88px; right: 24px; z-index: 90;
  background: #3A3535; color: #fff;
  border: none; border-radius: 50px;
  padding: 12px 22px; font-size: .88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  display: none; align-items: center; gap: 8px;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.builder-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(0,0,0,.3); background: #2a2828; }
.builder-fab.is-open { background: var(--sage, #8BAF8B); }

/* ── BACKDROP ──────────────────────────────────────────── */
.builder-backdrop {
  display: none; position: fixed; inset: 0; z-index: 149;
  background: rgba(0,0,0,.05);
  animation: fadeIn .25s ease;
}
.builder-backdrop.open { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── DRAWER ────────────────────────────────────────────── */
.builder-drawer {
  position: fixed; top: 0; right: -420px; bottom: 0; z-index: 150;
  width: 400px; max-width: 100vw; height: 100vh;
  background: #fff;
  box-shadow: -6px 0 40px rgba(0,0,0,.14);
  display: flex; flex-direction: column; overflow: hidden;
  transition: right .32s cubic-bezier(.4,0,.2,1);
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
}
.builder-drawer.open { right: 0; }

/* ── DRAWER HEADER ─────────────────────────────────────── */
.builder-head {
  background: #3A3535; color: #fff;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.builder-head-icon { font-size: 1.1rem; }
.builder-head-title { flex: 1; font-size: .92rem; font-weight: 600; }
.builder-dirty { display: none; width: 8px; height: 8px; border-radius: 50%; background: #f0a030; animation: bpulse .9s ease-in-out infinite alternate; }
@keyframes bpulse { to { opacity: .35; } }
.btn-bsave {
  background: var(--sage, #8BAF8B); color: #fff;
  border: none; border-radius: 50px; padding: 7px 18px;
  font-size: .8rem; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background .2s, opacity .2s;
}
.btn-bsave:hover { background: #6d9370; }
.btn-bsave:disabled { opacity: .5; cursor: not-allowed; }
.btn-bsave.saved { background: #3d7a40; }
.btn-bclose {
  background: rgba(255,255,255,.14); color: #fff; border: none;
  border-radius: 8px; width: 30px; height: 30px;
  font-size: 1rem; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.btn-bclose:hover { background: rgba(255,255,255,.25); }

/* ── TABS ──────────────────────────────────────────────── */
.builder-tabs {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 10px; background: #f7f7f7;
  border-bottom: 1px solid #e8e8e8; flex-shrink: 0;
}
.btab {
  flex: 1 0 calc(33.333% - 10px);
  background: #fff; border: 1.5px solid #eaeaea; border-radius: 10px;
  padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: .68rem; font-weight: 700; color: #aaa;
  cursor: pointer; font-family: inherit; letter-spacing: .02em;
  transition: all .18s; white-space: nowrap;
}
.btab:hover:not(.active) { color: #666; border-color: #ccc; background: #fafafa; }
.btab.active {
  color: var(--sage, #8BAF8B); border-color: var(--sage, #8BAF8B);
  background: #f2f8f2; box-shadow: 0 2px 8px rgba(139,175,139,.15);
}
.btab-icon  { font-size: 1.15rem; line-height: 1; }
.btab-label { line-height: 1; }

/* ── BODY / SCROLL ─────────────────────────────────────── */
.builder-body { flex: 1; overflow-y: auto; padding: 18px; scroll-behavior: smooth; min-height: 0; -webkit-overflow-scrolling: touch; }
.builder-body::-webkit-scrollbar { width: 4px; }
.builder-body::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 4px; }

.btab-pane { display: none; }
.btab-pane.active { display: block; }

/* ── SECTION LABELS ────────────────────────────────────── */
.b-sec {
  font-size: .68rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: #bbb; margin: 20px 0 10px;
}
.b-sec:first-child { margin-top: 0; }

/* ── FORM ELEMENTS ─────────────────────────────────────── */
.b-field { margin-bottom: 12px; }
.b-label { display: block; font-size: .75rem; font-weight: 700; color: #777; margin-bottom: 5px; }
.b-input, .b-select, .b-textarea {
  width: 100%; padding: 8px 11px;
  border: 1.5px solid #e4e4e4; border-radius: 8px;
  font-size: .84rem; font-family: inherit;
  background: #fff; color: #3A3535;
  outline: none; transition: border-color .18s;
}
.b-input:focus, .b-select:focus, .b-textarea:focus { border-color: var(--sage, #8BAF8B); }
.b-textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.b-select { cursor: pointer; }

/* ── COLOR GRID ────────────────────────────────────────── */
.b-colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.b-color-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.b-color-item span { font-size: .68rem; color: #999; text-align: center; }
.b-swatch {
  width: 48px; height: 48px; border-radius: 12px;
  border: 2px solid #e8e8e8; position: relative; overflow: hidden;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.b-swatch:hover { transform: scale(1.1); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.b-swatch-bg  { position: absolute; inset: 0; }
.b-swatch input[type="color"] {
  position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px);
  border: none; padding: 0; margin: 0; cursor: pointer; opacity: 0;
}

/* ── FONT PREVIEW ──────────────────────────────────────── */
.b-font-preview {
  margin-top: 7px; padding: 8px 12px;
  background: #f8f8f8; border-radius: 8px;
  font-size: 1.05rem; color: #888; text-align: center;
  transition: font-family .3s;
}

/* ── SECTION LIST (drag-and-drop) ──────────────────────── */
.sec-list { display: flex; flex-direction: column; gap: 7px; }
.sec-item {
  background: #f9f9f9; border: 1.5px solid #eaeaea;
  border-radius: 10px; padding: 11px 14px;
  display: flex; align-items: center; gap: 10px;
  transition: box-shadow .15s, border-color .15s, opacity .15s;
  user-select: none; cursor: default;
}
.sec-item.dragging  { opacity: .45; }
.sec-item.drag-over { border-color: var(--sage, #8BAF8B); box-shadow: 0 0 0 3px rgba(139,175,139,.18); }
.sec-drag { cursor: grab; color: #ccc; font-size: 1.1rem; line-height: 1; flex-shrink: 0; }
.sec-drag:active { cursor: grabbing; }
.sec-name { flex: 1; font-size: .86rem; font-weight: 600; color: #3A3535; }
.sec-hint { font-size: .72rem; color: #bbb; margin-left: auto; }

/* Toggle switch */
.b-toggle { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.b-toggle input { opacity: 0; width: 0; height: 0; }
.b-toggle-track {
  position: absolute; inset: 0;
  background: #d0d0d0; border-radius: 22px; cursor: pointer;
  transition: background .2s;
}
.b-toggle input:checked + .b-toggle-track { background: var(--sage, #8BAF8B); }
.b-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform .2s; pointer-events: none;
}
.b-toggle input:checked ~ .b-toggle-thumb { transform: translateX(16px); }

/* ── CARD / PILL EDITORS ───────────────────────────────── */
.editor-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.editor-item {
  background: #f9f9f9; border: 1.5px solid #eaeaea;
  border-radius: 10px; padding: 10px 12px;
}
.editor-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.editor-row:last-child { margin-bottom: 0; }
.b-emoji {
  width: 42px; height: 36px; text-align: center; font-size: 1.2rem;
  border: 1.5px solid #e4e4e4; border-radius: 8px;
  font-family: inherit; background: #fff; flex-shrink: 0; padding: 0 4px;
  outline: none; transition: border-color .18s;
}
.b-emoji:focus { border-color: var(--sage, #8BAF8B); }
.btn-remove {
  background: none; border: 1.5px solid #f0d0d0; color: #c07070;
  border-radius: 7px; padding: 4px 9px; font-size: .75rem;
  cursor: pointer; flex-shrink: 0; font-family: inherit;
  transition: all .15s; line-height: 1.4;
}
.btn-remove:hover { background: #fde8e8; border-color: #c07070; }
.btn-add {
  width: 100%; background: none;
  border: 1.5px dashed var(--sage-l, #C6DAC6);
  border-radius: 10px; padding: 10px;
  font-size: .8rem; font-weight: 700;
  color: var(--sage, #8BAF8B); cursor: pointer; font-family: inherit;
  transition: all .18s;
}
.btn-add:hover { background: #f0f8f0; border-color: var(--sage, #8BAF8B); }

/* ── DRAG-ITEM (card editor draggable) ─────────────────── */
.editor-item[draggable="true"] { cursor: grab; }
.editor-item[draggable="true"]:active { cursor: grabbing; opacity: .6; }
.editor-item.drag-over { border-color: var(--sage, #8BAF8B); }

/* ── STAT ROWS ─────────────────────────────────────────── */
.stat-row { display: flex; gap: 7px; margin-bottom: 7px; align-items: center; }
.stat-row .b-stat-val { flex: 0 0 70px; }
.stat-row .b-stat-lbl { flex: 1; }
.stat-label { font-size: .7rem; color: #aaa; margin-bottom: 3px; }

/* ── RESET BUTTON ──────────────────────────────────────── */
.b-reset-row { margin-bottom: 18px; }
.btn-reset {
  width: 100%; background: none;
  border: 1.5px solid #e8ddd8; border-radius: 10px;
  padding: 10px 16px; font-size: .8rem; font-weight: 700;
  color: #b08070; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .18s;
}
.btn-reset:hover { background: #fff4f0; border-color: #c49a86; color: #a0705a; }

/* ── TOAST ADJUSTMENT ──────────────────────────────────── */
/* Nudge the toast up when builder is open to avoid overlap */
body.builder-open #toast { right: 418px; }
