/**
 * Dark Theme CSS Variables and Base Styles
 * Comprehensive dark theme foundation for Dexro AI application
 */

:root {
  /* === Color Palette === */
  /* Primary brand colors */
  --color-primary: #007bff;
  --color-primary-light: #66b3ff;
  --color-primary-dark: #0056b3;
  --color-primary-alpha-10: rgba(0, 123, 255, 0.1);
  --color-primary-alpha-20: rgba(0, 123, 255, 0.2);
  --color-primary-alpha-30: rgba(0, 123, 255, 0.3);
  
  /* Secondary colors */
  --color-secondary: #6c757d;
  --color-secondary-light: #a6adb4;
  --color-secondary-dark: #495057;
  
  /* Success, warning, danger, info */
  --color-success: #28a745;
  --color-success-light: #71dd8a;
  --color-success-dark: #1e7e34;
  --color-success-alpha-10: rgba(40, 167, 69, 0.1);
  
  --color-warning: #ffc107;
  --color-warning-light: #ffda6a;
  --color-warning-dark: #e0a800;
  --color-warning-alpha-10: rgba(255, 193, 7, 0.1);
  
  --color-danger: #dc3545;
  --color-danger-light: #f1959b;
  --color-danger-dark: #bd2130;
  --color-danger-alpha-10: rgba(220, 53, 69, 0.1);
  
  --color-info: #17a2b8;
  --color-info-light: #7dd3fc;
  --color-info-dark: #138496;
  --color-info-alpha-10: rgba(23, 162, 184, 0.1);
  
  /* === Dark Theme Background Colors === */
  --bg-primary: #121212;        /* Main background */
  --bg-secondary: #1e1e1e;      /* Card backgrounds */
  --bg-tertiary: #2d2d2d;       /* Input fields, modals */
  --bg-quaternary: #3d3d3d;     /* Hover states */
  --bg-overlay: rgba(0, 0, 0, 0.7); /* Modal overlays */
  
  /* Surface colors for different elevations */
  --surface-0: #121212;         /* Base surface */
  --surface-1: #1e1e1e;         /* Elevated surface 1dp */
  --surface-2: #232323;         /* Elevated surface 2dp */
  --surface-3: #252525;         /* Elevated surface 3dp */
  --surface-4: #272727;         /* Elevated surface 4dp */
  --surface-6: #2c2c2c;         /* Elevated surface 6dp */
  --surface-8: #2e2e2e;         /* Elevated surface 8dp */
  --surface-12: #333333;        /* Elevated surface 12dp */
  --surface-16: #363636;        /* Elevated surface 16dp */
  --surface-24: #3d3d3d;        /* Elevated surface 24dp */
  
  /* === Text Colors === */
  --text-primary: #ffffff;      /* Primary text */
  --text-secondary: #b3b3b3;    /* Secondary text */
  --text-tertiary: #8c8c8c;     /* Tertiary text, placeholders */
  --text-quaternary: #666666;   /* Disabled text */
  --text-inverse: #121212;      /* Text on light backgrounds */
  
  /* === Border Colors === */
  --border-primary: #404040;    /* Primary borders */
  --border-secondary: #333333;  /* Secondary borders */
  --border-tertiary: #2d2d2d;   /* Subtle borders */
  --border-focus: var(--color-primary);
  --border-error: var(--color-danger);
  --border-success: var(--color-success);
  
  /* === Interactive Element Colors === */
  --interactive-normal: var(--color-primary);
  --interactive-hover: var(--color-primary-light);
  --interactive-active: var(--color-primary-dark);
  --interactive-disabled: var(--color-secondary);
  
  /* Button variants */
  --btn-primary-bg: var(--color-primary);
  --btn-primary-hover: var(--color-primary-light);
  --btn-primary-active: var(--color-primary-dark);
  --btn-primary-text: #ffffff;
  
  --btn-secondary-bg: transparent;
  --btn-secondary-hover: var(--surface-4);
  --btn-secondary-active: var(--surface-6);
  --btn-secondary-text: var(--text-primary);
  --btn-secondary-border: var(--border-primary);
  
  --btn-danger-bg: var(--color-danger);
  --btn-danger-hover: var(--color-danger-light);
  --btn-danger-active: var(--color-danger-dark);
  --btn-danger-text: #ffffff;
  
  --btn-warning-bg: #ffc107;
  --btn-warning-hover: #e0a800;
  --btn-warning-active: #d39e00;
  --btn-warning-text: #000000;
  
  --btn-success-bg: #28a745;
  --btn-success-hover: #218838;
  --btn-success-active: #1e7e34;
  --btn-success-text: #ffffff;
  
  /* Link colors */
  --link-normal: var(--color-primary);
  --link-hover: var(--color-primary-light);
  --link-visited: #bb86fc;
  
  /* === Form Element Colors === */
  --input-bg: var(--surface-2);
  --input-border: var(--border-secondary);
  --input-border-focus: var(--border-focus);
  --input-text: var(--text-primary);
  --input-placeholder: var(--text-tertiary);
  
  --select-bg: var(--surface-2);
  --select-border: var(--border-secondary);
  --select-arrow: var(--text-secondary);
  
  --checkbox-bg: var(--surface-2);
  --checkbox-border: var(--border-secondary);
  --checkbox-checked: var(--color-primary);
  
  /* === Navigation Colors === */
  --nav-bg: var(--surface-4);
  --nav-border: var(--border-secondary);
  --nav-item-hover: var(--surface-6);
  --nav-item-active: var(--color-primary-alpha-20);
  --nav-item-text: var(--text-primary);
  --nav-item-text-active: var(--color-primary);
  
  /* === Card Colors === */
  --card-bg: var(--surface-2);
  --card-border: var(--border-tertiary);
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
  
  /* === Modal Colors === */
  --modal-bg: var(--surface-8);
  --modal-border: var(--border-primary);
  --modal-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --modal-overlay: rgba(0, 0, 0, 0.75);
  
  /* === Table Colors === */
  --table-bg: var(--surface-1);
  --table-header-bg: var(--surface-3);
  --table-row-hover: var(--surface-2);
  --table-border: var(--border-tertiary);
  
  /* === Chart Colors === */
  --chart-grid: rgba(255, 255, 255, 0.1);
  --chart-text: var(--text-secondary);
  --chart-tooltip-bg: var(--surface-8);
  --chart-tooltip-border: var(--border-primary);
  
  /* === Status Colors === */
  --status-active: var(--color-success);
  --status-paused: var(--color-warning);
  --status-inactive: var(--color-secondary);
  --status-error: var(--color-danger);
  --status-in-progress: var(--color-info);
  
  /* === Typography === */
  --font-family-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: "SF Mono", Monaco, Inconsolata, "Roboto Mono", "Source Code Pro", monospace;
  
  --font-size-xs: 0.75rem;      /* 12px */
  --font-size-sm: 0.875rem;     /* 14px */
  --font-size-base: 1rem;       /* 16px */
  --font-size-lg: 1.125rem;     /* 18px */
  --font-size-xl: 1.25rem;      /* 20px */
  --font-size-2xl: 1.5rem;      /* 24px */
  --font-size-3xl: 1.875rem;    /* 30px */
  --font-size-4xl: 2.25rem;     /* 36px */
  
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  
  /* === Spacing === */
  --spacing-xs: 0.25rem;        /* 4px */
  --spacing-sm: 0.5rem;         /* 8px */
  --spacing-md: 0.75rem;        /* 12px */
  --spacing-lg: 1rem;           /* 16px */
  --spacing-xl: 1.5rem;         /* 24px */
  --spacing-2xl: 2rem;          /* 32px */
  --spacing-3xl: 3rem;          /* 48px */
  --spacing-4xl: 4rem;          /* 64px */
  
  /* === Border Radius === */
  --radius-sm: 0.25rem;         /* 4px */
  --radius-md: 0.375rem;        /* 6px */
  --radius-lg: 0.5rem;          /* 8px */
  --radius-xl: 0.75rem;         /* 12px */
  --radius-2xl: 1rem;           /* 16px */
  --radius-full: 9999px;
  
  /* === Shadows === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.5);
  --shadow-2xl: 0 16px 32px rgba(0, 0, 0, 0.6);
  
  /* === Z-Index === */
  --z-dropdown: 1000;
  --z-tooltip: 1010;
  --z-popover: 1020;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-toast: 1060;
  
  /* === Transitions === */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
  
  /* === Layout === */
  --max-width-sm: 640px;
  --max-width-md: 768px;
  --max-width-lg: 1024px;
  --max-width-xl: 1280px;
  --max-width-2xl: 1536px;
  
  --header-height: 64px;
  --sidebar-width: 256px;
  --sidebar-width-collapsed: 64px;
}

