/* ── Variables ───────────────────────────────────────────── */
:root {
  --navy:      #1B3A6B;
  --blue:      #2D6BB5;
  --sky:       #5B9BD5;
  --light:     #A8CEE8;
  --pale:      #EAF4FB;
  --white:     #FFFFFF;
  --gray:      #F4F7FB;
  --text:      #1a2d45;
  --muted:     #6b87a8;
  --radius:    18px;
  --radius-sm: 10px;
  --shadow:    0 4px 24px rgba(27,58,107,.10);
  --trans:     .25s ease;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray);
  color: var(--text);
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 74px;
  background: var(--white);
  border-bottom: 1px solid rgba(27,58,107,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  box-shadow: 0 2px 12px rgba(27,58,107,.07);
}

.header-logo {
  height: 58px;
  width: auto;
  filter: drop-shadow(0 1px 2px rgba(27,58,107,.12));
}

.lang-toggle {
  position: absolute;
  right: 20px;
  background: var(--pale);
  color: var(--navy);
  border: 1.5px solid var(--light);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .05em;
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
}
.lang-toggle:hover {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar-track {
  position: fixed;
  top: 74px; left: 0; right: 0;
  height: 3px;
  background: var(--pale);
  z-index: 99;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--sky));
  width: 0%;
  transition: width .5s ease;
}

/* ── Chat wrapper ────────────────────────────────────────── */
.chat-wrapper {
  position: fixed;
  top: 77px; bottom: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 0 8px;
}

/* ── Chat window ─────────────────────────────────────────── */
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-thumb { background: var(--light); border-radius: 4px; }

/* ── Bubbles ─────────────────────────────────────────────── */
.bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .95rem;
  line-height: 1.5;
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1) both;
}

.bubble-bot {
  background: var(--white);
  color: var(--text);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: var(--shadow);
}

.bubble-user {
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: var(--white);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  box-shadow: 0 4px 16px rgba(45,107,181,.25);
}

.bubble-avatar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--sky));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
}
.avatar img { width: 18px; height: 18px; }

/* typing indicator */
.bubble-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--light);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

/* ── Input area ──────────────────────────────────────────── */
.input-area {
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* button grid */
.btn-grid-wrap {
  position: relative;
}

/* gradiente que indica que hay más opciones abajo */
.btn-grid-wrap::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--gray));
  pointer-events: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  opacity: 0;
  transition: opacity var(--trans);
}
.btn-grid-wrap.scrollable::after {
  opacity: 1;
}

.btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-height: 148px;   /* aprox. 3 filas de botones */
  overflow-y: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--light) transparent;
}
.btn-grid::-webkit-scrollbar        { width: 4px; }
.btn-grid::-webkit-scrollbar-thumb  { background: var(--light); border-radius: 4px; }

.btn-option {
  background: var(--white);
  color: var(--navy);
  border: 1.5px solid var(--light);
  border-radius: 24px;
  padding: 9px 18px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans);
  box-shadow: 0 2px 8px rgba(27,58,107,.06);
}
.btn-option:hover, .btn-option.selected {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  box-shadow: 0 4px 14px rgba(45,107,181,.3);
  transform: translateY(-1px);
}

/* star rating */
.star-row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.star {
  font-size: 2rem;
  cursor: pointer;
  color: var(--light);
  transition: color var(--trans), transform var(--trans);
  line-height: 1;
}
.star:hover, .star.lit { color: #F5A623; transform: scale(1.15); }

/* emoji NPS */
.nps-row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.nps-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--light);
  background: var(--white);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--navy);
  transition: all var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
}
.nps-btn:hover, .nps-btn.selected {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  transform: scale(1.12);
}

/* text input */
.text-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.text-input-row textarea {
  flex: 1;
  border: 1.5px solid var(--light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .92rem;
  font-family: inherit;
  resize: none;
  outline: none;
  background: var(--white);
  color: var(--text);
  transition: border-color var(--trans);
  min-height: 52px;
  max-height: 100px;
  overflow-y: auto;
}
.text-input-row textarea:focus { border-color: var(--blue); }
.text-input-row textarea::placeholder { color: var(--muted); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--navy));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--trans), box-shadow var(--trans);
  box-shadow: 0 4px 12px rgba(45,107,181,.3);
}
.send-btn:hover { transform: scale(1.07); box-shadow: 0 6px 18px rgba(45,107,181,.4); }
.send-btn svg { width: 20px; height: 20px; fill: white; }

/* inline rating card */
.rating-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px 12px;
  align-self: flex-start;
  box-shadow: var(--shadow);
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1) both;
  max-width: 82%;
}
.rating-card.locked {
  pointer-events: none;
  opacity: .75;
}
.rating-card .star-row {
  justify-content: flex-start;
  gap: 8px;
}
.rating-card .star {
  font-size: 2.1rem;
}
.star-label {
  font-size: .82rem;
  color: var(--blue);
  font-weight: 600;
  margin-top: 6px;
  min-height: 20px;
  letter-spacing: .01em;
}

/* loading state */
.loading-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  padding: 6px 2px;
}
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.loading-text {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 500;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* skip link */
.skip-link {
  text-align: right;
  font-size: .78rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  padding-right: 2px;
}
.skip-link:hover { color: var(--blue); }

.change-specialty {
  text-align: left;
  color: var(--muted);
  font-size: .75rem;
}

/* ── Final card ──────────────────────────────────────────── */
.final-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin: 8px 0;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1) both;
}
.final-card .check-icon {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--blue), var(--sky));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.final-card .check-icon svg { width: 28px; height: 28px; fill: white; }
.final-card h2 { font-size: 1.2rem; color: var(--navy); margin-bottom: 8px; }
.final-card p  { font-size: .9rem; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }

.ig-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #833AB4, #FD1D1D, #F77737);
  color: white;
  text-decoration: none;
  border-radius: 28px;
  padding: 12px 26px;
  font-size: .92rem;
  font-weight: 700;
  transition: transform var(--trans), box-shadow var(--trans);
  box-shadow: 0 4px 18px rgba(253,29,29,.25);
}
.ig-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(253,29,29,.35); }
.ig-btn svg { width: 22px; height: 22px; fill: white; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes popIn {
  from { opacity: 0; transform: scale(.85) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);   }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .bubble { max-width: 90%; font-size: .9rem; }
  .star   { font-size: 1.75rem; }
  .nps-btn { width: 34px; height: 34px; font-size: .78rem; }
}
