:root {
  --sb-waveform-bar-count: 32;
  --sb-waveform-bar-thickness: 4;
}

.sbChat_container {
  max-width: 30vw;
  margin: 20px auto;
  height: 80vh;
  background-color: var(--chat-bg-secondary);
  border-radius: 12px;
  box-shadow: 0 8px 32px var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sbChat_header {
  padding: 16px 20px;
  background-color: var(--chat-accent);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sbChat_title {
  font-weight: 600;
  font-size: 18px;
}

.sbChat_dateTime {
  font-size: 10px;
  opacity: 0.5;
}

.sbChat_theme-selector {
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.sbChat_pinned-attachment {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--chat-bg-secondary);
  border-bottom: 1px solid var(--chat-border);
  padding: 12px;
  display: none;
  box-shadow: 0 2px 8px var(--chat-shadow);
}

.sbChat_pinned-attachment.visible {
  display: block;
}

.sbChat_messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--chat-bg-image-filter);
  position: relative;
  z-index: 0;
}

.sbChat_message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 80%;
  animation: sbChat_slideIn 0.3s ease-out;
}

.sbChat_parallax-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* height will be set by JavaScript */
  z-index: -1;
  background-image: var(--chat-bg-image-img);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center top;
  transition: background-position 0.1s;
}

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

.sbChat_message.other {
  align-self: flex-start;
}

.sbChat_avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.sbChat_bubble {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 100%;
  word-wrap: break-word;
  position: relative;
}

.sbChat_message.user .sbChat_bubble {
  background-color: var(--chat-user-bubble);
  color: var(--chat-user-text);
  border-bottom-right-radius: 0px;
}

.sbChat_message.other .sbChat_bubble {
  background-color: var(--chat-other-bubble);
  color: var(--chat-other-text);
  border-bottom-left-radius: 0px;
}

.sbChat_attachment {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.sbChat_attachment:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.sbChat_attachment-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* Image thumbnail for attachments */
.sbChat_image-thumb {
  max-height: 150px;
  height: auto;
  max-width: 200px;
  border-radius: 6px;
  margin-right: 8px;
  margin-bottom: 4px;
  display: block;
}

.sbChat_timestamp {
  font-size: 11px;
  color: var(--chat-text-secondary);
  margin-top: 4px;
  opacity: 0.7;
}

.sbChat_input-container {
    padding: 12px;
    /* Reduced padding for a tighter look */
    border-top: 1px solid var(--chat-border);
    background-color: var(--chat-bg-secondary);
    display: flex;
    /* Key for layout */
    align-items: flex-end;
    /* Aligns items if textarea grows */
    gap: 6px;
    /* Slightly increased space between input wrapper and send button for better visual separation */
}

.sbChat_input-wrapper {
    display: flex;
    align-items: center;
    /* Vertically align mic, textarea, icons */
    gap: 4px;
    /* Reduced space between elements inside wrapper */
    background-color: var(--chat-bg-primary);
    border-radius: 24px;
    /* Rounded corners for the wrapper */
    padding: 6px 12px;
    /* Padding inside the wrapper */
    border: 1px solid var(--chat-border);
    flex: 1;
    /* Makes the wrapper take available width */
}

.sbChat_input-icons-left,
.sbChat_input-icons-right {
  display: flex;
  align-items: center;
}

.sbChat_input-icons-left {
    gap: 4px;
    /* Reduced space between icons on left to match right side */
}

.sbChat_input-icons-right {
  gap: 4px;
  /* Space between icons on the right */
}

.sbChat_attachment-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-accent);
  transition: all 0.2s;
  font-size: 18px;
  /* Icon size */
}

.sbChat_attachment-btn i,
.sbChat_send-btn i {
  line-height: 1;
  /* Better FA icon alignment */
}

.sbChat_attachment-btn:hover {
  background-color: var(--chat-hover);
  transform: scale(1.1);
}

.sbChat_attachment-btn.recording {
  position: relative;
}
.sbChat_attachment-btn.recording::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #e53935;
  border-radius: 50%;
  box-shadow: 0 0 8px #e53935;
  animation: sbChat_blink 1s infinite;
  z-index: 2;
}
@keyframes sbChat_blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

.sbChat_attachment-btn.recording .fa-microphone {
  visibility: hidden;
}

