/* ============================================================
   components.css — botones, cards, inputs, chips, métricas, toast
============================================================ */

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color var(--transition);
}

.card-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 150ms;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-block { width: 100%; }

/* Inputs */
.input,
.select,
.textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 150ms;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.field { margin-bottom: 16px; }

.password-wrap {
  position: relative;
}

.password-wrap .input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-radius: 8px;
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  color: var(--text);
}

.password-hints {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.password-hints li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-3);
}

.password-hint-mark {
  width: 12px;
  flex: 0 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.password-hints li.is-ok,
.password-hints li.is-miss {
  color: var(--text-2);
}

.password-hints li.is-ok .password-hint-mark {
  color: var(--accent-dark);
}

.password-match {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-2);
}

.row { display: grid; gap: 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 800px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 150ms;
  user-select: none;
  cursor: pointer;
  font-family: inherit;
}

.chip-emoji {
  font-size: 1.05rem;
  line-height: 1;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.chip.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.account-email-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.chip-category {
  font-size: 0.78rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 14px 0 8px;
  font-weight: 600;
}

/* Cuotas de uso IA */
.quota-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-3);
}

.quota-chip strong {
  color: var(--accent);
  font-weight: 700;
}

/* Métricas */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.metric-value {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  color: var(--text);
  margin-top: 6px;
  line-height: 1;
}

.metric-value.accent { color: var(--accent); }

.metric-unit {
  font-size: 0.85rem;
  color: var(--text-3);
  font-family: 'DM Sans', sans-serif;
  margin-left: 4px;
}

@media (max-width: 800px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

/* Loading overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  flex-direction: column;
  gap: 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}

.overlay-text {
  color: var(--text);
  font-size: 1rem;
  max-width: 320px;
  text-align: center;
}

.overlay-sub {
  color: var(--text-2);
  font-size: 0.85rem;
  max-width: 320px;
  text-align: center;
}

/* ====== Overlay rico para generación con IA ====== */
.gen-overlay {
  gap: 14px;
}

.gen-scene {
  position: relative;
  width: 320px;
  height: 240px;
  margin-bottom: 4px;
  overflow: hidden;
}

.gen-food {
  position: absolute;
  bottom: -40px;
  animation: genRise linear infinite;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  pointer-events: none;
}

.gen-equipment {
  position: absolute;
  bottom: -40px;
  animation: genRise linear infinite;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  pointer-events: none;
}

.gen-scene--workout .gen-pot,
.gen-scene--workout .gen-steam,
.gen-scene--workout .gen-chef {
  display: none;
}

.gen-gym-floor {
  position: absolute;
  bottom: 0;
  left: 8%;
  right: 8%;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  z-index: 1;
}

.gen-trainer {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 76px;
  animation: genChefBounce 1.4s ease-in-out infinite;
  z-index: 3;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

@keyframes genRise {
  0%   { transform: translateY(0) rotate(0deg) scale(0.8); opacity: 0; }
  12%  { opacity: 1; transform: translateY(-30px) rotate(20deg) scale(1); }
  85%  { opacity: 1; }
  100% { transform: translateY(-280px) rotate(360deg) scale(0.7); opacity: 0; }
}

.gen-chef {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 76px;
  animation: genChefBounce 1.4s ease-in-out infinite;
  z-index: 3;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

@keyframes genChefBounce {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-4deg); }
  50%      { transform: translateX(-50%) translateY(-10px) rotate(4deg); }
}

.gen-pot {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  z-index: 2;
  animation: genPotShake 0.4s ease-in-out infinite alternate;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

@keyframes genPotShake {
  from { transform: translateX(-50%) rotate(-2deg); }
  to   { transform: translateX(-50%) rotate(2deg); }
}

.gen-steam {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 60px;
  z-index: 1;
}

.gen-steam span {
  position: absolute;
  bottom: 0;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  filter: blur(4px);
  animation: genSteamRise 2s ease-out infinite;
}

.gen-steam span:nth-child(1) { left: 8px;  animation-delay: 0s; }
.gen-steam span:nth-child(2) { left: 22px; animation-delay: 0.6s; }
.gen-steam span:nth-child(3) { left: 36px; animation-delay: 1.2s; }

@keyframes genSteamRise {
  0%   { transform: translateY(0) scale(1); opacity: 0; }
  20%  { opacity: 0.8; }
  100% { transform: translateY(-60px) scale(2.5); opacity: 0; }
}

/* Texto del overlay: agrupado en una "card" para destacar sobre la animación */
.gen-overlay {
  gap: 0;
}

.gen-text-block {
  background: rgba(20, 20, 20, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 22px 28px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  position: relative;
  z-index: 5;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .gen-text-block {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
}

.gen-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: #ffffff;
  text-align: center;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .gen-title {
  color: #1a1a1a;
  text-shadow: none;
}

.gen-status {
  color: rgba(255, 255, 255, 0.92);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  max-width: 360px;
  min-height: 26px;
  transition: opacity 200ms ease;
  padding: 0 4px;
}

[data-theme="light"] .gen-status {
  color: #2a2a2a;
}

.gen-dots {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.gen-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: genDotPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent);
}

.gen-dots span:nth-child(2) { animation-delay: 0.2s; }
.gen-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes genDotPulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.35; }
  40%           { transform: scale(1.1);  opacity: 1; }
}

.gen-warning {
  display: block;
  background: rgba(255, 209, 102, 0.18);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: #ffd166;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  padding: 12px 14px;
  margin: 12px 0 4px 0;
  border-radius: 10px;
  line-height: 1.5;
  max-width: 380px;
}

[data-theme="light"] .gen-warning {
  background: rgba(213, 132, 0, 0.12);
  border-color: rgba(213, 132, 0, 0.5);
  color: #8a5500;
}

.gen-tip {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.85rem;
  margin-top: 4px;
  text-align: center;
  max-width: 320px;
}

[data-theme="light"] .gen-tip {
  color: rgba(0, 0, 0, 0.55);
}

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-dialog {
  width: 100%;
  max-width: 400px;
  margin: 0;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  animation: confirmIn 220ms ease;
}

.confirm-dialog-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  margin: 0 0 10px;
  line-height: 1.35;
  color: var(--text);
}

