/* tutor-ia-bubble.css — Panel de chat TutorIA flotante */

/* ── Burbuja ──────────────────────────────────────────────────────────────── */
.tia-bubble {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9998;
  width: 66px;
  height: 66px;
  background: linear-gradient(-145deg, #0b1b35 0%, #0f2244 50%, #1B396A 100%);
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.10);
  color: white;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 10px 32px rgba(11, 27, 53, 0.60),
    0 3px 8px rgba(0, 0, 0, 0.28),
    0 0 0 0 rgba(27, 57, 106, 0.50);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation:
    tia-bubble-enter 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) both,
    tia-heartbeat 3s ease-in-out 1.5s infinite;
  font-family: 'Open Sans', sans-serif;
}

/* Badge "TutorIA" en el mismo tono oscuro de la burbuja */
.tia-bubble::before {
  content: 'TutorIA';
  position: absolute;
  top: -8px;
  right: -12px;
  background: #0f2244;
  color: rgba(255, 255, 255, 0.88);
  font-size: 8px;
  font-weight: 800;
  font-family: 'Open Sans', sans-serif;
  letter-spacing: 0.6px;
  padding: 3px 7px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(11, 27, 53, 0.55);
  z-index: 1;
}

.tia-bubble:hover {
  transform: scale(1.1) translateY(-3px);
}

