/* ═══════════════════════════════════════════════════════════════════════════
   BUTTON STUDIO — button-studio.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Page shell ──────────────────────────────────────────────────────────── */
.bs-page {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100vh;
  background: var(--color-bg-root);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

/* ── Studio intro bar ────────────────────────────────────────────────────── */
.bs-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-8);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-surface);
}

.bs-intro__title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
}

.bs-intro__mark {
  width: 28px;
  height: 28px;
  background: var(--color-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

.bs-intro__badge {
  font-size: 10px;
  font-family: var(--font-body);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* ── Editor layout: sidebar + preview ───────────────────────────────────── */
.bs-editor {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.bs-sidebar {
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 6px;
}

.bs-sidebar::-webkit-scrollbar { width: 4px; }
.bs-sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* Sidebar sections — card style matching form.css */
.bs-section {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-bg-card);
}

.bs-section__head {
  width: 100%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast);
}

.bs-section__head:hover { background: var(--color-bg-overlay); }

.bs-section__title {
  font-size: 10px;
  font-family: var(--font-body);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bs-section__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bs-section__chevron {
  color: var(--color-text-muted);
  flex-shrink: 0;
  transform: rotate(180deg);
  transition: transform var(--duration-base) var(--ease-in-out);
}

.bs-section__body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.bs-section.is-collapsed .bs-section__body  { display: none; }
.bs-section.is-collapsed .bs-section__chevron { transform: rotate(0deg); }

/* ── Controls ────────────────────────────────────────────────────────────── */
.bs-ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.bs-ctrl-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 72px;
}

.bs-ctrl-val {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--color-accent);
  background: var(--color-accent-glow);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  min-width: 40px;
  text-align: right;
}

/* Range input */
.bs-range {
  -webkit-appearance: none;
  flex: 1;
  height: 3px;
  background: var(--color-bg-overlay);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.bs-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  transition: transform var(--duration-fast);
  border: 2px solid var(--color-bg-root);
}

.bs-range::-webkit-slider-thumb:hover { transform: scale(1.3); }

/* Color row */
.bs-color-ctrl { display: flex; align-items: center; gap: var(--space-2); flex: 1; }

.bs-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.bs-swatch input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
}

.bs-hex-input {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--color-text-primary);
  outline: none;
  width: 90px;
  transition: border-color var(--duration-fast);
}

.bs-hex-input:focus { border-color: var(--color-accent); }

.bs-hex-input--full {
  width: 100%;
  max-width: none;
  flex: 1;
}

/* Select */
.bs-select {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 5px var(--space-2);
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--color-text-primary);
  outline: none;
  flex: 1;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}

.bs-select:focus { border-color: var(--color-accent); }

/* Segmented control */
.bs-seg {
  display: flex;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  flex: 1;
}

.bs-seg__btn {
  flex: 1;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px var(--space-1);
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  letter-spacing: 0.5px;
}

.bs-seg__btn.is-active {
  background: var(--color-bg-overlay);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

/* Font preview */
.bs-font-preview {
  font-size: var(--text-base);
  text-align: center;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  transition: all var(--duration-slow);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.3px;
}

/* Toggle */
.bs-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bs-toggle-label {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.bs-toggle {
  width: 32px;
  height: 18px;
  background: var(--color-bg-overlay);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
  transition: background var(--duration-base);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

.bs-toggle.is-on { background: var(--color-accent); border-color: var(--color-accent); }

.bs-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  transition: transform var(--duration-base);
}

.bs-toggle.is-on::after { transform: translateX(14px); }

/* ── Preview panel ───────────────────────────────────────────────────────── */
.bs-preview {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bs-preview__topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-surface);
  flex-shrink: 0;
}

.bs-preview__label {
  font-size: 10px;
  font-family: var(--font-body);
  letter-spacing: var(--tracking-widest);
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.bs-preview__bg-btns {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}

.bs-bg-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.bs-bg-dot.is-active { border-color: var(--color-text-primary); }

.bs-preview__canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
  overflow: auto;
  transition: background var(--duration-slow);
  position: relative;
}

.bs-props-overlay {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--color-text-muted);
  line-height: var(--leading-loose);
  max-width: 220px;
  pointer-events: none;
}

.bs-props-overlay b { color: var(--color-text-secondary); }

/* ── Generate bar ────────────────────────────────────────────────────────── */
.bs-gen-bar {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-surface);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.bs-gen-btn {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out-expo);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.bs-gen-btn:hover {
  background: var(--color-accent-dim);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px var(--color-accent-glow);
}

.bs-gen-btn:active { transform: translateY(0); }

/* Variante Figma del botón de generación */
.bs-gen-btn--figma {
  background: #1a1a2e;
  color: #fff;
  box-shadow: none;
}
.bs-gen-btn--figma:hover {
  background: #2a2a3e;
  box-shadow: 0 8px 24px rgba(26, 26, 46, .4);
  transform: translateY(-1px);
}
.bs-gen-btn--figma:active { transform: translateY(0); }

.bs-gen-hint {
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: var(--font-body);
}

/* Material icon helper */
.mi {
  font-family: 'Material Symbols Rounded';
  font-style: normal;
  font-size: inherit;
  line-height: 1;
  user-select: none;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* ── System output ───────────────────────────────────────────────────────── */
.bs-output {
  display: none;
  background: var(--color-bg-root);
  padding: var(--space-12) var(--space-8) var(--space-24);
}

.bs-output.is-visible { display: block; }

.bs-output__inner {
  max-width: 1400px;
  margin: 0 auto;
}

.bs-output__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.bs-output__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  letter-spacing: var(--tracking-tight);
}

.bs-output__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-body);
}

/* System sections */
.bs-sys-section { margin-bottom: var(--space-16); }

.bs-sys-section__title {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bs-sys-section__title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Format sub-label inside full matrix */
.bs-fmt-label {
  font-size: 11px;
  font-family: var(--font-body);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  letter-spacing: 1px;
}

.bs-fmt-block { margin-bottom: var(--space-8); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.bs-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
}

.bs-table {
  width: 100%;
  border-collapse: collapse;
}

.bs-table th {
  padding: var(--space-2) var(--space-4);
  font-size: 9px;
  font-family: var(--font-body);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: left;
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.bs-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.bs-table tr:last-child td { border-bottom: none; }
.bs-table tr:hover td      { background: var(--color-bg-elevated); }

/* Table cell helpers */
.bs-size-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 10px;
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  color: var(--color-text-secondary);
  letter-spacing: 1px;
}

.bs-td-mono {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--color-text-secondary);
}

.bs-td-mono b   { color: var(--color-text-primary); }
.bs-td-mono span { color: var(--color-accent); }

.bs-td-dim { font-size: 10px; color: var(--color-text-muted); }

.bs-btn-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 80px;
}

.bs-spec-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--color-text-muted);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
}

.bs-spec-chip b { color: var(--color-text-secondary); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.bs-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  opacity: 0;
  transition: all var(--duration-slow) var(--ease-spring);
  z-index: var(--z-toast);
  pointer-events: none;
  white-space: nowrap;
}

.bs-toast.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Scrollbar global ────────────────────────────────────────────────────── */
::-webkit-scrollbar         { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb   { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-track   { background: transparent; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .bs-editor { grid-template-columns: 1fr; }
  .bs-props-overlay { display: none; }
  .bs-gen-hint { display: none; }
  .bs-output {
    min-width: inherit;
    max-width: inherit;
    width: 100%;
    overflow-x: hidden;
  }
  .bs-gen-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .bs-gen-bar button{
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .bs-output__meta { display: none; }
}