/* ==========================================================================
   SABRESMETRICS DESIGN SYSTEM
   Reusable CSS variables and utility classes for consistent styling
   ========================================================================== */

:root {
  /* ==========================================================================
     Brand Colors
     ========================================================================== */
  --sabres-navy: #003087;
  --sabres-navy-dark: #002060;
  --sabres-navy-light: #0047ab;
  --sabres-gold: #fcb514;
  --sabres-gold-dark: #e5a312;
  --sabres-gold-light: #ffd54f;

  /* RGB values for use with rgba() */
  --sabres-navy-rgb: 0, 48, 135;
  --sabres-gold-rgb: 252, 181, 20;
  --white-rgb: 255, 255, 255;
  --black-rgb: 0, 0, 0;

  /* ==========================================================================
     Neutral Colors (Tailwind-inspired gray scale)
     ========================================================================== */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* ==========================================================================
     Semantic Colors
     ========================================================================== */
  --color-success: #059669;
  --color-success-light: #d1fae5;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-info: #0284c7;
  --color-info-light: #e0f2fe;

  /* ==========================================================================
     Spacing Scale (4px base)
     ========================================================================== */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ==========================================================================
     Typography
     ========================================================================== */
  --font-sans:
    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --font-brand: 'IBM Plex Sans', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, monospace;

  /* Font Sizes */
  --text-xs: 0.75rem; /* 12px */
  --text-sm: 0.875rem; /* 14px */
  --text-base: 1rem; /* 16px */
  --text-lg: 1.125rem; /* 18px */
  --text-xl: 1.25rem; /* 20px */
  --text-2xl: 1.5rem; /* 24px */
  --text-3xl: 1.875rem; /* 30px */
  --text-4xl: 2.25rem; /* 36px */

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

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

  /* ==========================================================================
     Border Radius
     ========================================================================== */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ==========================================================================
     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), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* ==========================================================================
     Transitions
     ========================================================================== */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ==========================================================================
   Global Base Styles
   ========================================================================== */

html,
body {
  font-family: var(--font-sans);
}

body {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--gray-800);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  color: var(--sabres-navy);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Cards */
.card-modern {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.card-modern-lg {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sabres-gold);
  color: var(--sabres-navy);
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast);
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--sabres-gold-dark);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sabres-navy);
  color: white;
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast);
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--sabres-navy-dark);
  transform: translateY(-1px);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--sabres-navy);
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  border: 2px solid var(--sabres-navy);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-outline:hover {
  background: var(--sabres-navy);
  color: white;
}

/* Form Inputs */
.input-modern {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: white;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.input-modern:focus {
  outline: none;
  border-color: var(--sabres-navy);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
}

.input-modern::placeholder {
  color: var(--gray-400);
}

/* Text Utilities */
.text-primary {
  color: var(--sabres-navy);
}

.text-accent {
  color: var(--sabres-gold);
}

.text-muted {
  color: var(--gray-500);
}

/* Background Utilities */
.bg-primary {
  background-color: var(--sabres-navy);
}

.bg-accent {
  background-color: var(--sabres-gold);
}

.bg-light {
  background-color: var(--gray-50);
}

/* ==========================================================================
   Width Utilities
   ========================================================================== */
.w-50 {
  width: 50px;
}
.w-60 {
  width: 60px;
}
.w-80 {
  width: 80px;
}
.w-100 {
  width: 100px;
}
.w-150 {
  width: 150px;
}
.w-200 {
  width: 200px;
}
.w-250 {
  width: 250px;
}
.w-350 {
  width: 350px;
}

.min-w-200 {
  min-width: 200px;
}
.min-w-250 {
  min-width: 250px;
}

.max-w-400 {
  max-width: 400px;
}
.max-w-500 {
  max-width: 500px;
}
.max-w-700 {
  max-width: 700px;
}

/* ==========================================================================
   Typography Utilities
   ========================================================================== */
.font-size-xs {
  font-size: 0.75em;
}
.font-size-sm {
  font-size: 0.8em;
}
.font-size-md {
  font-size: 0.9em;
}
.font-size-lg {
  font-size: 1.1em;
}
.font-weight-normal {
  font-weight: 400;
}
.font-weight-medium {
  font-weight: 500;
}
.font-weight-semibold {
  font-weight: 600;
}
.font-weight-bold {
  font-weight: 700;
}

/* ==========================================================================
   Display Utilities
   ========================================================================== */
.cursor-pointer {
  cursor: pointer;
}
.whitespace-nowrap {
  white-space: nowrap;
}
.overflow-auto {
  overflow: auto;
}
.overflow-hidden {
  overflow: hidden;
}
.visibility-hidden {
  visibility: hidden;
}

/* ==========================================================================
   Border Utilities
   ========================================================================== */
.border-left-none {
  border-left: none !important;
}
.border-right-none {
  border-right: none !important;
}
.border-bottom-none {
  border-bottom: none !important;
}

/* ==========================================================================
   Legend Colors (for table captions)
   ========================================================================== */
.legend-blue {
  color: #67a9cf;
}
.legend-red {
  color: #ef8a62;
}
.legend-green {
  color: #7fbf7b;
}
.legend-purple {
  color: #af8dc3;
}

/* ==========================================================================
   Text Color Utilities
   ========================================================================== */
.text-sabres-gold {
  color: var(--sabres-gold) !important;
}
.text-sabres-navy {
  color: var(--sabres-navy) !important;
}

/* ==========================================================================
   Table Column Width Classes
   ========================================================================== */
.col-w-narrow {
  width: 50px;
}
.col-w-medium {
  width: 80px;
}
.col-w-wide {
  width: 150px;
}
.col-w-extra-wide {
  width: 200px;
}

/* ==========================================================================
   Responsive Breakpoints (CSS Custom Properties for reference)
   Bootstrap 5 aligned breakpoints:
   - xs: < 576px (phones portrait)
   - sm: >= 576px (phones landscape)
   - md: >= 768px (tablets)
   - lg: >= 992px (desktops)
   - xl: >= 1200px (large desktops)
   - xxl: >= 1400px (extra large desktops)
   ========================================================================== */

/* Responsive Typography */
@media (max-width: 767.98px) {
  :root {
    --text-base: 0.9375rem; /* 15px on mobile */
  }

  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.5rem;
  }
  h3 {
    font-size: 1.25rem;
  }
}

