:root {

  --navy: #1e3a5f;
  --navy-mid: #2d5282;
  --navy-light: #4a7fb5;
  --bubble-user: #2d5282;
  --gold:       #c8982a;
  --gold-light: #f0c75e;
  --bg:         #f0f3fa;
  --surface:    #ffffff;
  --border:     #dde3f0;
  --text:       #0f2044;
  --text-muted: #5a6a8a;
  --text-light: #8a9abf;
  --bubble-bot: #ffffff;
  --radius:     16px;
  --radius-sm:  8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sora', sans-serif;
  background:
    linear-gradient(
      180deg,
      #1a2f4a 0%,
      #1e4060 35%,
      #2a5f7a 70%,
      #1e3a5f 100%
    );
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── HEADER ─── */
header {
  background: linear-gradient(
  180deg,
    #1a2f4a,
    #1e3a5f
);;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bot-avatar {
  width: 36px; height: 36px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.bot-info h1 {
  font-size: 14px;
  font-weight: 600;
  color: white;
  line-height: 1.2;
}

.bot-info p {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 5px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.school-tag {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.03em;
}

.btn-clear {
  padding: 6px 12px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-clear:hover { background: rgba(255,255,255,0.15); color: white; }

/* ─── SUGERENCIAS ─── */
.suggestions-bar {
  background: linear-gradient(
  180deg,
  #1e3a5f 0%,
  #1e4a5a 100%
);
  padding: 10px 1.5rem;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.suggestions-bar::-webkit-scrollbar { display: none; }

.suggestion-chip {
  padding: 6px 14px;
  background: rgba(250, 204, 21, .14);
  border: 1px solid rgba(250,204,21,.25);
  color: #fde68a;
  border-radius: 20px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}

.suggestion-chip:hover {
  background: #facc15;
  color: #07171d;
}

/* ─── CHAT ─── */
.chat-area {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-area::before{
  content: "";
  position: fixed;

  top: 50%;
  left: 50%;

  width: 700px;
  height: 700px;

  transform: translate(-50%, -50%);

  background:
    radial-gradient(
      circle,
      rgba(168,85,247,.10),
      transparent 70%
    );

  pointer-events: none;
  z-index: -1;
}


/* ─── MENSAJES ─── */
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {

  from {
    opacity: 0;
    transform:
      translateY(14px)
      scale(.98);
  }

  to {
    opacity: 1;
    transform:
      translateY(0)
      scale(1);
  }
}

.msg-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

@keyframes glowPulse {

  0%, 100%{
    opacity: .7;
    transform: scale(1);
  }

  50%{
    opacity: 1;
    transform: scale(1.12);
  }
}

.msg-avatar.pensando::after{
  content: "";

  position: absolute;
  inset: -20px;

  border-radius: 50%;

  border: 2px solid rgba(168,85,247,.25);

  animation: ringPulse 2.5s linear infinite;
}

@keyframes ringPulse{

  from{
    transform: scale(.8);
    opacity: 1;
  }

  to{
    transform: scale(1.4);
    opacity: 0;
  }
}


/* Glow SOLO mientras piensa */
.msg-avatar.pensando::before{
  content: "";

  position: absolute;
  inset: -12px;

  border-radius: 50%;

  background:
    radial-gradient(
      circle,
      rgba(168,85,247,.55) 0%,
      rgba(168,85,247,.25) 40%,
      transparent 75%
    );

  filter: blur(18px);

  z-index: -1;

  animation: glowPulse 2s ease-in-out infinite;
}


.msg.user .msg-avatar { 
  background: var(--navy-light); 
  color: white; 
  font-size: 12px; 
  font-weight: 600; 
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}

.msg.bot{
  padding-left: 2em;
}

.msg.user{
  padding: 1.5em 0;
}

.msg.bot .msg-bubble {
  background: var(--bubble-bot);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15,32,68,0.06);
}

.msg.user .msg-bubble {
  background:
    linear-gradient(
      135deg,
      #7faee0,
      #b7d8f5
    );

  box-shadow:
    0 4px 14px rgba(0,0,0,0.70),
    0 0 0 2px rgba(0,0,0,0.4);

  border-bottom-left-radius: 4px;
  color: #12304d;
}

.msg-time {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 4px;
  padding: 0 4px;
}

.msg-wrap { display: flex; flex-direction: column; }

/* ─── TYPING ─── */
.typing-indicator {
  display: flex;
  padding-left: 2em;
  align-items: flex-end;
  animation: fadeUp 0.2s ease;
}

.typing-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(15,32,68,0.06);
}

.typing-dot {
  width: 7px; height: 7px;
  background: var(--text-light);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ─── WELCOME ─── */
.welcome-card {
  background: rgba(255,255,255,.92);

  backdrop-filter: blur(10px);

  box-shadow:
    0 10px 35px rgba(0,0,0,.18);

  border:
    1px solid rgba(255,255,255,.25);

  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  max-width: 420px;
  margin: auto;
  animation: fadeUp 0.3s ease;
}

.welcome-icon {
  width: 56px; height: 56px;
  background: rgba(200,152,42,0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 1rem;
}

.welcome-card h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
}

.welcome-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.welcome-chip {
  padding: 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.welcome-chip:hover {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

/* ─── INPUT ─── */
.input-area {
  background: linear-gradient(
  180deg,
  rgba(30,64,96,.75),
  rgba(26,47,74,.95)
);

backdrop-filter: blur(10px);
padding: 1rem 1.5rem 3rem 1.5rem;
flex-shrink: 0;
}

.input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 800px;
  margin: 0 auto;
}

.input-box {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s;
  overflow-y: auto;
}

.input-box:focus { border-color: var(--navy); background: white; }
.input-box::placeholder { color: gray; }

.btn-send {
  width: 42px; height: 42px;
  background: linear-gradient(
      135deg,
      #2d5282,
      #4a7fb5
    );
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  line-height: 1;
  font-size: 18px;
}

.btn-send:hover { background: #2d5282; transform: scale(1.2); }
.btn-send:active { transform: scale(0.97); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.input-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 8px;
}

/* ─── ERROR BADGE ─── */
.error-badge {
  background: #faeaea;
  color: #b53030;
  border: 1px solid #e0aaaa;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  max-width: 100%;
  line-height: 1.5;
}

/* ─── NO ANSWER ─── */
.no-answer {
  font-style: italic;
  color: var(--text-muted) !important;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 600px) {
  /* Header */
  header {
    padding: 0 1rem;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .school-tag { display: none; }

  .bot-info h1 { font-size: 12px; }
  .bot-info p  { font-size: 10px; }

  .header-right { gap: 6px; }

  .btn-clear,
  .header-right a {
    font-size: 11px;
    padding: 5px 8px;
  }

  /* Sugerencias */
  .suggestions-bar { padding: 8px 1rem; }

  /* Welcome card */
  .welcome-card {
    max-width: 100%;
    padding: 1.25rem 1rem;
  }

  .welcome-card h2 { font-size: 14px; }

  /* Input */
  .input-area { 
    padding: 0.75rem 1rem; 
  }
  .input-box  { font-size: 13px; }
  .input-footer { font-size: 10px; }
}

/* ─── AVATAR ESTADOS ─── */
.msg-avatar.pensando {
  animation: rotar 1s linear infinite;

}

@keyframes rotar {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.msg-avatar img.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.bot-avatar img.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ───────────────────────────── */
/* AVATAR + GLOW ESTADOS BOT    */
/* ───────────────────────────── */

.msg-avatar{
  position: relative;
  z-index: 1;
  overflow: visible;

  transition:
    transform .3s ease,
    filter .3s ease;

}

/* Imagen avatar */
.msg-avatar img.avatar-img{
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;

  position: relative;
  z-index: 2;

  transition:
    filter .3s ease,
    transform .3s ease;

}

.msg-avatar::before{
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    background: rgba(168, 85, 247, .25);
    filter: blur(15px);
    border-radius: 50%;
    z-index: -1;

}

/* ───────────────────────────── */
/* ESTADO PENSANDO              */
/* ───────────────────────────── */

.msg-avatar.pensando{
  animation:
    floatBot 3s ease-in-out infinite;
}

/* Glow principal */
.msg-avatar.pensando::before{
  content: "";

  position: absolute;
  inset: -12px;

  border-radius: 50%;

  background:
    radial-gradient(
      circle,
      rgba(168,85,247,.55) 0%,
      rgba(168,85,247,.25) 45%,
      transparent 75%
    );

  filter: blur(18px);

  opacity: .9;

  z-index: 0;

  mix-blend-mode: screen;

  animation:
    glowPulse 2s ease-in-out infinite;

  transition:
    opacity .3s ease,
    transform .3s ease;
}

/* Ring expansivo */
.msg-avatar.pensando::after{
  content: "";

  position: absolute;
  inset: -20px;

  border-radius: 50%;

  border: 2px solid rgba(168,85,247,.25);

  filter: blur(1px);

  z-index: 1;

  animation:
    ringPulse 2.5s linear infinite;

  transition:
    opacity .3s ease,
    transform .3s ease;
}

/* Avatar iluminado */
.msg-avatar.pensando img.avatar-img{
  filter:
    brightness(1.05)
    saturate(1.1);
}

/* ───────────────────────────── */
/* ESTADO HABLANDO              */
/* ───────────────────────────── */

.msg-avatar.hablando::before{
  content: "";

  position: absolute;

  border-radius: 50%;

  background:
    radial-gradient(
      circle,
      rgba(168,85,247,.55) 0%,
      rgba(168,85,247,.25) 45%,
      transparent 75%
    );

  filter: blur(16px);

  opacity: 1;

  z-index: 0;
}

.msg-avatar.hablando img.avatar-img{
  filter:
    brightness(1.08)
    saturate(1.15);
}

/* ───────────────────────────── */
/* ANIMACIONES                  */
/* ───────────────────────────── */

@keyframes glowPulse{

  0%,100%{
    transform: scale(1);
    opacity: .7;
  }

  50%{
    transform: scale(1.12);
    opacity: 1;
  }
}

@keyframes talkGlow{

  0%,100%{
    transform: scale(1);
    opacity: .8;
  }

  50%{
    transform: scale(1.06);
    opacity: 1;
  }
}

@keyframes ringPulse{

  from{
    transform: scale(.8);
    opacity: 1;
  }

  to{
    transform: scale(1.4);
    opacity: 0;
  }
}

@keyframes floatBot{

  0%,100%{
    transform: translateY(0px);
  }

  50%{
    transform: translateY(-4px);
  }
}

.admin-link {
    padding: 6px 12px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    font-size: 12px;
    text-decoration: none;
    transition: all 0.15s;
}

.admin-link:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}