/* === Base Styles === */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--spacing-lg) 0;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
}

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

p {
  margin: 0 0 var(--spacing-lg) 0;
  color: var(--text-primary);
}

a {
  color: var(--link-normal);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-hover);
}

a:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* === Lists === */
ul, ol {
  margin: 0 0 var(--spacing-lg) 0;
  padding-left: var(--spacing-xl);
  color: var(--text-primary);
}

li {
  margin-bottom: var(--spacing-sm);
}

/* === Code === */
code, pre {
  font-family: var(--font-family-mono);
  font-size: 0.875em;
}

code {
  padding: var(--spacing-xs) var(--spacing-sm);
  background-color: var(--surface-3);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
}

pre {
  padding: var(--spacing-lg);
  background-color: var(--surface-2);
  border-radius: var(--radius-md);
  overflow-x: auto;
  color: var(--text-primary);
}

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

/* === Utility Classes === */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }

.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }
.bg-success { background-color: var(--color-success); }
.bg-warning { background-color: var(--color-warning); }
.bg-danger { background-color: var(--color-danger); }
.bg-info { background-color: var(--color-info); }

.border-primary { border-color: var(--border-primary); }
.border-secondary { border-color: var(--border-secondary); }
.border-success { border-color: var(--color-success); }
.border-warning { border-color: var(--color-warning); }
.border-danger { border-color: var(--color-danger); }
.border-info { border-color: var(--color-info); }

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

