/* Navbit Custom Theme - Dark/Light Mode Support */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== DARK MODE (Default) ===== */
:root,
.dark {
  /* Pure black background */
  --nvbt-bg-primary: #000000;
  --nvbt-bg-secondary: #0a0a0a;
  --nvbt-bg-tertiary: #1a1a1a;

  /* Pure white text */
  --nvbt-text-primary: #FFFFFF;
  --nvbt-text-secondary: #E0E0E0;
  --nvbt-text-muted: rgba(255, 255, 255, 0.6);

  /* Borders */
  --nvbt-border-color: #333333;
  --nvbt-border-light: #222222;
  --nvbt-border-hover: #444444;

  /* Input fields */
  --nvbt-input-bg: #0a0a0a;
  --nvbt-input-bg-focus: rgba(255, 255, 255, 0.1);
  --nvbt-input-border: rgba(255, 255, 255, 0.1);

  /* Buttons */
  --nvbt-button-bg: #1a1a1a;
  --nvbt-button-bg-hover: #252525;
  --nvbt-button-text: #ffffff;

  /* Header logo - dark mode uses just "navbit" (white) */
  --nvbt-header-logo: url("/public/logo_top_left.png");
  /* Start screen logo - dark mode uses full "navbit RAPID SURGICAL PLAN" (white) */
  --nvbt-start-logo: url("/public/logos/NVBT_RAPID_SP_Negative_RGB_v1.png");

  /* Chainlit overrides */
  --background-color: #000000;
  --paper-background-color: #000000;
  --text-primary: #FFFFFF;
  --text-secondary: #E0E0E0;
  --border-color: #333333;
  --primary: #FFFFFF;
}

/* ===== LIGHT MODE ===== */
.light {
  /* Light backgrounds */
  --nvbt-bg-primary: #FFFFFF;
  --nvbt-bg-secondary: #F5F5F5;
  --nvbt-bg-tertiary: #EEEEEE;

  /* Dark text */
  --nvbt-text-primary: #1A1A1A;
  --nvbt-text-secondary: #444444;
  --nvbt-text-muted: rgba(0, 0, 0, 0.6);

  /* Borders */
  --nvbt-border-color: #CCCCCC;
  --nvbt-border-light: #DDDDDD;
  --nvbt-border-hover: #AAAAAA;

  /* Input fields */
  --nvbt-input-bg: #FFFFFF;
  --nvbt-input-bg-focus: #F8F8F8;
  --nvbt-input-border: rgba(0, 0, 0, 0.15);

  /* Buttons */
  --nvbt-button-bg: #F0F0F0;
  --nvbt-button-bg-hover: #E5E5E5;
  --nvbt-button-text: #1A1A1A;

  /* Header logo - light mode uses black/positive version */
  --nvbt-header-logo: url("/public/logos/NVBT_Black_RGB_v1.png");
  --nvbt-start-logo: url("/public/logos/NVBT_RAPID_SP_Positive_RGB_v1.png");

  /* Chainlit overrides for light mode */
  --background-color: #FFFFFF;
  --paper-background-color: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #444444;
  --border-color: #CCCCCC;
  --primary: #1A1A1A;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  background-color: var(--nvbt-bg-primary) !important;
  color: var(--nvbt-text-primary) !important;
}

/* Main chat area */
.MuiPaper-root,
.css-1vbkfx9 {
  background-color: var(--nvbt-bg-primary) !important;
}

/* Message bubbles */
.step-container {
  background-color: var(--nvbt-bg-secondary) !important;
  border: 1px solid var(--nvbt-border-light) !important;
  border-radius: 12px !important;
}

/* Input area */
.MuiOutlinedInput-root {
  background-color: var(--nvbt-input-bg) !important;
  border: 1px solid var(--nvbt-border-color) !important;
  border-radius: 12px !important;
}

.MuiOutlinedInput-input {
  color: var(--nvbt-text-primary) !important;
}

/* Sidebar */
.MuiDrawer-paper {
  background-color: var(--nvbt-bg-primary) !important;
  border-right: 1px solid var(--nvbt-border-light) !important;
}

/* Buttons */
.MuiButton-root {
  color: var(--nvbt-text-primary) !important;
}

.MuiButton-contained {
  background-color: var(--nvbt-text-primary) !important;
  color: var(--nvbt-bg-primary) !important;
  background-image: none !important;
  /* Ensure no conflict */
}

/* Links */
a {
  color: var(--nvbt-text-primary) !important;
}

/* Headers */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--nvbt-text-primary) !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--nvbt-bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--nvbt-border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--nvbt-border-hover);
}

/* 
   Chatbot avatar - smaller (24px)
   Targeting the specific container classes
*/
.ai-message .relative.flex.shrink-0.overflow-hidden.rounded-full,
.ai-message span[class*="rounded-full"][class*="w-5"] {
  width: 24px !important;
  height: 24px !important;
  margin-top: 4px !important;
}

/* 
   HEADER BRANDING
   Shift header content to make room for logo
*/
#header {
  padding-left: 200px !important;
  /* Increased space for larger logo */
  position: relative !important;
}

/* Inject the logo into the header - uses theme-aware variable */
#header::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 60%;
  /* Adjusted from 50% to fix clipping */
  transform: translateY(-50%);
  width: 140px;
  /* 1.5x larger (was 140px) */
  height: 48px;
  /* 1.5x larger (was 48px) */
  background-image: var(--nvbt-header-logo);
  /* Uses theme-aware logo variable */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left center;
  z-index: 9999;
  pointer-events: none;
}

