/**
 * Command Center CSS Variables & Theme System
 * Supports light and dark modes with Tenex brand colors
 * Compatible with Tailwind CSS utilities
 */

/* ========================================
   ROOT VARIABLES - Light Mode (Default)
   ======================================== */
:root {
  /* Color Palette - Light Mode */
  --background: #ffffff;
  --foreground: #1a202c;
  --primary: #3b82f6;
  --primary-foreground: #f8fafc;
  --secondary: #f1f5f9;
  --secondary-foreground: #1e293b;
  --accent: #f1f5f9;
  --accent-foreground: #1e293b;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #3b82f6;
  --destructive: #ef4444;
  --destructive-foreground: #f8fafc;
  --card: #ffffff;
  --card-foreground: #1a202c;
  --popover: #ffffff;
  --popover-foreground: #1a202c;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;

  /* Tenex Brand Colors */
  --brand: #0d2847;
  --brand-foreground: #f8fafc;
  --brandlight: #4a90e2;
  --branddark: #0d2847;

  /* Spacing & Sizing */
  --radius: 0.375rem;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-size-base: 16px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

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

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ========================================
   SEMANTIC COLOR VARIABLES
   (Utility aliases for common patterns)
   ======================================== */
:root {
  /* Button States */
  --button-bg: var(--primary);
  --button-fg: var(--primary-foreground);
  --button-border: var(--primary);
  --button-hover-bg: color-mix(in srgb, var(--primary) 85%, black);
  --button-focus-ring: var(--ring);

  /* Input States */
  --input-bg: var(--input);
  --input-fg: var(--foreground);
  --input-border: var(--border);
  --input-focus-ring: var(--ring);
  --input-placeholder: var(--muted-foreground);

  /* Navigation */
  --nav-bg: var(--card);
  --nav-fg: var(--card-foreground);
  --nav-border: var(--border);
  --nav-active-bg: var(--primary);
  --nav-active-fg: var(--primary-foreground);

  /* Status Colors */
  --success: #10b981;
  --success-foreground: #f0fdf4;
  --warning: #f59e0b;
  --warning-foreground: #fffbeb;
  --error: var(--destructive);
  --error-foreground: var(--destructive-foreground);
  --info: var(--primary);
  --info-foreground: var(--primary-foreground);
}

/* ========================================
   GLOBAL TYPOGRAPHY & STYLING
   ======================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--foreground);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  transition: background-color var(--transition-base),
    color var(--transition-base);
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.125rem;
}

h5,
h6 {
  font-size: 1rem;
}

/* Buttons */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  font-family: inherit;
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
}

/* Links */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-base);
}

a:hover {
  color: var(--primary);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* Form Elements */
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  border: 1px solid var(--input-border);
  background-color: var(--input-bg);
  color: var(--input-fg);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: border-color var(--transition-base),
    box-shadow var(--transition-base);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--input-focus-ring);
  box-shadow: 0 0 0 3px var(--ring);
}

input::placeholder {
  color: var(--input-placeholder);
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
}

th {
  font-weight: var(--font-weight-semibold);
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  background-color: var(--muted);
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Code Elements */
code,
pre {
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  background-color: var(--muted);
  color: var(--foreground);
  border-radius: var(--radius);
}

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

pre {
  padding: 1rem;
  overflow-x: auto;
}

pre code {
  padding: 0;
  background-color: transparent;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Brand Colors */
.text-brand {
  color: var(--brand);
}

.bg-brand {
  background-color: var(--brand);
  color: var(--brand-foreground);
}

.border-brand {
  border-color: var(--brand);
}

/* Status Classes */
.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-error {
  color: var(--error);
}

.text-info {
  color: var(--info);
}

.bg-success {
  background-color: var(--success);
  color: var(--success-foreground);
}

.bg-warning {
  background-color: var(--warning);
  color: var(--warning-foreground);
}

.bg-error {
  background-color: var(--error);
  color: var(--error-foreground);
}

.bg-info {
  background-color: var(--info);
  color: var(--info-foreground);
}

/* Theme Toggle - No visual change, just capability */
.theme-light {
  --background: #ffffff;
  --foreground: #1a202c;
}

.theme-dark {
  --background: #1a1a1a;
  --foreground: #f8fafc;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* High contrast mode support */
@media (prefers-contrast: more) {
  :root {
    --border: #0a0a0a;
    --muted: #e5e5e5;
  }

  :root.dark {
    --border: #ffffff;
    --muted: #2a2a2a;
  }
}

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

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

/* ========================================
   RESPONSIVE UTILITY
   ======================================== */

/* Container queries for better component styling */
@supports (container-type: inline-size) {
  :root {
    --container-sm: 20rem;
    --container-md: 28rem;
    --container-lg: 32rem;
    --container-xl: 42rem;
  }
}

/* ========================================
   DARK MODE - Using .dark Class Selector
   ======================================== */
:root.dark,
.dark {
  /* Color Palette - Dark Mode */
  --background: #0f172a;
  --foreground: #f8fafc;
  --primary: #60a5fa;
  --primary-foreground: #1e293b;
  --secondary: #334155;
  --secondary-foreground: #f8fafc;
  --accent: #334155;
  --accent-foreground: #f8fafc;
  --border: #334155;
  --input: #334155;
  --ring: #60a5fa;
  --destructive: #fca5a5;
  --destructive-foreground: #7f1d1d;
  --card: #0f172a;
  --card-foreground: #f8fafc;
  --popover: #0f172a;
  --popover-foreground: #f8fafc;
  --muted: #334155;
  --muted-foreground: #cbd5e1;

  /* Tenex Brand Colors - Dark Mode */
  --brand: #4a90e2;
  --brand-foreground: #f8fafc;
  --brandlight: #7ab8ff;
  --branddark: #0d2847;
}

/* ========================================
   DARK MODE - Using @media Preference
   (Fallback for system preference)
   ======================================== */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    /* Color Palette - Dark Mode */
    --background: #0f172a;
    --foreground: #f8fafc;
    --primary: #60a5fa;
    --primary-foreground: #1e293b;
    --secondary: #334155;
    --secondary-foreground: #f8fafc;
    --accent: #334155;
    --accent-foreground: #f8fafc;
    --border: #334155;
    --input: #334155;
    --ring: #60a5fa;
    --destructive: #fca5a5;
    --destructive-foreground: #7f1d1d;
    --card: #0f172a;
    --card-foreground: #f8fafc;
    --popover: #0f172a;
    --popover-foreground: #f8fafc;
    --muted: #334155;
    --muted-foreground: #cbd5e1;

    /* Tenex Brand Colors - Dark Mode */
    --brand: #4a90e2;
    --brand-foreground: #f8fafc;
    --brandlight: #7ab8ff;
    --branddark: #0d2847;
  }
}

/* ========================================
   LIGHT MODE - Explicit Override
   ======================================== */
:root.light {
  /* Color Palette - Light Mode */
  --background: #ffffff;
  --foreground: #1a202c;
  --primary: #3b82f6;
  --primary-foreground: #f8fafc;
  --secondary: #f1f5f9;
  --secondary-foreground: #1e293b;
  --accent: #f1f5f9;
  --accent-foreground: #1e293b;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #3b82f6;
  --destructive: #ef4444;
  --destructive-foreground: #f8fafc;
  --card: #ffffff;
  --card-foreground: #1a202c;
  --popover: #ffffff;
  --popover-foreground: #1a202c;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;

  /* Tenex Brand Colors - Light Mode */
  --brand: #0d2847;
  --brand-foreground: #f8fafc;
  --brandlight: #4a90e2;
  --branddark: #0d2847;
}
