@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 0 0% 0%;

    --card: 0 0% 100%;
    --card-foreground: 0 0% 0%;

    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 0%;

    --primary: 0 0% 0%;
    --primary-foreground: 0 0% 100%;

    --secondary: 0 0% 96%;
    --secondary-foreground: 0 0% 9%;

    --muted: 0 0% 96%;
    --muted-foreground: 0 0% 45%;

    --accent: 0 0% 96%;
    --accent-foreground: 0 0% 9%;

    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 98%;

    --border: 0 0% 90%;
    --input: 0 0% 90%;
    --ring: 0 0% 0%;

    --radius: 0.5rem;

    /* OpenSAM light mode colors */
    --opensam-black: 0 0% 0%;
    --opensam-white: 0 0% 100%;
    --opensam-gray-50: 0 0% 98%;
    --opensam-gray-100: 0 0% 96%;
    --opensam-gray-200: 0 0% 90%;
    --opensam-gray-300: 0 0% 83%;
    --opensam-gray-400: 0 0% 64%;
    --opensam-gray-500: 0 0% 45%;
    --opensam-gray-600: 0 0% 32%;
    --opensam-gray-700: 0 0% 25%;
    --opensam-gray-800: 0 0% 15%;
    --opensam-gray-900: 0 0% 9%;
    --opensam-gray-950: 0 0% 4%;
  }

  .dark {
    --background: 0 0% 10%;
    --foreground: 0 0% 98%;

    --card: 0 0% 12%;
    --card-foreground: 0 0% 98%;

    --popover: 0 0% 12%;
    --popover-foreground: 0 0% 98%;

    --primary: 0 0% 98%;
    --primary-foreground: 0 0% 9%;

    --secondary: 0 0% 18%;
    --secondary-foreground: 0 0% 98%;

    --muted: 0 0% 18%;
    --muted-foreground: 0 0% 64%;

    --accent: 0 0% 18%;
    --accent-foreground: 0 0% 98%;

    --destructive: 0 62% 30%;
    --destructive-foreground: 0 0% 98%;

    --border: 0 0% 20%;
    --input: 0 0% 18%;
    --ring: 0 0% 83%;

    /* OpenSAM dark mode colors */
    --opensam-black: 0 0% 98%;
    --opensam-white: 0 0% 12%;
    --opensam-gray-50: 0 0% 15%;
    --opensam-gray-100: 0 0% 18%;
    --opensam-gray-200: 0 0% 25%;
    --opensam-gray-300: 0 0% 35%;
    --opensam-gray-400: 0 0% 45%;
    --opensam-gray-500: 0 0% 55%;
    --opensam-gray-600: 0 0% 65%;
    --opensam-gray-700: 0 0% 75%;
    --opensam-gray-800: 0 0% 85%;
    --opensam-gray-900: 0 0% 95%;
    --opensam-gray-950: 0 0% 98%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
  }
}

/* Custom scrollbar for the black and white theme */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f5f5f5;
}

::-webkit-scrollbar-thumb {
  background: #a3a3a3;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #737373;
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
  background: #171717;
}

.dark ::-webkit-scrollbar-thumb {
  background: #404040;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #525252;
}

/* Custom animations for OpenSAM AI */
@keyframes pulse-subtle {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fade-in-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-pulse-subtle {
  animation: pulse-subtle 2s infinite;
}

.animate-slide-in {
  animation: slide-in 0.3s ease-out;
}

.animate-fade-in-up {
  animation: fade-in-up 0.3s ease-out;
}

/* Chat message styles */
.chat-message {
  @apply rounded-lg p-4 max-w-2xl;
}

.chat-message-user {
  @apply bg-opensam-gray-100 ml-8 text-opensam-black;
}

.chat-message-assistant {
  @apply bg-opensam-white border border-opensam-gray-200 mr-8 text-opensam-black;
}

.chat-message-system {
  @apply bg-opensam-gray-50 border border-opensam-gray-200 text-opensam-gray-700 italic;
}

/* Loading dots animation */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.loading-dots::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: currentColor;
  animation: loading-dots 1.4s infinite both;
}

.loading-dots::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: currentColor;
  animation: loading-dots 1.4s infinite both;
  animation-delay: -0.16s;
  margin-right: 2px;
}

@keyframes loading-dots {
  0%, 80%, 100% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
}

