/* ==========================================================================
   BRAMHI - GATE AI MENTOR & MOTIVATIONAL CHATBOT STYLES
   CS Revolt Theme Integration (Cyan #1fb5f5, Orange #f7931e, Glassmorphism)
   ========================================================================== */

/* Floating Launcher Button - Hidden on sign in page until authenticated */
body.auth-locked .bramhi-launcher,
body.auth-locked .bramhi-chat-window {
  display: none !important;
}

.bramhi-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1fb5f5 0%, #0077ff 60%, #f7931e 120%);
  color: #ffffff;
  padding: 10px 18px 10px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 30px rgba(31, 181, 245, 0.45), 0 4px 15px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: none; /* lets the finger drag the launcher instead of scrolling the page */
  font-family: var(--font-heading, 'Outfit', sans-serif);
}

.bramhi-launcher.dragging {
  transition: none;
  cursor: grabbing;
  transform: scale(1.06);
}

.bramhi-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 35px rgba(31, 181, 245, 0.6), 0 0 25px rgba(247, 147, 30, 0.4);
}

.bramhi-launcher:active {
  transform: translateY(0) scale(0.98);
}

.bramhi-launcher-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  position: relative;
  flex-shrink: 0;
}

.bramhi-pulse-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: bramhiPulse 2s infinite;
}

@keyframes bramhiPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.bramhi-launcher-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.bramhi-launcher-title {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bramhi-launcher-subtitle {
  font-size: 0.72rem;
  opacity: 0.92;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-weight: 500;
}

/* Small ball: used when the launcher is dragged into a screen corner */
.bramhi-launcher.compact {
  padding: 4px;
  gap: 0;
}

.bramhi-launcher.compact .bramhi-launcher-text {
  display: none;
}

.bramhi-launcher.compact .bramhi-launcher-avatar {
  width: 56px;
  height: 56px;
  font-size: 1.9rem;
}

/* Chat Window Modal / Container */
.bramhi-chat-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card, rgba(14, 25, 48, 0.96));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong, rgba(31, 181, 245, 0.3));
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 35px rgba(31, 181, 245, 0.2);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.bramhi-chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.bramhi-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(31, 181, 245, 0.15) 0%, rgba(247, 147, 30, 0.15) 100%), var(--bg-secondary, #0b1428);
  border-bottom: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.15));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.bramhi-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bramhi-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1fb5f5 0%, #f7931e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 0 15px rgba(31, 181, 245, 0.4);
  position: relative;
}

.bramhi-title-area {
  display: flex;
  flex-direction: column;
}

