/* Modern AI Chat Typography System - Inspired by ChatGPT, Claude, LibreChat
 * Using Inter (ChatGPT/LibreChat primary), JetBrains Mono (code), Source Serif Pro (Claude-style headers)
 * Optimized for readability, accessibility, and modern AI application aesthetics
 */

/* === INTER FONT FAMILY (Primary UI Font) === */
/* ChatGPT and LibreChat use Inter for its superior readability and modern geometric design */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-300.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-400.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-500.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-600.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-700.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* === JETBRAINS MONO FONT FAMILY (Monospace/Code) === */
/* JetBrains Mono provides excellent code readability with programming ligatures */

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono/jetbrains-mono-400.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono/jetbrains-mono-500.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono/jetbrains-mono-600.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono/jetbrains-mono-700.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* === SOURCE SERIF PRO FONT FAMILY (Serif Headers - Claude Style) === */
/* Source Serif Pro adds elegant, readable serif typography for headers */

@font-face {
  font-family: 'Source Serif Pro';
  src: url('/fonts/source-serif-pro/source-serif-pro-400.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Source Serif Pro';
  src: url('/fonts/source-serif-pro/source-serif-pro-600.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Source Serif Pro';
  src: url('/fonts/source-serif-pro/source-serif-pro-700.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* === CSS CUSTOM PROPERTIES (Design Tokens) === */
:root {
  /* Font Stack Variables - Optimized for Modern AI Applications */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  --font-serif: 'Source Serif Pro', ui-serif, 'Times New Roman', Times, serif;
  
  /* Typography Scale - Based on ChatGPT/Claude Design System */
  --text-xs: 0.75rem;    /* 12px - Small labels, timestamps */
  --text-sm: 0.875rem;   /* 14px - Secondary text, captions */
  --text-base: 1rem;     /* 16px - Body text, chat messages */
  --text-lg: 1.125rem;   /* 18px - Large body, emphasized text */
  --text-xl: 1.25rem;    /* 20px - Small headings */
  --text-2xl: 1.5rem;    /* 24px - Medium headings */
  --text-3xl: 1.875rem;  /* 30px - Large headings */
  --text-4xl: 2.25rem;   /* 36px - Hero text */
  
  /* Font Weight Variables */
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Line Height Variables - Optimized for readability */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;
  
  /* Letter Spacing - Subtle improvements for digital screens */
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.025em;
  --tracking-normal: 0em;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  
  /* Monochrome Color System - ChatGPT/LibreChat Inspired */
  --text-primary: #1f1f1f;        /* Primary text - Almost black */
  --text-secondary: #676767;      /* Secondary text - Medium gray */
  --text-tertiary: #8e8e8e;       /* Tertiary text - Light gray */
  --text-quaternary: #b4b4b4;     /* Quaternary text - Very light gray */
  --text-inverse: #ffffff;        /* Inverse text - Pure white */
  
  /* Background Colors - Pure monochrome */
  --bg-primary: #ffffff;          /* Primary background - Pure white */
  --bg-secondary: #f7f7f8;        /* Secondary background - Very light gray */
  --bg-tertiary: #f1f1f3;         /* Tertiary background - Light gray */
  --bg-quaternary: #ececec;       /* Quaternary background - Gray */
  --bg-hover: #f5f5f5;           /* Hover background */
  --bg-chat-user: #f4f4f4;        /* User message background */
  --bg-chat-ai: transparent;      /* AI message background */
  --bg-sidebar: #f9f9f9;          /* Sidebar background - Slightly darker than primary */
  
  /* Interactive Colors - Monochrome with minimal accent */
  --accent-primary: #1f1f1f;      /* Primary action - Black */
  --accent-hover: #333333;        /* Hover state - Dark gray */
  --accent-active: #000000;       /* Active state - Pure black */
  --accent-disabled: #d1d1d1;     /* Disabled state - Light gray */
  
  /* Border Colors - Subtle monochrome */
  --border-light: #e5e5e5;        /* Light border */
  --border-medium: #d1d1d1;       /* Medium border */
  --border-dark: #b4b4b4;         /* Dark border */
  --border-focus: #8e8e8e;        /* Focus border */
  
  /* Shadow Colors - Monochrome */
  --shadow-light: rgba(0, 0, 0, 0.04);
  --shadow-medium: rgba(0, 0, 0, 0.08);
  --shadow-dark: rgba(0, 0, 0, 0.12);
  --shadow-focus: rgba(0, 0, 0, 0.16);
  
  /* Action Colors - For buttons and interactive elements */
  --primary: #3b82f6;                 /* Primary blue */
  --primary-dark: #2563eb;            /* Darker primary for hover */
  --primary-light: #60a5fa;           /* Lighter primary */
  --danger: #ef4444;                  /* Danger red */
  --danger-dark: #dc2626;             /* Darker danger for hover */
  --danger-light: #f87171;            /* Lighter danger */
  --success: #10b981;                 /* Success green */
  --success-dark: #059669;            /* Darker success for hover */
  --success-light: #34d399;           /* Lighter success */
  --warning: #f59e0b;                 /* Warning orange */
  --warning-dark: #d97706;            /* Darker warning for hover */
  --warning-light: #fbbf24;           /* Lighter warning */
  --error: var(--danger);             /* Alias for danger */
  --error-dark: var(--danger-dark);   /* Alias for danger-dark */
}

/* === GLOBAL TYPOGRAPHY RESET === */
* {
  box-sizing: border-box;
}

/* === SVG ICON STYLING === */
svg {
  flex-shrink: 0;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure all SVG icons inherit current color */
button svg,
.icon svg,
.user-avatar svg,
.profile-avatar svg,
.welcome-icon svg,
.loading-icon svg,
.settings-icon,
.toggle-arrow {
  color: inherit;
  stroke: currentColor;
}

/* Spinning animation for loading icons */
.loading-icon svg {
  animation: spin 1s linear infinite;
}

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

/* Page Title Styling - Ultra Professional with Logo */
.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
  min-height: 40px;
}

.header-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
  flex-shrink: 0;
  display: block;
}

.header-text {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

html {
  font-size: 16px; /* Base font size for rem calculations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  letter-spacing: var(--tracking-normal);
}

/* === TYPOGRAPHY UTILITIES === */

/* Font Family Classes */
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }
.font-serif { font-family: var(--font-serif); }

/* Font Size Classes */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }

/* Font Weight Classes */
.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* Line Height Classes */
.leading-none { line-height: var(--leading-none); }
.leading-tight { line-height: var(--leading-tight); }
.leading-snug { line-height: var(--leading-snug); }
.leading-normal { line-height: var(--leading-normal); }
.leading-relaxed { line-height: var(--leading-relaxed); }
.leading-loose { line-height: var(--leading-loose); }

/* Letter Spacing Classes */
.tracking-tighter { letter-spacing: var(--tracking-tighter); }
.tracking-tight { letter-spacing: var(--tracking-tight); }
.tracking-normal { letter-spacing: var(--tracking-normal); }
.tracking-wide { letter-spacing: var(--tracking-wide); }
.tracking-wider { letter-spacing: var(--tracking-wider); }

/* Text Color Classes */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-inverse { color: var(--text-inverse); }

/* === DEFAULT HTML ELEMENT STYLING === */

/* Headings - Claude/ChatGPT inspired hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 0.75em 0;
}

h1 { font-size: var(--text-4xl); font-weight: var(--font-weight-bold); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); font-family: var(--font-sans); }
h6 { font-size: var(--text-base); font-family: var(--font-sans); }

/* Body text elements */
p {
  margin: 0 0 1rem 0;
  line-height: var(--leading-relaxed);
}

/* Code and preformatted text */
code, pre, .code {
  font-family: var(--font-mono);
  background-color: var(--bg-tertiary);
  border-radius: 4px;
}

code {
  padding: 0.125rem 0.25rem;
  font-size: 0.875em;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  line-height: var(--leading-normal);
}

pre code {
  background: none;
  padding: 0;
}

/* Lists */
ul, ol {
  margin: 0 0 1rem 0;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.25rem;
}

/* Links */
a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.2s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

/* Small text */
small {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Strong and emphasis */
strong, b {
  font-weight: var(--font-weight-semibold);
}

em, i {
  font-style: italic;
}

/* === CHAT-SPECIFIC TYPOGRAPHY === */

/* Chat message text - Optimized for long-form reading */
.message-content p,
.chat-message {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  font-weight: var(--font-weight-normal);
}

/* User input text */
.chat-input,
#messageInput {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: var(--font-weight-normal);
}

/* Timestamps and metadata */
.timestamp,
.message-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--tracking-wide);
}

/* Welcome message styling */
.welcome-message h2 {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.welcome-message p {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Button typography */
button, .btn {
  font-family: var(--font-sans);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--tracking-wide);
}

/* Form labels */
label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  letter-spacing: var(--tracking-wide);
}

/* === RESPONSIVE TYPOGRAPHY === */
@media (max-width: 768px) {
  html {
    font-size: 14px; /* Slightly smaller base size on mobile */
  }
  
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
  
  .welcome-message h2 {
    font-size: var(--text-2xl);
  }
  
  .welcome-message p {
    font-size: var(--text-base);
  }
}

/* === ACCESSIBILITY IMPROVEMENTS === */
@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #000000;
    --text-secondary: #333333;
    --bg-primary: #ffffff;
  }
}

/* Dark mode - Inverted monochrome */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #909090;
    --text-quaternary: #707070;
    --text-inverse: #1f1f1f;
    
    --bg-primary: #1f1f1f;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --bg-quaternary: #404040;
    --bg-hover: #2d2d2d;
    --bg-chat-user: #2a2a2a;
    --bg-chat-ai: transparent;
    --bg-sidebar: #181818;          /* Darker than primary in dark mode */
    
    --accent-primary: #f0f0f0;
    --accent-hover: #d0d0d0;
    --accent-active: #ffffff;
    --accent-disabled: #505050;
    
    --border-light: #333333;
    --border-medium: #404040;
    --border-dark: #505050;
    --border-focus: #707070;
    
    --shadow-light: rgba(255, 255, 255, 0.04);
    --shadow-medium: rgba(255, 255, 255, 0.08);
    --shadow-dark: rgba(255, 255, 255, 0.12);
    --shadow-focus: rgba(255, 255, 255, 0.16);
  }
}