/* ==========================================================================
   Comunidad360 — preview interactivo del app
   Selectores de rol y plan, marco de dispositivo, tarjetas y bloqueo por plan.
   ========================================================================== */

.preview {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* --- panel de control --------------------------------------------------- */

.control {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.control__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.control__label b {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--brand);
  font-weight: 600;
}

.roles {
  display: grid;
  gap: 8px;
}

.role-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}

.role-btn:hover {
  background: var(--surface-2);
}

.role-btn[aria-selected='true'] {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.role-btn__ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}

.role-btn[aria-selected='true'] .role-btn__ico {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
}

.role-btn__ico .ico {
  width: 17px;
  height: 17px;
}

.role-btn__txt {
  min-width: 0;
}

.role-btn__txt strong {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 600;
}

.role-btn__txt span {
  display: block;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.4;
  margin-top: 1px;
}

.mini-badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.segmented button {
  padding: 8px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-selected='true'] {
  background: var(--brand);
  color: #fff;
}

.control__hint {
  font-size: 13px;
  color: var(--text-faint);
  line-height: 1.5;
}

.control__stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.control__stat strong {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.control__stat span {
  font-size: 13px;
  color: var(--text-faint);
}

/* --- escenario ---------------------------------------------------------- */

.stage {
  min-width: 0;
}

.stage__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stage__title {
  font-size: 15px;
  font-weight: 600;
}

.stage__title span {
  color: var(--text-faint);
  font-weight: 400;
}

.stage__tools {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.stage__tools button {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.stage__tools button[aria-selected='true'] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* --- marco del dispositivo ---------------------------------------------- */

.device {
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: max-width 0.32s var(--ease);
  margin: 0 auto;
  max-width: 100%;
}

.device.is-mobile {
  max-width: 400px;
  border-radius: 30px;
}

.device__chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.device__dots {
  display: flex;
  gap: 6px;
}

.device__dots i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--line-strong);
}

.device__url {
  flex: 1;
  min-width: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device.is-mobile .device__dots,
.device.is-mobile .device__url {
  display: none;
}

.device.is-mobile .device__chrome {
  justify-content: center;
  padding: 8px 14px 10px;
}

.device.is-mobile .device__chrome::before {
  content: '';
  width: 84px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
}

/* --- pantalla del app --------------------------------------------------- */

.app {
  padding: 20px;
  max-height: 720px;
  overflow: auto;
  scrollbar-width: thin;
}

.device.is-mobile .app {
  padding: 16px;
  max-height: 640px;
}

.app__top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.app__avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), var(--mint));
  color: #fff;
  font-weight: 650;
  font-size: 14px;
}

.app__who strong {
  display: block;
  font-size: 16.5px;
}

.app__who span {
  font-size: 12.5px;
  color: var(--text-faint);
}

