/* Creador de temas · Administración. Solo presentación del estudio. */

#acThemeTrialBar {
  position: fixed;
  z-index: 4000;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 24px));
  padding: 8px 12px;
  border: 1px solid #d6ff5c;
  background: #11110d;
  color: #f6f3e8;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  font-size: 13px;
}
#acThemeTrialBar[hidden] { display: none !important; }
#acThemeTrialBar button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d6ff5c;
  background: #d6ff5c;
  color: #16210b;
  font-weight: 700;
  cursor: pointer;
}

#temas .theme-studio-layout {
  min-height: 0;
  overflow: auto;
}
.theme-studio {
  display: grid;
  gap: 14px;
  padding: 0 14px 18px;
  min-width: 0;
}
.theme-studio .hint { margin: 0; color: var(--ink-muted); font-size: var(--font-sm); }
.theme-studio-saved .btn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.theme-studio-toolbar,
.theme-studio-ai,
.theme-preview-shell {
  border: 1px solid var(--line);
  background: var(--surface);
}
.theme-studio-toolbar,
.theme-studio-ai { padding: 12px; display: grid; gap: 10px; }
.theme-studio-saved { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}
.theme-studio-editor { display: grid; gap: 8px; align-content: start; min-width: 0; }
.theme-studio-ident {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}
.theme-studio-ident label,
.theme-studio-ai label {
  display: grid;
  gap: 4px;
  color: var(--ink-muted);
  font-size: var(--font-xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.theme-group { border: 1px solid var(--line); background: var(--surface); }
.theme-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-deep);
  font-weight: 700;
}
.theme-group > summary::-webkit-details-marker { display: none; }
.theme-group-body { display: grid; gap: 8px; padding: 10px; }
.theme-token {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: center;
}
.theme-token input[type="color"] {
  width: 42px;
  height: 36px;
  padding: 2px;
  cursor: pointer;
}
.theme-token input.hex {
  width: 92px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.theme-token strong { display: block; color: var(--ink-strong); font-size: 13px; }
.theme-token code, .theme-token em { display: block; color: var(--ink-muted); font-size: var(--font-xs); font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; }
.theme-contrast { display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.theme-contrast-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.theme-contrast-row.is-fail { color: var(--danger); font-weight: 700; }
.theme-contrast-row em { color: var(--ink-muted); font-style: normal; font-weight: 500; }

/* Galería: reconocer un tema por su color antes de abrirlo. Las tarjetas caben
   a dos columnas en el ancho mínimo (280px) de la columna del editor. */
.theme-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.theme-card {
  display: grid;
  /* La nota de «Auto» ocupa tres líneas: sin fila elástica, sus botones
     quedaban un escalón por debajo de los de las demás tarjetas. */
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.theme-card.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-card-swatches { display: flex; height: 26px; border: 1px solid var(--line-strong); }
.theme-card-swatches i { flex: 1; }
.theme-card-body strong { display: block; color: var(--ink-strong); font-size: 13px; }
.theme-card-body .hint { font-size: var(--font-xs); }
.theme-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-card-actions .btn { flex: 1; min-width: 74px; }
.theme-notes { grid-column: 1 / -1; }
.theme-notes textarea { resize: vertical; font: inherit; text-transform: none; letter-spacing: 0; font-weight: 500; }

.theme-preview-shell { overflow: hidden; }
.theme-preview-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  font-size: var(--font-xs);
  color: var(--ink-muted);
}
.theme-preview {
  --row-h: 36px;
  min-height: 520px;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
}
.theme-preview-nav {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 8px 6px;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
}
.theme-preview-nav a {
  display: block;
  padding: 8px 8px;
  color: var(--ink-muted);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.theme-preview-nav a.is-active {
  background: var(--surface-2);
  color: var(--ink-strong);
  border-left-color: var(--accent);
}
.theme-preview-main { display: grid; grid-template-rows: auto auto 1fr; min-width: 0; }
.theme-preview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}
.theme-preview-work { display: grid; gap: 10px; padding: 10px; overflow: auto; }
.theme-preview-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.theme-preview-metric {
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}
.theme-preview-metric strong { display: block; font-family: var(--font-mono); font-size: 16px; color: var(--ink-strong); }
.theme-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.theme-preview th {
  text-align: left;
  padding: 6px 8px;
  background: var(--bg-deep);
  color: var(--ink-muted);
  font-size: var(--font-xs);
  text-transform: uppercase;
}
.theme-preview td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.theme-preview tbody tr:nth-child(even) { background: var(--surface-2); }
.theme-preview tbody tr.is-active td { background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.theme-preview .toast {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 6px 10px;
  border-left: 4px solid var(--success);
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
}
.theme-ai-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.theme-ai-result { display: grid; gap: 6px; }
.theme-ai-result[hidden] { display: none; }

@media (max-width: 1100px) {
  .theme-studio-grid,
  .theme-preview,
  .theme-studio-ident { grid-template-columns: 1fr; }
  .theme-preview-nav { display: none; }
  .theme-preview-metrics { grid-template-columns: 1fr 1fr; }
}

/* Keep the existing Save/More controls reachable on a narrow theme editor.
   This follows the two-row header already used by the farm workspace. */
@media (max-width: 550px) {
  body[data-active-module="themes"] { --topbar-h: 96px; }
  body[data-active-module="themes"] .workspace {
    grid-template-rows: 96px minmax(0, 1fr);
  }
  body[data-active-module="themes"] .workspace > .topbar.ac-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 192px;
    grid-template-rows: 40px 44px;
    gap: 4px 8px;
    height: 96px;
    min-height: 96px;
    max-height: 96px;
    padding: 4px 12px;
  }
  html.mobile-full-app body[data-active-module="themes"] .ac-topbar .topbar-route {
    display: flex;
    flex: initial;
    width: auto;
  }
  body[data-active-module="themes"] .ac-topbar #moduleTitle {
    font-size: 14px;
    flex-shrink: 1;
  }
  body[data-active-module="themes"] .ac-topbar #moduleActionHost {
    grid-template-columns: 120px 64px;
    width: 192px;
    justify-content: start;
  }
  body[data-active-module="themes"] #modulePrimaryAction { width: 120px; font-size: 13px; }
  body[data-active-module="themes"] #moduleMoreMenu { width: 64px; }
  body[data-active-module="themes"] .ac-topbar .topbar-global-controls {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    flex: initial;
    justify-content: flex-end;
  }
  body[data-active-module="themes"] .ac-topbar .global-search-shell {
    flex: 1 1 44px;
    min-width: 44px;
    width: auto;
  }
  body[data-active-module="themes"] .ac-topbar .global-search-input { width: 100%; }
}