.confirm-dialog-message {
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0 0 20px;
  white-space: pre-line; /* respeta \n en mensajes (p. ej. línea de cupos) */
}

/* Anuncio con texto rico: el cuerpo trae <p>/<ul>/<strong>/<a> generados por
   rich-text.js, así que aquí NO va white-space: pre-line (duplicaría saltos). */
.announcement-body {
  white-space: normal;
}

.announcement-body p {
  margin: 0 0 0.7em;
}

.announcement-body p:last-child,
.announcement-body ul:last-child {
  margin-bottom: 0;
}

.announcement-body ul {
  margin: 0 0 0.7em;
  padding-left: 1.2em;
}

.announcement-body li {
  margin-bottom: 0.25em;
}

.announcement-body a {
  color: var(--accent);
  text-decoration: underline;
}

.announcement-body strong {
  color: var(--text);
  font-weight: 600;
}

.confirm-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-dialog-actions .btn {
  flex: 1;
  min-width: 120px;
}

@media (max-width: 420px) {
  .confirm-dialog-actions {
    flex-direction: column-reverse;
  }
  .confirm-dialog-actions .btn {
    width: 100%;
    flex: none;
  }
}

@keyframes confirmIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-area-bottom) + var(--mobile-browser-bottom-buffer));
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  z-index: 200;
  animation: slideIn 300ms ease;
  max-width: 360px;
}

.toast.success { border-color: var(--success); }
.toast.error {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin-top: -2px;
  flex-shrink: 0;
}

.toast-close:hover { color: var(--text); }


/* ----- Env badge (QA / DEV / PREVIEW) ----- */
.env-badge {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 9999;
  padding: 4px 10px;
  border-radius: 999px;
  color: #0a0a0a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: help;
  user-select: none;
  pointer-events: auto;
}

@media (max-width: 800px) {
  .env-badge {
    top: 6px;
    right: 8px;
    font-size: 0.65rem;
    padding: 3px 7px;
  }
}