/* Mute button styling */
.sbChat_attachment-btn.muted {
    background-color: rgba(255, 71, 87, 0.1);
    border: 1px solid #ff4757;
}

.sbChat_attachment-btn.muted .fa-volume-mute {
    color: #ff4757;
}

.sbChat_input {
  flex: 1;
  /* Textarea takes up available space */
  border: none;
  outline: none;
  background: transparent;
  color: var(--chat-text-primary);
  font-size: 16px;
  resize: none;
  min-height: 24px;
  /* Adjusted for better alignment with 32px buttons */
  max-height: 100px;
  line-height: 20px;
  /* Adjust as needed */
  padding: 4px 0;
  /* Minimal vertical padding */
}

.sbChat_send-btn {
  width: 32px;
  height: 32px;
  border: none;
  background-color: var(--chat-accent);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 16px;
  /* Icon size for send */
  flex-shrink: 0;
  /* Prevent button from shrinking */
  align-self: center;
}

.sbChat_send-btn:hover {
  transform: scale(1.1);
}

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

@keyframes sbChat_slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .sbChat_container {
    margin: 0;
    height: 100vh;
    border-radius: 0;
  }

  .sbChat_message {
    max-width: 85%;
  }

  .sbChat_messages {
    padding: 12px;
  }

  .sbChat_input-container {
    padding: 8px;
    /* Tighter padding on mobile */
  }

  .sbChat_input-wrapper {
    padding: 6px 10px;
    /* Tighter padding on mobile */
  }

  .sbChat_attachment-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .sbChat_send-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .sbChat_input {
    min-height: 20px;
    font-size: 15px;
  }
}

/* Hidden file input */
.sbChat_file-input {
  display: none;
}

.sbChat_editable-input {
  border: 1px solid var(--chat-accent);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 1em;
  font-family: inherit;
  background-color: var(--chat-bg-primary);
  color: var(--chat-text-primary);
}

/* Overrides for when chat is embedded in the sidebar */
.sidebar-content-area .sbChat_container {
  max-width: none;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  border: none;
}

/* Voice message styles */
.sbChat_waveform {
  width: 200px;
  height: 50px;
  background-color: var(--chat-bg-primary);
  border-radius: 8px;
  margin: 4px 0;
  border: none !important;
  background: transparent !important;
}

.sbChat_message.voice {
  opacity: 1;
}

.sbChat_message.voice .sbChat_bubble {
  min-width: 220px;
  padding: 8px 12px;
}

.sbChat_message.voice .sbChat_waveform {
  display: block;
  margin: 8px 0;
}

/* ========== MathJax Styling ========== */

/* Style for MathJax containers in chat bubbles */
.sbChat_bubble .MathJax {
  display: inline-block !important;
  margin: 0.2em 0 !important;
}

/* Style for display math (block equations) */
.sbChat_bubble .MathJax_Display {
  text-align: center !important;
  margin: 0.5em 0 !important;
  padding: 0.3em 0 !important;
}

/* Style for inline math */
.sbChat_bubble .MathJax_SVG {
  vertical-align: middle !important;
}

/* Ensure math expressions inherit text color from bubble */
.sbChat_bubble .MathJax .MJX-TEX {
  color: inherit !important;
}

.sbChat_bubble .MathJax svg {
  color: inherit !important;
}

/* Better spacing for mathematical expressions */
.sbChat_bubble mjx-container {
  margin: 0.1em 0.2em !important;
  line-height: 1.2 !important;
}

/* Display math gets more spacing */
.sbChat_bubble mjx-container[display="true"] {
  margin: 0.5em 0 !important;
  text-align: center !important;
}

/* Ensure math expressions are readable in both light and dark themes */
.sbChat_message.user .sbChat_bubble mjx-container {
  color: var(--chat-user-text) !important;
}

.sbChat_message.other .sbChat_bubble mjx-container {
    color: var(--chat-other-text) !important;
    border: 2px solid #3b82f6 !important; /* Blue border highlight for LaTeX equations */
    border-radius: 8px !important;
    padding: 8px 12px !important;
    margin: 8px 0 !important;
    background-color: rgba(59, 130, 246, 0.05) !important; /* Very subtle blue background */
    display: inline-block !important;
}

/* Responsive math for smaller screens */
@media (max-width: 768px) {
  .sbChat_bubble mjx-container {
    font-size: 0.9em !important;
    max-width: 100% !important;
    overflow-x: auto !important;
  }
}

