/* Global Font Settings */
body, 
html,
input,
textarea,
button,
select,
div,
span:not([class*="fa"]):not([class*="material"]),
p,
h1, h2, h3, h4, h5, h6 {
  font-family: 'Google Sans Flex', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
}

/* Keep Font Awesome icons */
.fa, .fas, .far, .fal, .fab,
[class^="fa-"], [class*=" fa-"],
i[class*="fa"] {
  font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 6 Brands", "FontAwesome" !important;
}

/* Keep monospace fonts for code */
code, pre, .monospace, 
[class*="courier"], 
[class*="mono"] {
  font-family: 'Courier New', Monaco, Menlo, 'Ubuntu Mono', monospace !important;
}

/* Modern Chat Styles */
.chat-bubble {
  max-width: 80%;
  word-wrap: break-word;
  animation: slideInMessage 0.3s ease-out;
  position: relative;
}

.chat-bubble.user {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  margin-left: auto;
  border-radius: 18px 18px 4px 18px;
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-2);
}

.chat-bubble.bot {
  background: var(--md-sys-color-surface-container) !important;
  color: var(--md-sys-color-on-surface) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
  margin-right: auto;
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--md-sys-elevation-2) !important;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  animation: slideInMessage 0.3s ease-out !important;
}

/* Bot message text color */
.chat-bubble.bot * {
  color: var(--md-sys-color-on-surface) !important;
}

/* Bot message code blocks */
.chat-bubble.bot pre,
.chat-bubble.bot code {
  background: var(--md-sys-color-surface-container-lowest) !important;
  color: var(--md-sys-color-on-surface) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
}

/* Bot message links */
.chat-bubble.bot a {
  color: var(--md-sys-color-tertiary) !important;
  text-decoration: underline;
}

.chat-bubble.system {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 auto;
  border-radius: 18px;
  text-align: center;
  font-size: 0.875rem;
  border: 1px solid var(--md-sys-color-outline);
  box-shadow: var(--md-sys-elevation-1);
}

@keyframes slideInMessage {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Enhanced Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 18px 18px 18px 4px;
  margin-right: auto;
  max-width: 80px;
  box-shadow: var(--md-sys-elevation-1);
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-sys-color-tertiary);
  margin: 0 2px;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Chat Input Styles */
.chat-input-container {
  background: var(--md-sys-color-surface-container-high);
  border-radius: 25px;
  border: 2px solid var(--md-sys-color-outline-variant);
  transition: all 0.3s ease;
}

.chat-input-container:focus-within {
  border-color: #213448;
  box-shadow: 0 0 0 3px rgba(33, 52, 72, 0.1);
}

.chat-input {
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  border-radius: 25px;
}

/* Auto-resize textarea */
.chat-input {
  overflow-y: hidden;
  transition: height 0.2s ease;
}

/* Progress Animations */
.progress-step {
  transition: all 0.3s ease;
}

.progress-step.active {
  background: #94B4C1;
  border-color: #547792;
  transform: scale(1.02);
}

.progress-step.completed {
  background: #EAE0CF;
  border-color: #547792;
}

.progress-step.active .w-8 {
  background: #94B4C1 !important;
}

.progress-step.completed .w-8 {
  background: #EAE0CF !important;
}

.progress-step.active i {
  color: #213448 !important;
}

.progress-step.completed i {
  color: #547792 !important;
}

/* Message animations */
.message {
  opacity: 0;
  transform: translateY(5px);
  animation: fadeInUp 0.3s ease-out forwards;
}

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

/* File Upload Styles */
.file-drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.file-drop-zone.drag-over {
  border-color: #547792;
  background: #EAE0CF;
  transform: scale(1.02);
}

/* Enhanced drag and drop styles */
.drag-over {
  background-color: #EAE0CF !important;
  border-color: #547792 !important;
  transform: scale(1.01);
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(84, 119, 146, 0.15) !important;
}

/* File display animations */
#selected-file-info > div {
  animation: slideInFromTop 0.3s ease-out;
}

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

/* Scrollbar Styles */
#chat-messages {
  scrollbar-width: thin;
  scrollbar-color: #94B4C1 #EAE0CF;
}

#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
  background: #EAE0CF;
  border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background-color: #94B4C1;
  border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
  background-color: #547792;
}

/* Button Enhancements */
button {
  transition: all 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

/* Loading States */
.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Small loading spinner for buttons */
.loading-spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

/* Markdown Styles for Chat Messages */
.chat-bubble.bot h1,
.chat-bubble.bot h2,
.chat-bubble.bot h3,
.chat-bubble.bot h4,
.chat-bubble.bot h5,
.chat-bubble.bot h6 {
  font-weight: 600;
  margin: 0.5rem 0;
  color: #1f2937;
}

.chat-bubble.bot h1 {
  font-size: 1.25rem;
}
.chat-bubble.bot h2 {
  font-size: 1.125rem;
}
.chat-bubble.bot h3 {
  font-size: 1rem;
}

.chat-bubble.bot p {
  margin: 0.5rem 0;
  line-height: 1.5;
}

.chat-bubble.bot ul,
.chat-bubble.bot ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.chat-bubble.bot li {
  margin: 0.25rem 0;
}

.chat-bubble.bot blockquote {
  border-left: 4px solid #94B4C1;
  padding-left: 1rem;
  margin: 0.5rem 0;
  font-style: italic;
  color: #547792;
}

.chat-bubble.bot code {
  background-color: #EAE0CF;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: "Courier New", monospace;
  font-size: 0.875rem;
  color: #213448;
}

.chat-bubble.bot pre {
  background-color: #213448;
  color: #EAE0CF;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-family: "Courier New", monospace;
  font-size: 0.875rem;
}

.chat-bubble.bot pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
}

