/* ── Tutor Chat Panel — ElectroRIC ─────────────────────────────────────── */

.tch-panel {
  position: fixed;
  bottom: 28px;
  right: 120px;
  width: 360px;
  height: 520px;
  display: flex;
  flex-direction: column;
  background: #0E0E1A;
  border: 1px solid rgba(245,197,24,0.18);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(245,197,24,0.06),
    0 24px 64px rgba(0,0,0,0.75),
    0 0 80px rgba(245,197,24,0.04);
  z-index: 9998;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.tch-panel.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* Gold accent bar at top */
.tch-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 12px; right: 12px; height: 2px;
  background: linear-gradient(90deg, transparent, #F5C518 30%, #E8832A 70%, transparent);
  border-radius: 2px;
  z-index: 1;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.tch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.015);
  flex-shrink: 0;
}

.tch-hd-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tch-bolt { font-size: 1.1rem; line-height: 1; }

.tch-hd-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #F5C518;
  line-height: 1;
  display: block;
}

.tch-hd-sub {
  font-size: 0.62rem;
  color: #555770;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 500;
  display: block;
  margin-top: 3px;
}

.tch-hd-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tch-online {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.62rem;
  color: #4CAF82;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 600;
}

.tch-online-dot {
  width: 6px; height: 6px;
  background: #4CAF82;
  border-radius: 50%;
  animation: tch-pulse 2s ease-in-out infinite;
}

@keyframes tch-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.45; transform: scale(0.8); }
}

.tch-close-btn {
  background: none;
  border: none;
  color: #44445A;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 7px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.tch-close-btn:hover { color: #F5C518; background: rgba(245,197,24,0.08); }

/* ── Messages ──────────────────────────────────────────────────────────── */
.tch-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.tch-messages::-webkit-scrollbar { width: 3px; }
.tch-messages::-webkit-scrollbar-track { background: transparent; }
.tch-messages::-webkit-scrollbar-thumb {
  background: rgba(245,197,24,0.18);
  border-radius: 2px;
}

.tch-msg {
  display: flex;
  flex-direction: column;
  animation: tch-msg-in 0.18s ease both;
}

@keyframes tch-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tch-msg-user { align-items: flex-end; }
.tch-msg-ai   { align-items: flex-start; }

.tch-bubble {
  max-width: 90%;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 0.83rem;
  line-height: 1.58;
  word-break: break-word;
}

.tch-msg-user .tch-bubble {
  background: rgba(245,197,24,0.09);
  border: 1px solid rgba(245,197,24,0.22);
  color: #D8D8E8;
  border-radius: 10px 10px 2px 10px;
}

.tch-msg-ai .tch-bubble {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  color: #B8B8CC;
  border-radius: 2px 10px 10px 10px;
  position: relative;
  padding-left: 16px;
}

.tch-msg-ai .tch-bubble::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, #F5C518, #E8832A);
  border-radius: 2px;
}

/* Normative reference highlight */
.tch-ref {
  color: #F5C518;
  font-weight: 600;
  font-size: 0.79rem;
  background: rgba(245,197,24,0.09);
  padding: 0 3px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Streaming cursor */
.tch-cursor {
  display: inline-block;
  width: 7px; height: 13px;
  background: #F5C518;
  border-radius: 1px;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: tch-blink 0.8s step-end infinite;
}
@keyframes tch-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Typing indicator */
.tch-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 10px 16px;
  max-width: 90%;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 2px 10px 10px 10px;
  position: relative;
}

.tch-typing::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, #F5C518, #E8832A);
  border-radius: 2px;
}

.tch-typing-dots {
  display: flex;
  gap: 4px;
  padding-left: 4px;
}

.tch-typing-dot {
  width: 5px; height: 5px;
  background: #F5C518;
  border-radius: 50%;
  animation: tch-dot 1.2s ease-in-out infinite;
}
.tch-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.tch-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes tch-dot {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.75); }
  40%           { opacity: 1;   transform: scale(1.1); }
}

/* ── Quota bar ─────────────────────────────────────────────────────────── */
.tch-quota {
  padding: 5px 14px;
  font-size: 0.67rem;
  color: #484860;
  letter-spacing: 0.05em;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.tch-quota:empty { padding: 0; border-top: none; }
.tch-quota.warn  { color: #E8832A; }
.tch-quota.full  { color: #CC4444; }

.tch-quota-bar {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
}

.tch-quota-fill {
  height: 100%;
  background: linear-gradient(90deg, #F5C518, #E8832A);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Gate overlay ──────────────────────────────────────────────────────── */
.tch-gate {
  position: absolute;
  inset: 0;
  background: rgba(10,10,15,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: 28px;
  text-align: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.tch-gate.visible {
  opacity: 1;
  pointer-events: all;
}

.tch-gate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.tch-gate-icon { font-size: 2.4rem; }

.tch-gate-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: #E0E0F0;
  text-transform: uppercase;
}

.tch-gate-desc {
  font-size: 0.8rem;
  color: #5A5A78;
  line-height: 1.55;
  max-width: 230px;
}

.tch-gate-btn {
  background: linear-gradient(135deg, #F5C518, #E8832A);
  color: #0A0A0F;
  border: none;
  border-radius: 6px;
  padding: 9px 24px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.tch-gate-btn:hover { opacity: 0.85; transform: scale(1.04); }

/* ── Compose ───────────────────────────────────────────────────────────── */
.tch-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.tch-textarea {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  color: #D8D8E8;
  font-family: 'Barlow', sans-serif;
  font-size: 0.83rem;
  line-height: 1.5;
  padding: 8px 11px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.tch-textarea::placeholder { color: #33334A; }
.tch-textarea:focus { border-color: rgba(245,197,24,0.3); }

.tch-send-btn {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #F5C518, #E8832A);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
  color: #0A0A0F;
}

.tch-send-btn:hover  { opacity: 0.85; transform: scale(1.06); }
.tch-send-btn:active { transform: scale(0.96); }
.tch-send-btn:disabled { opacity: 0.25; cursor: not-allowed; transform: none; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .tch-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    height: calc(100svh - 80px);
    max-height: 580px;
  }
}

/* ── Botón flotante para módulos ─────────────────────────────────────────── */
.btn-tutor-flotante {
  position: fixed;
  bottom: 180px;
  right: 24px;
  z-index: 999;
  background: #F5C518;
  color: #0A0A0F;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(245,197,24,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-tutor-flotante:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(245,197,24,0.45);
}