/* Touch-friendly minimum sizes */
@media (hover: none) and (pointer: coarse) {
  .btn-primary,
  .btn-secondary,
  .btn-outline,
  .nav-link,
  .dropdown-item {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ==========================================================================
   Responsive Table Container
   ========================================================================== */
.table-responsive-custom {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive-custom table {
  min-width: 100%;
}

/* Scroll indicator shadow on mobile */
@media (max-width: 767.98px) {
  .table-responsive-custom {
    position: relative;
  }

  .table-responsive-custom::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.05), transparent);
    pointer-events: none;
  }
}

/* ==========================================================================
   Sabres-Themed Table Headers
   Usage: Add .table-sabres-header to table element
   ========================================================================== */
.table-sabres-header thead tr {
  background: linear-gradient(
    135deg,
    var(--sabres-navy) 0%,
    var(--sabres-navy-dark) 100%
  ) !important;
}

.table-sabres-header thead th {
  background: transparent !important;
  color: var(--sabres-gold) !important;
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  border-color: var(--sabres-navy-dark) !important;
}

/* Super headers (white bg, blue text) */
.table-sabres-header thead tr.super-header {
  background: #ffffff !important;
}

.table-sabres-header thead tr.super-header th {
  color: var(--sabres-navy);
  border-bottom: 2px solid var(--sabres-navy);
}

/* Filter row styling */
.table-filter-row,
.table-sabres-header thead tr.filters {
  background: #e4ebf4 !important;
}

.table-sabres-header thead tr.filters th {
  color: var(--sabres-navy);
  background: #e4ebf4 !important;
}

/* DataTables sort arrows - gold color */
.table-sabres-header thead th.sorting::before,
.table-sabres-header thead th.sorting::after,
.table-sabres-header thead th.sorting_asc::before,
.table-sabres-header thead th.sorting_asc::after,
.table-sabres-header thead th.sorting_desc::before,
.table-sabres-header thead th.sorting_desc::after {
  filter: brightness(0) saturate(100%) invert(79%) sepia(46%) saturate(1000%)
    hue-rotate(358deg) brightness(101%) contrast(97%);
  opacity: 0.5;
}

.table-sabres-header thead th.sorting_asc::after,
.table-sabres-header thead th.sorting_desc::before {
  opacity: 1;
}

/* ==========================================================================
   Centered Form Card Layout
   Usage: Wrap form in .centered-form-container > .form-card
   ========================================================================== */
.centered-form-container {
  background-color: var(--gray-100);
  min-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-8) var(--space-4);
}

.form-card {
  background: #ffffff;
  padding: var(--space-8) var(--space-10);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
}

.form-card-sm {
  max-width: 500px;
}

.form-card-md {
  max-width: 600px;
}

.form-card-lg {
  max-width: 700px;
}

/* Results card below form */
.results-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  margin-top: var(--space-6);
  width: 100%;
  max-width: 1000px;
}

/* Form title styling */
.form-card .form-title {
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  color: var(--sabres-navy);
  margin-bottom: var(--space-6);
}

/* Responsive form adjustments */
@media (max-width: 767.98px) {
  .centered-form-container {
    padding: var(--space-4) var(--space-3);
  }

  .form-card {
    padding: var(--space-5) var(--space-4);
  }

  .results-card {
    padding: var(--space-4);
  }
}

/* ==========================================================================
   Hover Tooltip Pattern
   Usage: Add .tooltip-trigger to parent, .tooltip-content to popup
   ========================================================================== */
.tooltip-trigger {
  position: relative;
}

.tooltip-trigger .tooltip-content {
  position: absolute;
  top: 0;
  transform: translateY(70%) scale(0);
  transition: transform var(--transition-fast);
  transform-origin: right;
  display: inline;
  background: #add8e6;
  z-index: 20;
  overflow-wrap: break-word;
  hyphens: manual;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  white-space: normal;
  min-width: 200px;
  max-width: 400px;
}

.tooltip-trigger:hover .tooltip-content {
  transform: translateY(-20%) scale(1) translateX(5%);
}

/* Touch device support - show on focus/active instead of hover */
@media (hover: none) and (pointer: coarse) {
  .tooltip-trigger:hover .tooltip-content {
    transform: translateY(70%) scale(0);
  }

  .tooltip-trigger:focus .tooltip-content,
  .tooltip-trigger:active .tooltip-content {
    transform: translateY(-20%) scale(1) translateX(5%);
  }
}

/* ==========================================================================
   Badge Variants (extends Bootstrap)
   ========================================================================== */
.badge.bg-purple {
  background-color: #6f42c1 !important;
}

/* ==========================================================================
   Select2 Responsive Fixes
   ========================================================================== */
.select2-container {
  min-width: 100% !important;
}

@media (max-width: 767.98px) {
  .select2-container .select2-selection--single {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom */
  }

  .select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 42px;
  }

  .select2-container .select2-selection--single .select2-selection__arrow {
    height: 42px;
  }
}