/* 
   LIVE AVATAR BUTTON - Bottom Right Corner
   Pill-shaped "Speak live" button matching chat interface
*/
#avatar-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 12px 20px;
  border-radius: 24px;
  background: var(--nvbt-button-bg);
  border: 1px solid var(--nvbt-border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--nvbt-button-text);
  transition: all 0.2s ease;
  z-index: 10000;
}

#avatar-button:hover {
  background: var(--nvbt-button-bg-hover);
  border-color: var(--nvbt-border-hover);
  transform: translateY(-2px);
}

#avatar-button svg {
  width: 18px;
  height: 18px;
  color: var(--nvbt-button-text);
}

/* 
   AVATAR POPUP MODAL
   Blurred background effect with dark theme matching chat interface
*/
#avatar-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 10001;
  align-items: center;
  justify-content: center;
}

#avatar-modal.active {
  display: flex;
}

#avatar-container {
  position: relative;
  width: 90%;
  max-width: 800px;
  height: 90vh;
  max-height: 700px;
  background: var(--nvbt-bg-secondary);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--nvbt-border-light);
}

/* Close button */
#close-avatar {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

#close-avatar:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

#close-avatar svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* Avatar video container */
#avatar-video-container {
  width: 100%;
  height: 100%;
  background: #000000;
  position: relative;
}

#avatar-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 55% 50%;
}

/* Placeholder when no video */
#avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

#avatar-placeholder.hidden {
  display: none;
}

.avatar-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--nvbt-button-bg);
  border: 1px solid var(--nvbt-border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pulse-slow {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

.avatar-icon svg {
  width: 36px;
  height: 36px;
  color: var(--nvbt-text-primary);
}

.avatar-placeholder-text {
  color: var(--nvbt-text-muted);
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* Status badges */
#avatar-status {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.status-badge {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  border: 1px solid;
}

.status-badge.speaking {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.2);
}

.status-badge.listening {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.2);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Controls at bottom */
#avatar-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 24px 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.8) 70%, transparent 100%);
  z-index: 10;
}

#avatar-controls.hidden {
  display: none;
}

.control-group {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Text input row */
.input-row {
  display: flex;
  gap: 12px;
}

#avatar-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px 20px;
  color: white;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

#avatar-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

#avatar-input:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.control-btn {
  padding: 16px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  transform: scale(1.05);
}

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

.control-btn.primary {
  background: #e6588a;
  box-shadow: none;
}

.control-btn.primary:hover {
  background: #d44478;
}

.control-btn svg {
  width: 24px;
  height: 24px;
  color: white;
}

/* Action buttons row */
.actions-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-btn {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.8);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.action-btn:active {
  background: rgba(59, 130, 246, 0.2);
}

.action-btn.muted {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.action-btn.muted:hover {
  background: rgba(239, 68, 68, 0.2);
}

.action-btn.danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.action-btn svg {
  width: 20px;
  height: 20px;
}

.action-label {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.8px;
  opacity: 0.7;
}

/* Start button - matches chat interface style */
#start-avatar-btn {
  width: 100%;
  padding: 18px 24px;
  border-radius: 20px;
  border: 1px solid var(--nvbt-border-color);
  background: var(--nvbt-button-bg);
  color: var(--nvbt-button-text);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#start-avatar-btn:hover {
  background: var(--nvbt-button-bg-hover);
  border-color: var(--nvbt-border-hover);
}

#start-avatar-btn:active {
  transform: scale(0.98);
}

#start-avatar-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--nvbt-button-text);
}

/* Loading spinner - matches dark theme */
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#loading-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  z-index: 20;
}

#loading-overlay.active {
  display: flex;
}

.loading-text {
  color: var(--nvbt-text-primary);
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* 
   ========================================
   CHAINLIT START SCREEN LOGO
   The logo that appears above the text input on the start screen
   Uses theme-aware variable for automatic light/dark switching
   ========================================
*/
/* Hide the default Chainlit logo image */
#welcome-screen>img.logo {
  display: none !important;
}

/* Inject Navbit logo above the input using a pseudo-element */
#welcome-screen::before {
  content: "";
  display: block;
  width: 200px;
  height: 60px;
  background-image: var(--nvbt-start-logo);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  margin: 0 auto 20px auto;
}

/* 
   ========================================
   ADDITIONAL LIGHT MODE OVERRIDES
   For elements that need explicit light mode handling
   ========================================
*/
.light .MuiPaper-root,
.light .css-1vbkfx9 {
  background-color: var(--nvbt-bg-primary) !important;
}

.light .step-container {
  background-color: var(--nvbt-bg-secondary) !important;
  border-color: var(--nvbt-border-light) !important;
}

.light .MuiOutlinedInput-root {
  background-color: var(--nvbt-input-bg) !important;
  border-color: var(--nvbt-border-color) !important;
}

.light .MuiOutlinedInput-input {
  color: var(--nvbt-text-primary) !important;
}

.light .MuiDrawer-paper {
  background-color: var(--nvbt-bg-primary) !important;
  border-color: var(--nvbt-border-light) !important;
}

.light .MuiButton-root {
  color: var(--nvbt-text-primary) !important;
}

.light .MuiButton-contained {
  background-color: var(--nvbt-text-primary) !important;
  color: var(--nvbt-bg-primary) !important;
}

.light a {
  color: var(--nvbt-text-primary) !important;
}

.light h1,
.light h2,
.light h3,
.light h4,
.light h5,
.light h6 {
  color: var(--nvbt-text-primary) !important;
}

/* Light mode text color overrides for messages */
.light .message-content,
.light .markdown-body,
.light p,
.light span,
.light li {
  color: var(--nvbt-text-primary) !important;
}

/* Ensure code blocks adapt */
.light pre,
.light code {
  background-color: var(--nvbt-bg-secondary) !important;
  color: var(--nvbt-text-primary) !important;
}