.app__plan {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.device.is-mobile .app__plan {
  display: none;
}

.app__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.device.is-mobile .app__grid {
  grid-template-columns: 1fr;
}

.app__grid > .card--wide {
  grid-column: span 2;
}

.device.is-mobile .app__grid > .card--wide {
  grid-column: span 1;
}

/* --- tarjeta ------------------------------------------------------------ */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  /* Sin fill-mode: si la animación no corre, la tarjeta ya está en su estado final. */
  animation: card-in 0.4s var(--ease);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card__head h4 {
  font-size: 14.5px;
  font-weight: 650;
}

.card__head p {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 3px;
  line-height: 1.45;
}

.card__flag {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.card__flag--profesional {
  background: var(--brand-soft);
  color: var(--brand);
}

.card__flag--premium {
  background: var(--mint-soft);
  color: var(--mint);
}

/* bloqueada por plan */
.card.is-locked {
  border-style: dashed;
  border-color: var(--line-strong);
  background: transparent;
}

.card.is-locked .card__content {
  filter: blur(3.5px) saturate(0.5);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  max-height: 132px;
  overflow: hidden;
}

.card__lock {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.card__lock .ico {
  width: 17px;
  height: 17px;
  color: var(--text-faint);
}

.card__lock strong {
  font-size: 12.5px;
  font-weight: 650;
  display: block;
}

.card__lock span {
  font-size: 11.5px;
  color: var(--text-faint);
}

.card__lock button {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.card__lock button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* --- renderers ---------------------------------------------------------- */

/* bullets */
.bullets {
  display: grid;
  gap: 11px;
}

.bullets li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.bullets .dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--brand);
}

.bullets .dot .ico {
  width: 14px;
  height: 14px;
}

.bullets strong {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

.bullets span {
  font-size: 12px;
  color: var(--text-faint);
}

/* kpis */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  padding: 11px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.kpi__label {
  font-size: 11.5px;
  color: var(--text-faint);
}

.kpi__value {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.kpi__delta {
  font-size: 11.5px;
  margin-top: 2px;
}

.tone-good {
  color: var(--mint);
}

.tone-warn {
  color: var(--warn);
}

.tone-danger {
  color: var(--danger);
}

.tone-muted {
  color: var(--text-faint);
}

/* list */
.rows {
  display: grid;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.row__txt {
  min-width: 0;
}

.row__txt strong {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
}

.row__txt span {
  font-size: 12px;
  color: var(--text-faint);
}

.tag {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  border: 1px solid currentColor;
}

/* progress */
.bars {
  display: grid;
  gap: 13px;
}

.bar__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 6px;
}

.bar__top b {
  font-variant-numeric: tabular-nums;
}

.bar__track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  width: 0;
  transition: width 0.7s var(--ease);
}

.bar__fill.tone-good {
  background: var(--mint);
}

.bar__fill.tone-warn {
  background: var(--warn);
}

.bar__fill.tone-danger {
  background: var(--danger);
}

/* table */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.mini-table th {
  text-align: left;
  padding: 6px 9px;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.mini-table td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
}

.mini-table tr:last-child td {
  border-bottom: 0;
}

.mini-table tr.is-best td {
  background: var(--mint-soft);
}

.mini-table tr.is-best td:first-child {
  font-weight: 650;
  border-left: 2px solid var(--mint);
}

.table-note {
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  gap: 7px;
  align-items: flex-start;
}

.table-note .ico {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  color: var(--mint);
}

/* chat */
.chat {
  display: grid;
  gap: 9px;
}

.msg {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.45;
}

.msg--user {
  justify-self: end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg--bot {
  justify-self: start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.chat__input {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 3px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-faint);
}

.chat__input .ico {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: var(--brand);
}

/* timeline */
.steps {
  display: grid;
  gap: 2px;
}

.step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 11px;
}

.step__rail {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.step__node {
  width: 13px;
  height: 13px;
  margin-top: 4px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
}

.step--done .step__node {
  border-color: var(--mint);
  background: var(--mint);
}

.step--active .step__node {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.step__line {
  width: 2px;
  flex: 1;
  min-height: 18px;
  background: var(--line);
}

.step:last-child .step__line {
  display: none;
}

.step__body {
  padding-bottom: 12px;
}

.step__body strong {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
}

.step__body span {
  font-size: 12px;
  color: var(--text-faint);
}

.step--todo .step__body {
  opacity: 0.62;
}

/* breakdown */
.stack {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.stack i {
  display: block;
  height: 100%;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px 14px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.legend b {
  margin-left: auto;
  color: var(--text-faint);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* slider */
.sim__value {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.sim__value strong {
  font-size: 28px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.sim__value span {
  font-size: 12.5px;
  color: var(--text-faint);
}

.sim input[type='range'] {
  width: 100%;
  accent-color: var(--brand);
}

.sim__out {
  display: grid;
  gap: 8px;
}

.sim__out div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
}

.sim__out b {
  font-variant-numeric: tabular-nums;
}

/* action */
.action {
  display: grid;
  gap: 11px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chips span {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-dim);
}

.action__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
}

/* --- demo guiada -------------------------------------------------------- */

.tour {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.tour__steps {
  display: grid;
  gap: 8px;
}

.tour__step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 13px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.tour__step:hover {
  background: var(--surface-2);
}

.tour__step[aria-selected='true'] {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.tour__num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 650;
  color: var(--text-faint);
}

.tour__step[aria-selected='true'] .tour__num {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
}

.tour__step strong {
  display: block;
  font-size: 14.5px;
}

.tour__step p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.5;
}

.tour__screen {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  min-height: 300px;
}

.tour__screen .card {
  opacity: 0.42;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.tour__screen .card.is-focus {
  opacity: 1;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  transform: translateY(-2px);
}

.tour__caption {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-faint);
}

.tour__caption .ico {
  width: 16px;
  height: 16px;
  color: var(--brand);
}

/* --- simulación de video ------------------------------------------------ */

.sim-player {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
}

.sim-player__screen {
  padding: 18px;
  min-height: 320px;
  /* Acotado para que el pie de reproducción y el subtítulo siempre se vean. */
  max-height: min(52vh, 460px);
  overflow: hidden;
}

.sim-player__screen .app__grid {
  grid-template-columns: 1fr;
}

/* En una sola columna, una tarjeta ancha crearía columna implícita. */
.sim-player__screen .app__grid > .card--wide {
  grid-column: span 1;
}

.sim-player__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-faint);
}

.sim-player__track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.sim-player__fill {
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width 0.5s linear;
}

.sim-player__cap {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  background: var(--surface);
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 1020px) {
  .preview,
  .tour {
    grid-template-columns: 1fr;
  }

  .control {
    position: static;
  }

  .app__grid {
    grid-template-columns: 1fr;
  }

  .app__grid > .card--wide {
    grid-column: span 1;
  }
}

@media (max-width: 520px) {
  .kpis {
    grid-template-columns: 1fr;
  }

  .stage__tools {
    width: 100%;
    margin-left: 0;
  }

  .stage__tools button {
    flex: 1;
  }
}
