/* ==========================================================================
   LSPGCOER College Assistant Chatbot Stylesheet
   ========================================================================== */

:root {
  --cb-navy: #0e2a47;
  --cb-navy-deep: #071a30;
  --cb-gold: #f3a812;
  --cb-gold-bright: #ffc233;
  --cb-azure: #1d6690;
  --cb-paper: #f8fafc;
  --cb-paper-dim: #edf2f7;
  --cb-line: #e2e8f0;
  --cb-ink: #1e293b;
  --cb-slate: #64748b;
  --cb-white: #ffffff;
  --cb-shadow: 0 12px 36px rgba(7, 26, 48, 0.18), 0 4px 12px rgba(7, 26, 48, 0.08);
  --cb-radius: 14px;
}

/* Adjust back-to-top button so it doesn't overlap the chatbot */
#backToTop {
  bottom: 5.5rem !important;
  right: 1.5rem !important;
  z-index: 9998 !important;
}

/* Floating Launcher Button */
.cb-launcher {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-navy-deep), var(--cb-azure));
  color: var(--cb-white);
  border: 2px solid var(--cb-gold);
  box-shadow: var(--cb-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  user-select: none;
}

.cb-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 40px rgba(7, 26, 48, 0.28);
}

.cb-launcher:active {
  transform: scale(0.96);
}

.cb-launcher-icon {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s ease;
}

.cb-launcher.open .cb-icon-chat {
  display: none;
}

.cb-launcher:not(.open) .cb-icon-close {
  display: none;
}

/* Badge on launcher */
.cb-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--cb-gold);
  color: var(--cb-navy-deep);
  font-size: 11px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cb-white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  animation: cbPulse 2.5s infinite;
}

@keyframes cbPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Chat Panel Container */
.cb-panel {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 560px;
  max-height: calc(100vh - 8rem);
  background: var(--cb-white);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  border: 1px solid var(--cb-line);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

.cb-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.cb-header {
  background: linear-gradient(135deg, var(--cb-navy-deep) 0%, var(--cb-navy) 60%, var(--cb-azure) 100%);
  color: var(--cb-white);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--cb-gold);
  flex-shrink: 0;
}

.cb-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--cb-white);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.cb-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.cb-header-title-box h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--cb-white);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cb-header-title-box p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: #cdd9e5;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.cb-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--cb-white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.cb-close-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: rotate(90deg);
}

/* Messages Area */
.cb-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: #fdfdfd;
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
  width: 5px;
}
.cb-messages::-webkit-scrollbar-track {
  background: transparent;
}
.cb-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

/* Message Rows */
.cb-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: cbSlideIn 0.25s ease-out;
}

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

.cb-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.cb-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.cb-bubble {
  padding: 0.75rem 0.95rem;
  font-size: 0.88rem;
  line-height: 1.45;
  border-radius: 14px;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cb-msg.user .cb-bubble {
  background: var(--cb-navy);
  color: var(--cb-white);
  border-bottom-right-radius: 4px;
}

.cb-msg.assistant .cb-bubble {
  background: var(--cb-paper-dim);
  color: var(--cb-ink);
  border: 1px solid var(--cb-line);
  border-bottom-left-radius: 4px;
}

.cb-time {
  font-size: 0.68rem;
  color: var(--cb-slate);
  margin-top: 0.25rem;
  padding: 0 0.3rem;
}

/* Action Links & Buttons inside Assistant messages */
.cb-action-box {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.cb-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--cb-white);
  color: var(--cb-navy);
  border: 1px solid var(--cb-azure);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.cb-action-btn:hover {
  background: var(--cb-azure);
  color: var(--cb-white);
  transform: translateX(2px);
}

.cb-action-btn.primary {
  background: var(--cb-navy);
  color: var(--cb-white);
  border-color: var(--cb-navy);
}

.cb-action-btn.primary:hover {
  background: var(--cb-azure);
  border-color: var(--cb-azure);
}

/* Quick Action Chips */
.cb-quick-chips {
  padding: 0.55rem 0.9rem;
  background: var(--cb-paper);
  border-top: 1px solid var(--cb-line);
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.cb-quick-chips::-webkit-scrollbar {
  height: 4px;
}
.cb-quick-chips::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

.cb-chip {
  background: var(--cb-white);
  border: 1px solid #cbd5e1;
  color: var(--cb-navy-deep);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
}

.cb-chip:hover {
  background: var(--cb-navy);
  color: var(--cb-gold-bright);
  border-color: var(--cb-navy);
  transform: translateY(-1px);
}

/* Typing Indicator */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.55rem 0.8rem;
  background: var(--cb-paper-dim);
  border: 1px solid var(--cb-line);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
  margin-bottom: 0.2rem;
}

.cb-typing span {
  width: 6px;
  height: 6px;
  background: var(--cb-azure);
  border-radius: 50%;
  animation: cbTypingBounce 1.3s infinite ease-in-out both;
}

.cb-typing span:nth-child(1) { animation-delay: -0.32s; }
.cb-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes cbTypingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.cb-footer {
  padding: 0.75rem 0.9rem;
  background: var(--cb-white);
  border-top: 1px solid var(--cb-line);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cb-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 0.55rem 0.95rem;
  font-size: 0.88rem;
  color: var(--cb-ink);
  outline: none;
  background: var(--cb-paper);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cb-input:focus {
  border-color: var(--cb-azure);
  background: var(--cb-white);
  box-shadow: 0 0 0 3px rgba(29, 102, 144, 0.15);
}

.cb-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cb-navy);
  color: var(--cb-white);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

.cb-send-btn:hover {
  background: var(--cb-azure);
  transform: scale(1.05);
}

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

.cb-send-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-left: 2px;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .cb-launcher {
    bottom: 1rem;
    right: 1rem;
    width: 54px;
    height: 54px;
  }
  #backToTop {
    bottom: 4.8rem !important;
    right: 1rem !important;
    width: 42px !important;
    height: 42px !important;
  }
  .cb-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .cb-header {
    padding: 0.85rem 1rem;
    border-radius: 0;
  }
}