.chat-bubble.bot table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0;
  font-size: 0.875rem;
}

.chat-bubble.bot th,
.chat-bubble.bot td {
  border: 1px solid #94B4C1;
  padding: 0.5rem;
  text-align: left;
}

.chat-bubble.bot th {
  background-color: #EAE0CF;
  font-weight: 600;
}

.chat-bubble.bot a {
  color: #547792;
  text-decoration: underline;
}

.chat-bubble.bot a:hover {
  color: #213448;
}

.chat-bubble.bot strong {
  font-weight: 600;
}

.chat-bubble.bot em {
  font-style: italic;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .chat-bubble {
    max-width: 90%;
  }

  .container {
    padding: 1rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .text-3xl {
    font-size: 1.875rem;
  }

  .space-x-6 > * + * {
    margin-left: 1rem;
  }

  .p-4 {
    padding: 0.75rem;
  }
}

/* Fade-out animation for notifications */
@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.fade-out {
  animation: fadeOut 3s forwards;
}

/* Legacy compatibility */
#edit-mode-indicator {
  padding: 4px 8px;
  border-radius: 4px;
  background-color: rgba(79, 70, 229, 0.1);
  transition: all 0.3s ease;
}

#edit-mode-indicator.hidden {
  display: none;
}

/* Code output compatibility */
#code-output .message.bot {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

/* Face Tooltip Styles */
.face-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 1000;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.2s ease;
  pointer-events: auto;
}

.face-tooltip.show {
  opacity: 1;
  transform: scale(1);
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.face-id {
  font-weight: bold;
  color: #00ff88;
}

.tooltip-close {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  width: 18px;
  height: 18px;
}

.tooltip-close:hover {
  color: white;
}

.tooltip-body div {
  margin: 4px 0;
  display: flex;
  justify-content: space-between;
}

.tooltip-body span {
  font-weight: bold;
  color: #fff;
}

/* Edge Tooltip Styles */
.edge-tooltip {
  position: absolute;
  background: #547792;
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 1000;
  min-width: 200px;
  box-shadow: 0 4px 20px rgba(84, 119, 146, 0.3);
  border: 1px solid #94B4C1;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.2s ease;
  pointer-events: auto;
}

.edge-tooltip.show {
  opacity: 1;
  transform: scale(1);
}

.edge-tooltip .tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.edge-tooltip .edge-id {
  font-weight: bold;
  color: #94B4C1;
}

.edge-tooltip .tooltip-close {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  width: 18px;
  height: 18px;
}

.edge-tooltip .tooltip-close:hover {
  color: white;
}

.edge-tooltip .tooltip-body div {
  margin: 4px 0;
  display: flex;
  justify-content: space-between;
}

.edge-tooltip .tooltip-body span {
  font-weight: bold;
  color: #fff;
  font-family: 'Courier New', monospace;
}

/* ========================================
   AI THINKING MESSAGE ANIMATIONS
   ======================================== */

/* Fade in animation */
@keyframes aiThinkingFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Fade out animation */
@keyframes aiThinkingFadeOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
}

/* Gradient animation */
@keyframes aiThinkingGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Floating animation */
@keyframes aiThinkingFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* Shimmer effect */
@keyframes aiThinkingShimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Icon rotation */
@keyframes aiThinkingIconRotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Pulse ring */
@keyframes aiThinkingPulseRing {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.3);
    opacity: 0;
  }
  100% {
    transform: scale(0.8);
    opacity: 0;
  }
}

/* Text glow */
@keyframes aiThinkingTextGlow {
  0%, 100% {
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
  }
  50% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  }
}

/* Dot bounce */
@keyframes aiThinkingDotBounce {
  0%, 80%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-8px) scale(1.2);
    opacity: 1;
  }
}

/* AI Thinking Classes */
.ai-thinking-fade-in {
  animation: aiThinkingFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.ai-thinking-fade-out {
  animation: aiThinkingFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.ai-thinking-bubble {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-thinking-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(84, 119, 146, 0.4) !important;
}

.ai-thinking-icon-container {
  position: relative;
  animation: aiThinkingIconRotate 3s linear infinite;
  transform-origin: center;
}

.ai-thinking-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  margin-left: -20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  animation: aiThinkingPulseRing 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.ai-thinking-text {
  animation: aiThinkingTextGlow 2s ease-in-out infinite;
}

.ai-thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: white;
  animation: aiThinkingDotBounce 1.4s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* Old pulse animation - kept for backward compatibility */
@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
