/* ── VARIABLES ─────────────────────────────────────────────────────────────── */
:root {
  --accent: #00843D;
  --accent-dark: #006b31;
  --gold: #FFD700;
  --text: #1a202c;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg-page: radial-gradient(circle at center, #f8fafc 0%, #cbd5e1 100%);
  --bg-card: #ffffff;
  --radius-card: 16px;
  --radius-input: 8px;
}

/* ── BASE ───────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Montserrat', -apple-system, sans-serif;
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
  background: var(--bg-page);
}

/* ── CARD ───────────────────────────────────────────────────────────────────── */
#portal {
  text-align: center;
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  padding: 30px 25px;
  border-radius: var(--radius-card);
  border-top: 6px solid var(--accent);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
  transition: max-width 0.4s ease;
}

#portal::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 6px;
  background: var(--gold);
  transform: translateY(6px);
}

/* ── LOGO ───────────────────────────────────────────────────────────────────── */
.institutional-header { margin-bottom: 5px; padding-top: 5px; }

#logo {
  display: block;
  max-width: 130px;
  width: 100%;
  height: auto;
  margin: 0 auto 10px;
}

/* ── STEPS ──────────────────────────────────────────────────────────────────── */
section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.4s ease-out;
}

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

h1, h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1.2;
}

p { font-size: 0.85rem; line-height: 1.5; color: #4a5568; margin: 0; }

/* ── MEDIA CONTAINER ────────────────────────────────────────────────────────── */
#media-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  overflow: hidden;
}

/* YouTube / video horizontal — 16:9 */
#media-container.media-h {
  aspect-ratio: 16 / 9;
  position: relative;
  background: #000;
}
#media-container.media-h iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: none;
}

/* YouTube Shorts / Reels verticales — 9:16, max 60vh */
#media-container.media-v {
  aspect-ratio: 9 / 16;
  max-height: 60vh;
  position: relative;
  background: #000;
}
#media-container.media-v iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: none;
}

/* Facebook / Instagram — móvil: proporción 4:5 */
#media-container.media-social {
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

/* Laptop+: altura fija, contenido centrado verticalmente */
@media (min-width: 1024px) {
  #media-container.media-social {
    aspect-ratio: unset;
    height: 520px;
    overflow: hidden;
    justify-content: center;
  }
}
#media-container.media-social iframe,
#media-container.media-social .fb-post,
#media-container.media-social .instagram-media {
  width: 100% !important;
  max-width: 100%;
  border: none;
}

/* Image */
#media-container.media-image {
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
}
#media-container.media-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

/* Custom embed — flexible height */
#media-container.media-custom {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 8px;
  min-height: 60px;
}
#media-container.media-custom iframe {
  width: 100%;
  border: none;
  display: block;
}

/* ── TIMER ──────────────────────────────────────────────────────────────────── */
.timer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  transition: color 0.3s;
}
.timer-text.timer-ready { color: var(--accent); font-weight: 700; }

/* ── TERMS ──────────────────────────────────────────────────────────────────── */
.terms-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 15px;
  height: 100px;
  overflow-y: auto;
  text-align: left;
  font-size: 0.75rem;
  color: #64748b;
}

.checkbox-container {
  display: flex;
  align-items: flex-start;
  text-align: left;
  gap: 10px;
  font-size: 0.75rem;
  cursor: pointer;
}
.checkbox-container input {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  margin-top: 2px;
}

/* ── FORM ───────────────────────────────────────────────────────────────────── */
#loginForm {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 15px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}
.input-group label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.date-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr 1fr;
  gap: 10px;
}

input, select {
  width: 100%;
  padding: 12px;
  height: 45px;
  border-radius: var(--radius-input);
  border: 2px solid var(--border);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  box-sizing: border-box;
  color: var(--text);
}
input:focus, select:focus {
  border-color: var(--accent);
  outline: none;
}

.iti { width: 100%; }

/* ── STEP WELCOME BACK ──────────────────────────────────────────────────────── */
#step-welcome-back {
  align-items: center;
  width: 100%;
}
#step-welcome-back h2 {
  color: var(--accent);
  font-size: 1.1rem;
  margin: 8px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.welcome-back-card {
  background: #f0faf4;
  border: 1px solid #c6e9d4;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
}
.welcome-back-avatar {
  font-size: 2.5rem;
  margin-bottom: 8px;
}
.wb-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 2px;
}
.wb-visits {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}
.wb-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.btn-wb-connect {
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.5px;
  transition: background 0.2s;
}
.btn-wb-connect:hover { background: var(--accent-dark); }
.btn-wb-update {
  padding: 13px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.5px;
  transition: background 0.2s, color 0.2s;
}
.btn-wb-update:hover { background: var(--accent); color: #fff; }

/* ── STEP NAV ───────────────────────────────────────────────────────────────── */
.status-card {
  background: #f0fff4;
  padding: 25px 15px;
  border-radius: 12px;
  border: 1px solid #c6f6d5;
}
#timerContainer {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

/* ── BUTTONS ────────────────────────────────────────────────────────────────── */
button {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-input);
  border: none;
  background: var(--accent);
  color: white;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
button:hover:not(:disabled) { background: var(--accent-dark); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { background: #cbd5e1; cursor: not-allowed; }

#submitBtn {
  width: 100%;
  max-width: 100%;
  margin: 10px auto 0;
  display: block;
  height: auto;
}

/* ── STATUS MSG ─────────────────────────────────────────────────────────────── */
.status-msg { font-size: 0.8rem; font-weight: 600; color: #e53e3e; margin-top: 6px; }

/* ── SPINNER ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ENCUESTA POSTLOGIN ─────────────────────────────────────────────────────── */
#survey-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.survey-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  text-align: center;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.star {
  font-size: 2rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  user-select: none;
  line-height: 1;
}

.star.active,
.star.hover { color: #f59e0b; }
.star:active { transform: scale(1.2); }

.survey-comment {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.82rem;
  resize: none;
  box-sizing: border-box;
  color: var(--text);
}
.survey-comment:focus { border-color: var(--accent); outline: none; }

/* ── POSTLOGIN MEDIA ────────────────────────────────────────────────────────── */
#postlogin-media-container {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
}
#postlogin-media-container img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
}

/* ── LAPTOP 1024px+ ─────────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  #portal {
    max-width: 600px;
    padding: 45px;
  }
  #logo { max-width: 160px; margin-bottom: 15px; }
  h1, h2 { font-size: 1.5rem; }
  p { font-size: 1rem; }
  #loginForm { gap: 28px; }
  .date-grid { gap: 15px; }
  .terms-box { height: 150px; font-size: 0.85rem; }
}