.bramhi-name {
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-primary, #ffffff);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bramhi-tag {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(31, 181, 245, 0.18);
  color: var(--brand-cyan, #1fb5f5);
  border: 1px solid rgba(31, 181, 245, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bramhi-status-text {
  font-size: 0.75rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.bramhi-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

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

.bramhi-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  color: var(--text-secondary, #94a3b8);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.bramhi-icon-btn:hover {
  background: rgba(31, 181, 245, 0.15);
  color: var(--brand-cyan, #1fb5f5);
  border-color: var(--brand-cyan, #1fb5f5);
}

/* Minimized: only the header bar stays, docked where the window was; click it to restore */
.bramhi-chat-window.minimized {
  height: auto;
}
.bramhi-chat-window.minimized > :not(.bramhi-header),
.bramhi-chat-window.minimized #bramhiApiKeyBtn,
.bramhi-chat-window.minimized #bramhiClearBtn {
  display: none;
}
.bramhi-chat-window.minimized .bramhi-header {
  cursor: pointer;
  border-bottom: 0;
}

/* Quick Topic Pills / Filter Bar */
.bramhi-quick-bar {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.1));
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}

.bramhi-quick-bar::-webkit-scrollbar {
  display: none;
}

.bramhi-chip {
  white-space: nowrap;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.15));
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bramhi-chip:hover {
  background: rgba(31, 181, 245, 0.15);
  color: var(--brand-cyan, #1fb5f5);
  border-color: rgba(31, 181, 245, 0.4);
  transform: translateY(-1px);
}

.bramhi-chip.motivate {
  background: rgba(247, 147, 30, 0.15);
  color: #ff9e3d;
  border-color: rgba(247, 147, 30, 0.35);
}

.bramhi-chip.motivate:hover {
  background: rgba(247, 147, 30, 0.25);
  color: #ffb703;
  border-color: rgba(247, 147, 30, 0.6);
}

/* Messages Area */
.bramhi-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.bramhi-messages::-webkit-scrollbar {
  width: 5px;
}

.bramhi-messages::-webkit-scrollbar-thumb {
  background: rgba(31, 181, 245, 0.2);
  border-radius: 10px;
}

/* Individual Message Bubbles */
.bramhi-msg {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: bramhiFadeIn 0.25s ease-out forwards;
}

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

.bramhi-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bramhi-msg.bot {
  align-self: flex-start;
}

.bramhi-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.bramhi-msg.bot .bramhi-msg-avatar {
  background: linear-gradient(135deg, #1fb5f5, #0077ff);
  color: #fff;
  box-shadow: 0 0 10px rgba(31, 181, 245, 0.3);
}

.bramhi-msg.user .bramhi-msg-avatar {
  background: linear-gradient(135deg, #f7931e, #ffb703);
  color: #fff;
}

.bramhi-msg-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.bramhi-msg.user .bramhi-msg-content {
  background: linear-gradient(135deg, #0b72c0 0%, #0077ff 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 119, 255, 0.25);
}

.bramhi-msg.bot .bramhi-msg-content {
  background: var(--bg-secondary, #0b1428);
  color: var(--text-primary, #f8fafc);
  border: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.15));
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

/* Markdown formatting inside Bot Messages */
.bramhi-msg-content strong {
  color: var(--brand-cyan, #1fb5f5);
  font-weight: 600;
}

.bramhi-msg.bot .bramhi-msg-content p {
  margin: 0 0 8px 0;
}

.bramhi-msg.bot .bramhi-msg-content p:last-child {
  margin-bottom: 0;
}

.bramhi-msg-content ul, .bramhi-msg-content ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.bramhi-msg-content li {
  margin-bottom: 4px;
}

.bramhi-code-block {
  background: #040813;
  border: 1px solid rgba(31, 181, 245, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.78rem;
  color: #70e2ff;
  margin: 8px 0;
  overflow-x: auto;
  position: relative;
}

.bramhi-copy-code-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #94a3b8;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.bramhi-copy-code-btn:hover {
  background: var(--brand-cyan, #1fb5f5);
  color: #060b18;
}

.bramhi-punchline-card {
  background: linear-gradient(135deg, rgba(247, 147, 30, 0.15) 0%, rgba(255, 183, 3, 0.08) 100%);
  border: 1px solid rgba(247, 147, 30, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 500;
  color: #ff9e3d;
}

.bramhi-punchline-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Typing Indicator */
.bramhi-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-secondary, #0b1428);
  border: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.15));
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.bramhi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-cyan, #1fb5f5);
  opacity: 0.4;
  animation: bramhiDotBlink 1.4s infinite ease-in-out both;
}

.bramhi-dot:nth-child(1) { animation-delay: -0.32s; }
.bramhi-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bramhiDotBlink {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Input Area */
.bramhi-input-area {
  padding: 12px 14px;
  background: var(--bg-secondary, #0b1428);
  border-top: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.15));
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bramhi-input {
  flex: 1;
  background: var(--bg-input, #0a1224);
  border: 1px solid var(--border-subtle, rgba(31, 181, 245, 0.18));
  border-radius: 9999px;
  padding: 10px 16px;
  font-size: 0.88rem;
  color: var(--text-primary, #f8fafc);
  outline: none;
  font-family: var(--font-body, 'Inter', sans-serif);
  transition: all 0.2s ease;
}

.bramhi-input:focus {
  border-color: var(--brand-cyan, #1fb5f5);
  box-shadow: 0 0 12px rgba(31, 181, 245, 0.25);
}

.bramhi-input::placeholder {
  color: var(--text-muted, #64748b);
  font-size: 0.82rem;
}

.bramhi-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1fb5f5 0%, #0077ff 100%);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(31, 181, 245, 0.3);
}

.bramhi-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(31, 181, 245, 0.5);
}

.bramhi-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Footer info */
.bramhi-footer-note {
  font-size: 0.65rem;
  color: var(--text-muted, #64748b);
  text-align: center;
  padding: 4px 10px 8px;
  background: var(--bg-secondary, #0b1428);
}

/* Settings / API Key Modal */
.bramhi-api-modal {
  position: absolute;
  inset: 0;
  background: rgba(6, 11, 24, 0.95);
  backdrop-filter: blur(10px);
  z-index: 20;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  border-radius: 20px;
}

.bramhi-api-modal.show {
  opacity: 1;
  visibility: visible;
}

/* Light Theme Overrides */
body[data-theme="light"] .bramhi-chat-window {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 153, 194, 0.25);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12), 0 0 25px rgba(31, 181, 245, 0.1);
}

body[data-theme="light"] .bramhi-header {
  background: linear-gradient(135deg, rgba(31, 181, 245, 0.08) 0%, rgba(247, 147, 30, 0.08) 100%), #f8fafc;
}

body[data-theme="light"] .bramhi-name {
  color: #0f172a;
}

body[data-theme="light"] .bramhi-msg.bot .bramhi-msg-content {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #e2e8f0;
}

body[data-theme="light"] .bramhi-input-area {
  background: #ffffff;
  border-top-color: #e2e8f0;
}

body[data-theme="light"] .bramhi-input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

body[data-theme="light"] .bramhi-chip {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

body[data-theme="light"] .bramhi-code-block {
  background: #0f172a;
  color: #38bdf8;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .bramhi-chat-window {
    right: 10px;
    bottom: 68px;
    width: calc(100vw - 20px);
    height: min(460px, calc(100vh - 150px));
    max-height: calc(100vh - 150px);
    border-radius: 14px;
  }

  /* Icon-only round launcher on phones */
  .bramhi-launcher {
    bottom: 14px;
    right: 14px;
    padding: 4px;
    gap: 0;
  }

  .bramhi-launcher-text {
    display: none;
  }

  .bramhi-launcher-avatar {
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }

  .bramhi-header {
    padding: 8px 12px;
  }

  .bramhi-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  .bramhi-name {
    font-size: 0.95rem;
  }

  .bramhi-icon-btn {
    width: 28px;
    height: 28px;
  }

  .bramhi-quick-bar {
    padding: 6px 10px;
  }

  .bramhi-chip {
    font-size: 0.7rem;
    padding: 4px 9px;
  }

  .bramhi-messages {
    padding: 10px;
    gap: 10px;
  }

  .bramhi-msg-content {
    font-size: 0.82rem;
    padding: 8px 11px;
  }

  .bramhi-input-area {
    padding: 8px 10px;
  }

  .bramhi-input {
    padding: 8px 14px;
    font-size: 16px; /* avoids iOS zoom on focus */
  }

  .bramhi-send-btn {
    width: 34px;
    height: 34px;
  }
}