/* Syntax highlighting for code blocks */
pre {
  @apply bg-opensam-gray-100 rounded-lg p-4 overflow-x-auto;
}

code {
  @apply bg-opensam-gray-100 rounded px-2 py-1 font-mono text-sm;
}

pre code {
  @apply bg-transparent p-0;
}

/* Enhanced Chat Interface Styles */
.chat-container {
  @apply h-[calc(100vh-200px)] flex flex-col;
}

.chat-messages {
  @apply flex-1 overflow-y-auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(156, 163, 175, 0.5);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background-color: rgba(156, 163, 175, 0.7);
}

/* Message bubble animations */
.message-bubble {
  animation: messageSlideIn 0.3s ease-out;
}

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

/* Typing indicator animation */
.typing-dots {
  animation: typingDots 1.4s infinite;
}

@keyframes typingDots {
  0%, 20% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
  80%, 100% {
    transform: translateY(0);
  }
}

/* Enhanced input area */
.chat-input {
  @apply transition-all duration-200;
}

.chat-input:focus-within {
  @apply ring-2 ring-blue-500 ring-opacity-50;
}

/* Auto-resize textarea */
.chat-textarea {
  resize: none;
  overflow-y: hidden;
}

/* Message actions hover effects */
.message-actions button {
  @apply transition-all duration-200;
}

.message-actions button:hover {
  @apply scale-105;
}

/* Company profile selector animations */
.company-profile-option {
  @apply transition-all duration-200;
}

.company-profile-option:hover {
  @apply transform scale-[1.02];
}

/* Enhanced loading states */
.loading-spinner {
  animation: spin 1s linear infinite;
}

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

/* Message timestamp fade */
.message-timestamp {
  @apply opacity-60 transition-opacity duration-200;
}

.message-timestamp:hover {
  @apply opacity-100;
}

/* RAG context styling */
.rag-context {
  @apply animate-fade-in-up;
}

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

/* Quick action buttons */
.quick-action {
  @apply transition-all duration-200 hover:shadow-md hover:scale-[1.02];
}

.quick-action:hover {
  @apply border-blue-300;
}

/* Status indicators */
.status-indicator {
  @apply animate-pulse;
}

/* Enhanced markdown styling for chat */
.chat-markdown {
  @apply text-sm leading-relaxed;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
  @apply font-semibold text-gray-900 mb-2;
}

.chat-markdown h1 {
  @apply text-lg;
}

.chat-markdown h2 {
  @apply text-base;
}

.chat-markdown h3,
.chat-markdown h4 {
  @apply text-sm;
}

.chat-markdown p {
  @apply mb-2;
}

.chat-markdown ul,
.chat-markdown ol {
  @apply mb-2 pl-4;
}

.chat-markdown li {
  @apply mb-1;
}

.chat-markdown code {
  @apply bg-gray-100 rounded px-1 py-0.5 text-xs font-mono;
}

.chat-markdown pre {
  @apply bg-gray-100 rounded p-3 overflow-x-auto mb-2;
}

.chat-markdown pre code {
  @apply bg-transparent p-0;
}

.chat-markdown blockquote {
  @apply border-l-4 border-gray-300 pl-4 italic text-gray-600 mb-2;
}

.chat-markdown a {
  @apply text-blue-600 hover:text-blue-800 underline;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  .chat-container {
    @apply h-[calc(100vh-150px)];
  }
  
  .message-bubble {
    @apply max-w-[90%];
  }
  
  .quick-actions-grid {
    @apply grid-cols-1;
  }
}

/* Dark mode support */
.dark .chat-markdown {
  @apply text-foreground;
}

.dark .chat-markdown h1,
.dark .chat-markdown h2,
.dark .chat-markdown h3,
.dark .chat-markdown h4 {
  @apply text-foreground;
}

.dark .chat-markdown code {
  @apply bg-muted text-foreground;
}

.dark .chat-markdown pre {
  @apply bg-muted;
}

.dark .chat-markdown blockquote {
  @apply border-border text-muted-foreground;
}

/* Focus states for accessibility */
.focus-visible:focus {
  @apply outline-none ring-2 ring-opensam-black ring-offset-2;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: 0 0% 0%;
    --input: 0 0% 0%;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .chat-message {
    border: 1px solid #000 !important;
    margin: 10px 0 !important;
    break-inside: avoid;
  }
}