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

/* ===== DESIGN SYSTEM VARIABLES ===== */
:root {
  /* Dark Theme (Primary) */
  --color-bg-primary: #0a0a0a;
  --color-bg-secondary: #1a1a1a;
  --color-bg-tertiary: #2a2a2a;
  --color-bg-surface: #1e1e1e;
  --color-bg-overlay: rgba(0, 0, 0, 0.8);

  --color-text-primary: #ffffff;
  --color-text-secondary: #b3b3b3;
  --color-text-tertiary: #808080;
  --color-text-inverse: #000000;

  --color-border-primary: #333333;
  --color-border-secondary: #404040;
  --color-border-focus: #0066cc;

  --color-accent-primary: #0066cc;
  --color-accent-secondary: #0052a3;
  --color-accent-tertiary: #004080;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;

  /* Light Theme Variables */
  --color-bg-primary-light: #ffffff;
  --color-bg-secondary-light: #f8f9fa;
  --color-bg-tertiary-light: #e9ecef;
  --color-bg-surface-light: #ffffff;
  --color-bg-overlay-light: rgba(255, 255, 255, 0.9);

  --color-text-primary-light: #000000;
  --color-text-secondary-light: #4a4a4a;
  --color-text-tertiary-light: #808080;
  --color-text-inverse-light: #ffffff;

  --color-border-primary-light: #e5e5e5;
  --color-border-secondary-light: #d1d5db;
  --color-border-focus-light: #0066cc;

  /* Font Families */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Spacing Scale */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Border Radius */
  --radius-none: 0;
  --radius-sm: 0.125rem;
  --radius-base: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Animations */
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Responsive Breakpoints */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* Light Theme Override */
.light {
  --color-bg-primary: var(--color-bg-primary-light);
  --color-bg-secondary: var(--color-bg-secondary-light);
  --color-bg-tertiary: var(--color-bg-tertiary-light);
  --color-bg-surface: var(--color-bg-surface-light);
  --color-bg-overlay: var(--color-bg-overlay-light);

  --color-text-primary: var(--color-text-primary-light);
  --color-text-secondary: var(--color-text-secondary-light);
  --color-text-tertiary: var(--color-text-tertiary-light);
  --color-text-inverse: var(--color-text-inverse-light);

  --color-border-primary: var(--color-border-primary-light);
  --color-border-secondary: var(--color-border-secondary-light);
  --color-border-focus: var(--color-border-focus-light);
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html {
  font-family: var(--font-primary);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

/* ===== LAYOUT UTILITIES ===== */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  overflow: hidden;
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: 50;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
}

/* Chat Layout */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-header {
  flex-shrink: 0;
  height: 60px;
  border-bottom: 1px solid var(--color-border-primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.chat-input {
  flex-shrink: 0;
  padding: var(--space-4);
  border-top: 1px solid var(--color-border-primary);
}

/* Settings Modal Layout */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.settings-content {
  background: var(--color-bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  width: 90vw;
  height: 80vh;
  max-width: 1000px;
  display: grid;
  grid-template-columns: 240px 1fr;
  overflow: hidden;
}

@media (max-width: 768px) {
  .settings-content {
    width: 95vw;
    height: 90vh;
    grid-template-columns: 1fr;
  }
  
  .settings-nav {
    display: none;
  }
  
  .settings-nav.mobile-open {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 240px;
    height: 100%;
    background: var(--color-bg-secondary);
    z-index: 10;
  }
}

/* ===== COMPONENT UTILITIES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-primary {
  background-color: var(--color-accent-primary);
  color: var(--color-text-inverse);
}

.btn-primary:hover {
  background-color: var(--color-accent-secondary);
}

.btn-secondary {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-primary);
}

.btn-secondary:hover {
  background-color: var(--color-bg-secondary);
}

.input {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-primary);
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.input:focus {
  outline: none;
  border-color: var(--color-border-focus);
}

.input::placeholder {
  color: var(--color-text-tertiary);
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
}

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