/* ============================================================
   GHTA Academy Tutor — GHTA Academy AI Study Companion
   Brand: teal #0E2A3B | gold #C9A55C | ivory #FAF8F4
   Z-index: 900 (below nav 1000)
   ============================================================ */

/* --- Floating Toggle Button --- */
.studybot-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0E2A3B;
  border: 2px solid #C9A55C;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  box-shadow: 0 4px 20px rgba(14, 42, 59, 0.35), 0 2px 8px rgba(201, 165, 92, 0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  outline: none;
}

.studybot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(14, 42, 59, 0.45), 0 3px 12px rgba(201, 165, 92, 0.35);
}

.studybot-toggle:focus-visible {
  outline: 2px solid #C9A55C;
  outline-offset: 3px;
}

.studybot-toggle svg {
  width: 28px;
  height: 28px;
  transition: opacity 0.2s, transform 0.2s;
}

/* Logo image in toggle button */
.studybot-toggle .icon-open img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 50%;
  transition: opacity 0.2s, transform 0.2s;
}

.studybot-toggle .icon-open {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.studybot-toggle .icon-close {
  position: absolute;
  opacity: 0;
  transform: scale(0.6) rotate(-90deg);
}

.studybot-toggle.is-open .icon-open {
  opacity: 0;
  transform: scale(0.6) rotate(90deg);
}

.studybot-toggle.is-open .icon-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* --- Chat Panel --- */
.studybot-panel {
  position: fixed;
  bottom: 6.5rem;
  right: 2rem;
  width: 320px;
  height: 420px;
  background: #FAF8F4;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(14, 42, 59, 0.22), 0 2px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  z-index: 899;
  overflow: hidden;
  transform: translateY(24px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  border: 1px solid rgba(201, 165, 92, 0.2);
}

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

/* --- Panel Header --- */
.studybot-header {
  background: linear-gradient(135deg, #0E2A3B 0%, #1a3f57 100%);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  border-bottom: 2px solid #C9A55C;
  min-width: 0;
}

.studybot-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid rgba(201, 165, 92, 0.4);
}

.studybot-avatar svg {
  width: 22px;
  height: 22px;
}

.studybot-header-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.studybot-header-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #FAF8F4;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studybot-header-tagline {
  font-size: 0.65rem;
  color: rgba(201, 165, 92, 0.85);
  font-style: italic;
  line-height: 1.3;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studybot-header-track {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #C9A55C;
  background: rgba(201, 165, 92, 0.12);
  border: 1px solid rgba(201, 165, 92, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Messages Area --- */
.studybot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
}

.studybot-messages::-webkit-scrollbar {
  width: 4px;
}

.studybot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.studybot-messages::-webkit-scrollbar-thumb {
  background: rgba(14, 42, 59, 0.15);
  border-radius: 2px;
}

/* Message bubbles */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  animation: msgIn 0.25s ease;
}

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

.msg.bot {
  flex-direction: row;
}

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

.msg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #C9A55C;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.msg-bubble {
  max-width: 82%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  word-break: break-word;
}

.msg.bot .msg-bubble {
  background: #fff;
  color: #1a2e3b;
  border: 1px solid rgba(14, 42, 59, 0.1);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, #C9A55C, #d4b06a);
  color: #0E2A3B;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.55rem 0.75rem;
  background: #fff;
  border: 1px solid rgba(14, 42, 59, 0.1);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  max-width: 60px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #C9A55C;
  animation: typingDot 1.2s ease-in-out infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* Quick-reply chips */
.studybot-chips {
  padding: 0 0.85rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.chip {
  font-size: 0.68rem;
  font-weight: 600;
  color: #0E2A3B;
  background: rgba(201, 165, 92, 0.12);
  border: 1px solid rgba(201, 165, 92, 0.5);
  border-radius: 20px;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.chip:hover {
  background: rgba(201, 165, 92, 0.28);
  border-color: #C9A55C;
}

/* --- Input Bar --- */
.studybot-input-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border-top: 1px solid rgba(14, 42, 59, 0.1);
  flex-shrink: 0;
}

.studybot-input {
  flex: 1;
  border: 1px solid rgba(14, 42, 59, 0.15);
  border-radius: 20px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  color: #1a2e3b;
  background: #FAF8F4;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  resize: none;
  height: 36px;
  line-height: 1.4;
}

.studybot-input:focus {
  border-color: #C9A55C;
  box-shadow: 0 0 0 2px rgba(201, 165, 92, 0.15);
}

.studybot-input::placeholder {
  color: rgba(26, 46, 59, 0.4);
}

.studybot-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0E2A3B;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  outline: none;
}

.studybot-send:hover {
  background: #1a3f57;
  transform: scale(1.08);
}

.studybot-send:active {
  transform: scale(0.95);
}

.studybot-send svg {
  width: 16px;
  height: 16px;
  color: #FAF8F4;
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
  .studybot-panel {
    width: calc(100vw - 2rem);
    right: 1rem;
    bottom: 5.5rem;
    height: 380px;
  }

  .studybot-toggle {
    bottom: 1.25rem;
    right: 1rem;
  }
}

/* ============================================================
   Accessibility: reduce motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .studybot-toggle,
  .studybot-panel,
  .msg,
  .typing-bubble span {
    transition: none;
    animation: none;
  }
}