.tia-bubble.active {
  background: linear-gradient(-145deg, #1e293b, #334155);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: none;
  transform: none;
}

.tia-bubble.active::before { display: none; }
.tia-bubble.active:hover   { transform: scale(1.05); }

@keyframes tia-bubble-enter {
  from { opacity: 0; transform: scale(0.3) translateY(24px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Latido: el anillo exterior crece y se desvanece */
@keyframes tia-heartbeat {
  0%, 100% {
    box-shadow:
      0 10px 32px rgba(11, 27, 53, 0.60),
      0 3px 8px rgba(0, 0, 0, 0.28),
      0 0 0 0 rgba(27, 57, 106, 0.50);
  }
  50% {
    box-shadow:
      0 10px 32px rgba(11, 27, 53, 0.60),
      0 3px 8px rgba(0, 0, 0, 0.28),
      0 0 0 14px rgba(27, 57, 106, 0);
  }
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
.tia-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 390px;
  height: 100vh;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid rgba(27, 57, 106, 0.10);
  box-shadow: -6px 0 32px rgba(27, 57, 106, 0.10);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Open Sans', sans-serif;
}

.tia-panel.open {
  transform: translateX(0);
}

.tia-panel.tia-no-transition {
  transition: none !important;
}

/* Header */
.tia-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(27, 57, 106, 0.10);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(27, 57, 106, 0.03);
}

.tia-panel-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tia-brand-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1B396A, #24518F);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}

.tia-brand-name {
  font-size: 17px;
  font-weight: 800;
  background: linear-gradient(135deg, #1B396A 0%, #dc3545 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tia-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tia-credits-pill {
  background: rgba(27, 57, 106, 0.08);
  color: #1B396A;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.tia-icon-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.tia-icon-btn:hover { color: #1B396A; background: #f0f4ff; }
.tia-icon-btn:hover i.fa-sign-out,
.tia-icon-btn[id="tiaLogoutBtn"]:hover { color: #dc3545; background: #fef2f2; }

/* Messages */
.tia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.tia-messages::-webkit-scrollbar { width: 4px; }
.tia-messages::-webkit-scrollbar-track { background: transparent; }
.tia-messages::-webkit-scrollbar-thumb { background: #dce4ed; border-radius: 10px; }

.tia-msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.tia-msg.tia-ai {
  flex-direction: column;
  align-items: flex-start;
}

.tia-msg-inner {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.tia-msg.tia-user {
  flex-direction: row-reverse;
}

.tia-msg-avt {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #1B396A;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.tia-bubble-txt {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
}

.tia-msg.tia-ai .tia-bubble-txt {
  background: rgba(241, 244, 249, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(27, 57, 106, 0.08);
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.tia-msg.tia-user .tia-bubble-txt {
  background: linear-gradient(135deg, #1B396A, #122a50);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 6px 18px rgba(27, 57, 106, 0.20);
}

/* Markdown dentro de burbuja */
.tia-bubble-txt p  { margin-bottom: 8px; }
.tia-bubble-txt p:last-child { margin-bottom: 0; }
.tia-bubble-txt ul, .tia-bubble-txt ol { margin-left: 16px; margin-bottom: 8px; }
.tia-bubble-txt code { background: rgba(0,0,0,0.06); padding: 2px 5px; border-radius: 4px; font-size: 12px; font-family: monospace; }
.tia-bubble-txt strong { font-weight: 700; }
.tia-bubble-txt h1, .tia-bubble-txt h2, .tia-bubble-txt h3 { font-size: 14px; font-weight: 700; margin: 10px 0 5px; }
.tia-bubble-txt table { border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.tia-bubble-txt th, .tia-bubble-txt td { padding: 5px 8px; border: 1px solid #e2e8f0; }
.tia-bubble-txt th { background: #f8fafc; font-weight: 700; }

.tia-error { color: #ef4444; font-size: 13px; }

/* Typing dots */
.tia-dots {
  display: flex;
  gap: 4px;
  padding: 3px 0;
}
.tia-dots span {
  width: 6px; height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: tia-blink 1.4s infinite both;
}
.tia-dots span:nth-child(2) { animation-delay: 0.2s; }
.tia-dots span:nth-child(3) { animation-delay: 0.4s; }

/* History loading dots */
.tia-history-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  padding: 8px;
}
.tia-history-dots span {
  width: 6px; height: 6px;
  background: #cbd5e1;
  border-radius: 50%;
  animation: tia-blink 1.4s infinite both;
}
.tia-history-dots span:nth-child(2) { animation-delay: 0.2s; }
.tia-history-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tia-blink {
  0%, 100% { opacity: 0.2; }
  20%       { opacity: 1; }
}

/* Input area */
.tia-input-area {
  padding: 10px 14px 14px;
  border-top: 1px solid #eef2f7;
  flex-shrink: 0;
  flex-direction: column;
  gap: 6px;
}

.tia-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(248, 250, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(27, 57, 106, 0.10);
  border-radius: 14px;
  padding: 8px 10px;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.tia-input-wrap:focus-within { border-color: #1B396A; background: rgba(255, 255, 255, 0.92); }

#tiaInput {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  line-height: 1.45;
  font-family: 'Open Sans', sans-serif;
  color: #1e293b;
}
#tiaInput::placeholder { color: #94a3b8; }
#tiaInput:disabled { color: #94a3b8; }

#tiaSendBtn {
  background: #1B396A;
  color: white;
  border: none;
  border-radius: 9px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
#tiaSendBtn:hover:not(:disabled) { background: #122a50; transform: scale(1.05); }
#tiaSendBtn:disabled { opacity: 0.28; cursor: not-allowed; transform: none; }

.tia-disclaimer {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  margin: 0;
  line-height: 1.3;
}

/* ── Login card ──────────────────────────────────────────────────────────── */
.tia-login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 18px 16px;
  gap: 11px;
  text-align: center;
}

.tia-login-icon {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #1B396A, #24518F);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 30px;
  margin-bottom: 4px;
}

.tia-login-card h3 {
  font-size: 18px;
  font-weight: 800;
  color: #1B396A;
  margin: 0;
}

.tia-login-card > p {
  font-size: 13px;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

.tia-field {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'Open Sans', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  color: #1e293b;
}
.tia-field:focus { border-color: #1B396A; }

.tia-login-btn {
  width: 100%;
  padding: 11px;
  background: #1B396A;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Open Sans', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}
.tia-login-btn:hover:not(:disabled) { background: #122a50; }
.tia-login-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.tia-login-msg {
  font-size: 12px;
  color: #dc3545;
  min-height: 16px;
  margin: 0;
}

.tia-login-hint {
  font-size: 12px;
  color: #94a3b8;
  margin: 0;
}
.tia-login-hint a { color: #1B396A; font-weight: 700; text-decoration: none; }
.tia-login-hint a:hover { text-decoration: underline; }

/* ── Input footer (contador + disclaimer) ────────────────────────────────── */
.tia-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 0 2px;
}

.tia-char-counter {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.2s;
}
.tia-char-counter.warning { color: #f59e0b; }
.tia-char-counter.limit   { color: #dc3545; }

/* ── Stop button ─────────────────────────────────────────────────────────── */
#tiaStopBtn {
  background: white;
  color: #1B396A;
  border: 1.5px solid #1B396A;
  border-radius: 9px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.3s ease;
  font-size: 13px;
}
#tiaStopBtn:hover { background: #f1f5f9; transform: scale(1.05); }

/* ── Suggestion chips ────────────────────────────────────────────────────── */
.tia-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
}
.tia-chips::-webkit-scrollbar { display: none; }

.tia-chip {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(27, 57, 106, 0.10);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  cursor: pointer;
  font-family: 'Open Sans', sans-serif;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.tia-chip:hover {
  background: #f0f4ff;
  border-color: #1B396A;
  color: #1B396A;
  transform: translateY(-1px);
}
.tia-chip i { margin-right: 5px; color: #1B396A; font-size: 11px; }

/* ── Scroll-to-bottom button ─────────────────────────────────────────────── */
.tia-scroll-btn {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(27, 57, 106, 0.10);
  box-shadow: 0 4px 16px rgba(27,57,106,0.14);
  color: #1B396A;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.tia-scroll-btn:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 20px rgba(27,57,106,0.2);
}

.tia-typing-mini {
  display: flex;
  gap: 3px;
}
.tia-typing-mini span {
  width: 4px; height: 4px;
  background: #1B396A;
  border-radius: 50%;
  animation: tia-blink 1.4s infinite both;
}
.tia-typing-mini span:nth-child(2) { animation-delay: 0.2s; }
.tia-typing-mini span:nth-child(3) { animation-delay: 0.4s; }

/* ── Feedback controls ───────────────────────────────────────────────────── */
.tia-feedback {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-left: 39px;
  margin-top: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.tia-msg.tia-ai:hover .tia-feedback { opacity: 1; }

.tia-fb-btn {
  background: #f1f5f9;
  border: none;
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: #64748b;
  font-size: 12px;
  border-radius: 7px;
  transition: all 0.3s ease;
}
.tia-fb-btn:hover { background: #e2e8f0; color: #1B396A; transform: translateY(-1px); }
.tia-fb-btn.active.tia-fb-up   { color: #10b981; background: #ecfdf5; }
.tia-fb-btn.active.tia-fb-down { color: #ef4444; background: #fef2f2; }
.tia-fb-btn:disabled { cursor: default; transform: none !important; opacity: 0.5; }

/* ── Code copy button ────────────────────────────────────────────────────── */
.tia-bubble-txt pre { position: relative; }

.tia-code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 26px;
  height: 26px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 5px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s ease;
  font-size: 12px;
}
.tia-code-copy-btn:hover { background: rgba(255,255,255,0.1); color: white; }

/* ── OA reference buttons ────────────────────────────────────────────────── */
.tia-oa-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tia-oa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f0f4ff;
  border: 1.5px solid rgba(27,57,106,0.2);
  border-radius: 16px;
  color: #1B396A;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Open Sans', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
}
.tia-oa-btn:hover {
  background: #1B396A;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(27,57,106,0.2);
}
.tia-oa-btn i { font-size: 11px; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tia-tabs {
  display: flex;
  gap: 0;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 3px;
  width: 100%;
}

.tia-tab {
  flex: 1;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Open Sans', sans-serif;
  color: #64748b;
  cursor: pointer;
  transition: all 0.3s ease;
}
.tia-tab.active { background: white; color: #1B396A; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.tia-tab-panel { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.tia-hidden    { display: none !important; }

.tia-correo-hint {
  font-size: 11px;
  color: #1B396A;
  font-weight: 600;
  display: none;
  margin: 0;
}

/* ── Móvil ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .tia-bubble {
    bottom: 22px;
    right: 20px;
    width: 58px;
    height: 58px;
    font-size: 22px;
  }

  .tia-bubble::after {
    inset: -5px;
  }

  .tia-panel {
    width: 100%;
    border-left: none;
  }

  .tia-feedback { opacity: 1; }
}
