/* ====== Base ====== */
:root{
  --bg: #0c0f14;
  --card: #10151d;
  --muted: #94a3b8;
  --text: #e6edf7;
  --primary: #10d320;
  --primary-2: #0aa51a;
  --soft: #3b82f6;
  --soft-2: #2563eb;
  --ghost: #1f2937;
  --border: #233043;
  --ring: #3b82f680;
  --shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.02) inset;
  --radius: 18px;
  --field-bg: #0e141d;
  color-scheme: dark;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol";
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 0% 0%, #142133 0%, transparent 60%),
    radial-gradient(900px 400px at 100% 0%, #1a2940 0%, transparent 60%),
    var(--bg);
}

/* ====== Layout ====== */
.container{
  width: min(900px, 92vw);
  margin: 28px auto;
}

h1{
  margin: 0 0 4px;
  font-weight: 800;
  letter-spacing: .3px;
  font-size: clamp(26px, 2.6vw, 36px);
}
.subtitle{ color: var(--muted); margin: 4px 0 0 }

/* Card principal */
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-title{
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

/* ====== Fields / Inputs ====== */
.field{
  display:flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.label{
  font-weight: 600;
  color: #cbd5e1;
}
.hint{
  color: var(--muted);
  font-size: 13px;
}

/* Inputs genéricos */
.input,
.textarea{
  width: 100%;
  padding: 12px 14px;
  background: var(--field-bg) !important;
  border: 1px solid #213047;
  border-radius: 14px;
  color: #fff !important;
  outline: none;
  transition: border .2s, box-shadow .2s, background .2s, height .1s ease-out;
  font-family: inherit;
  font-size: 14px;
}

.input::placeholder,
.textarea::placeholder{
  color: #8da2b8 !important;
}

.input:focus,
.textarea:focus{
  border-color: var(--soft);
  box-shadow: 0 0 0 4px var(--ring);
}

.input.read,
.textarea.read{
  background: #0b1118 !important;
  color: #fff !important;
}

/* Textarea base (entrada) */
.textarea{
  resize: none;           /* el alto lo controla JS + CSS */
  line-height: 1.4;
  min-height: 10rem;
  overflow-y: auto;       /* permite scroll si hace falta */
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Textarea de respuesta: máximo ~20 líneas, luego scroll */
.textarea.read{
  /* 1.4 (line-height) * 20 líneas * 14px ≈ 392px + padding extra */
  max-height: 420px;
  overflow-y: auto;
}

/* Fila output con botón copiar */
.output{
  display:flex;
  gap:10px;
  align-items: stretch;
}

@media (max-width: 700px){
  .output{
    flex-direction: column;
  }

  .output .btn{
    width: 100%;
    text-align: center;
  }
}

/* ====== Botones ====== */
.btn{
  border: 1px solid transparent;
  background: var(--ghost);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .05s ease, background .2s, border .2s, box-shadow .2s;
  user-select: none;
  font-size: 14px;
}
.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
}
.btn.primary:hover{
  box-shadow: 0 0 0 4px rgba(16,211,32,.18);
}
.btn.ghost{
  background: #0e141d;
  border-color: #223149;
}
.btn.ghost.copied{
  outline: 2px solid #22c55e;
}

/* Centrado genérico (no se usa para la fila de acción ya) */
.center{
  display:flex;
  justify-content:center;
  width:100%;
}

/* Fila acción (switch + botón enviar) */
.action-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 1rem;
  margin-top: 1.4rem;
  flex-wrap: wrap;
}

.action-row .btn{
  white-space: nowrap;
}

@media (max-width: 700px){
  .action-row{
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .action-row .btn{
    width: 100%;
    text-align: center;
  }
}

/* Switch de entorno */
.env-toggle{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  font-size: 13px;
}

.env-toggle .env-label{
  font-weight:600;
  opacity:.7;
}
.env-toggle .env-label-test{
  color:#e5e7eb;
}
.env-toggle .env-label-prod{
  color:#f97316;
}

/* Estado visual según entorno */
.env-toggle.is-prod .env-label-prod{
  opacity:1;
}
.env-toggle.is-prod .env-label-test{
  opacity:.4;
}
.env-toggle:not(.is-prod) .env-label-test{
  opacity:1;
}
.env-toggle:not(.is-prod) .env-label-prod{
  opacity:.4;
}

/* Estilos del switch tipo iOS */
.switch{
  position:relative;
  display:inline-flex;
  width:48px;
  height:24px;
}
.switch input{
  opacity:0;
  width:0;
  height:0;
}
.slider{
  position:absolute;
  cursor:pointer;
  inset:0;
  background:#020617;
  border-radius:999px;
  transition:.25s;
  box-shadow:0 0 0 1px #1f2937 inset;
}
.slider::before{
  content:"";
  position:absolute;
  height:18px;
  width:18px;
  left:3px;
  top:3px;
  border-radius:999px;
  background:#e5e7eb;
  transition:.25s;
}

/* Encendido: productivo */
.switch input:checked + .slider{
  background:linear-gradient(90deg, var(--soft), var(--soft-2));
  box-shadow:0 0 0 1px #1d4ed8 inset;
}
.switch input:checked + .slider::before{
  transform:translateX(24px);
}

/* Divider */
.divider{
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #223149, transparent);
  margin: 20px 0;
}

/* ====== Modal ====== */
dialog{
  border: none;
  background: transparent;
  padding: 0;
}
dialog::backdrop{
  background: rgba(15,23,42,.7);
  backdrop-filter: blur(3px);
}

.modal-card{
  width: min(420px, 92vw);
  background: #0f1520;
  border: 1px solid #223149;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  color: #fff;
}
.modal-head{
  padding: 16px 18px;
  border-bottom: 1px solid #1f2a3d;
}
.modal-head h3{ margin:0; color:#fff; }
.modal-body{
  padding: 18px;
  display:flex;
  gap:14px;
  align-items:center;
  color: #fff;
}
.modal-body p{ margin:0; }

/* Spinner */
.spinner{
  width: 22px;
  height: 22px;
  border: 3px solid #2a3c57;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin{ to { transform: rotate(360deg); } }

/* ====== Toasts ====== */
.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  bottom: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  color: #0b1220;
  background: #e2e8f0;
  font-weight: 700;
  opacity: 0;
  transition: .25s;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  z-index: 60;
}
.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.ok{   background: #bbf7d0; }
.toast.warn{ background: #fde68a; }
.toast.err{  background: #fecaca; }