/* Font weights */
.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); }

/* Spacing utilities */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mr-0 { margin-right: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mx-0 { margin-left: 0; margin-right: 0; }
.my-0 { margin-top: 0; margin-bottom: 0; }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pr-0 { padding-right: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }
.px-0 { padding-left: 0; padding-right: 0; }
.py-0 { padding-top: 0; padding-bottom: 0; }

/* Display utilities */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }

/* Flexbox utilities */
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

/* Position utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Width utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.max-w-full { max-width: 100%; }

/* Height utilities */
.h-full { height: 100%; }
.h-auto { height: auto; }
.min-h-screen { min-height: 100vh; }

/* Border radius utilities */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow utilities */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }
.shadow-none { box-shadow: none; }

/* Transition utilities */
.transition { transition: all var(--transition-normal); }
.transition-colors { transition: color var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal); }
.transition-transform { transition: transform var(--transition-normal); }
.transition-opacity { transition: opacity var(--transition-normal); }

/* Cursor utilities */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.cursor-default { cursor: default; }

/* Overflow utilities */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* Opacity utilities */
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* === Screen Reader Only === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Focus Styles === */
.focus-ring:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.focus-ring-danger:focus {
  outline: 2px solid var(--color-danger);
  outline-offset: 2px;
}

/* === Responsive Design === */
@media (max-width: 576px) {
  :root {
    --font-size-4xl: 1.875rem;   /* Smaller on mobile */
    --font-size-3xl: 1.5rem;
    --spacing-3xl: 2rem;         /* Reduce spacing on mobile */
    --spacing-4xl: 2.5rem;
  }
}

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