/* Status message styling - small gray centered text without bubbles */
.sbChat_status-message {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0;
}

.sbChat_status-text {
    font-size: 11px;
    color: var(--chat-text-secondary);
    opacity: 0.6;
    text-align: center;
    font-style: italic;
    max-width: 80%;
}

/* Animation for status messages */
.sbChat_status-message {
    animation: sbChat_statusFadeIn 0.3s ease-out;
}

@keyframes sbChat_statusFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Status message styling - small gray centered text without bubbles */
.sbChat_status-message {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0;
}

.sbChat_status-text {
    font-size: 11px;
    color: var(--chat-text-secondary);
    opacity: 0.6;
    text-align: center;
    font-style: italic;
    max-width: 80%;
}

/* Animation for status messages */
.sbChat_status-message {
    animation: sbChat_statusFadeIn 0.3s ease-out;
}

@keyframes sbChat_statusFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ========== Video Recording Styles ========== */

/* Video recording modal overlay */
#sbChat_videoModal {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Video recording modal container */
#sbChat_videoModalContainer {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

/* Video recording controls */
.sbChat_video-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* Video recording button states */
#sbChat_startRecordBtn {
  transition: all 0.2s ease;
}

#sbChat_startRecordBtn:hover {
  background: #218838 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

#sbChat_stopRecordBtn:hover {
  background: #c82333 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

/* Video thumbnail styles */
.sbChat_video-thumb {
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.sbChat_video-thumb:hover {
  transform: scale(1.02);
}

.sbChat_video-thumb video {
  border: 2px solid var(--chat-border);
  transition: border-color 0.2s ease;
}

.sbChat_video-thumb:hover video {
  border-color: var(--chat-accent);
}

/* Recording timer animation */
#sbChat_recordingTimer {
  animation: sbChat_pulse 1s infinite;
}

@keyframes sbChat_pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Video modal responsive design */
@media (max-width: 768px) {
  #sbChat_videoModalContainer {
    min-width: 90vw !important;
    min-height: 80vh !important;
    padding: 16px !important;
  }

  #sbChat_videoRecordingVideo {
    min-height: 180px !important;
  }

  .sbChat_video-controls {
    flex-direction: column;
    gap: 8px;
  }

  .sbChat_video-controls button {
    width: 100%;
    max-width: 200px;
  }
}

/* Video attachment in chat messages */
.sbChat_attachment .sbChat_video-thumb {
  cursor: pointer;
  position: relative;
}

.sbChat_attachment .sbChat_video-thumb::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 49%,
    rgba(var(--chat-accent-rgb, 59, 130, 246), 0.1) 50%,
    transparent 51%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sbChat_attachment:hover .sbChat_video-thumb::after {
  opacity: 1;
}

/* ========== Live Video Streaming Styles ========== */

/* Live streaming modal */
#sbChat_liveStreamModal {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Live streaming window */
#sbChat_liveStreamWindow {
  transition: all 0.3s ease;
}

#sbChat_liveStreamWindow.dragging {
  transition: none;
}

/* Live streaming controls */
#sbChat_liveStreamWindow button {
  transition: all 0.3s ease;
}

#sbChat_liveStreamWindow button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Live indicator animation */
#sbChat_liveIndicator .fas.fa-circle {
  animation: sbChat_blink 1s infinite;
}

/* Frame rate slider */
#sbChat_frameRateSlider {
  accent-color: var(--chat-accent);
}

/* Live streaming stats grid */
.sbChat_live-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
  text-align: center;
}

/* Live streaming button states */
#sbChat_liveStreamBtn:hover {
  background: #e63946 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(255, 107, 107, 0.3);
}

#sbChat_startLiveBtn:hover {
  background: #218838 !important;
}

#sbChat_stopLiveBtn:hover {
  background: #c82333 !important;
}

#sbChat_pauseLiveBtn:hover {
  background: #0056b3 !important;
}

/* Mobile responsive design for live streaming */
@media (max-width: 768px) {
  #sbChat_liveStreamWindow {
    min-width: 300px !important;
    width: 90vw !important;
    height: 70vh !important;
    min-height: 400px !important;
  }

  #sbChat_liveStreamWindow .sbChat_live-stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #sbChat_liveStreamWindow button {
    font-size: 0.8rem !important;
    padding: 8px 16px !important;
  }
}

