/**
 * GNL WordPress Styles
 * Modern, responsive stylesheet for GNL shortcodes
 * Provides a design system with reusable components
 * Mobile-first responsive approach
 * 
 * IMPORTANT: All styles are scoped to .gnl-wrapper to prevent conflicts with WordPress themes
 */

/* ============================================
   DESIGN TOKENS - Color System
   ============================================ */
.gnl-wrapper {
  /* Primary Colors */
  --gnl-primary: #3182ce;
  --gnl-primary-hover: #2c5aa0;
  --gnl-primary-light: #e6f2ff;
  
  /* Neutral Colors */
  --gnl-gray-900: #2d3748;
  --gnl-gray-800: #4a5568;
  --gnl-gray-700: #718096;
  --gnl-gray-600: #a0aec0;
  --gnl-gray-500: #cbd5e0;
  --gnl-gray-400: #e2e8f0;
  --gnl-gray-300: #f7fafc;
  --gnl-gray-200: #edf2f7;
  --gnl-gray-100: #ffffff;
  
  /* Semantic Colors */
  --gnl-success: #48bb78;
  --gnl-success-bg: #e6fffa;
  --gnl-warning: #ed8936;
  --gnl-danger: #f56565;
  
  /* Spacing Scale */
  --gnl-space-xs: 4px;
  --gnl-space-sm: 8px;
  --gnl-space-md: 12px;
  --gnl-space-lg: 16px;
  --gnl-space-xl: 20px;
  --gnl-space-2xl: 24px;
  --gnl-space-3xl: 32px;
  --gnl-space-4xl: 48px;
  
  /* Typography */
  --gnl-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --gnl-font-size-xs: 11px;
  --gnl-font-size-sm: 12px;
  --gnl-font-size-base: 13px;
  --gnl-font-size-md: 14px;
  --gnl-font-size-lg: 15px;
  --gnl-font-size-xl: 17px;
  --gnl-font-size-2xl: 20px;
  --gnl-font-size-3xl: 24px;
  --gnl-font-size-4xl: 28px;
  
  /* Border Radius */
  --gnl-radius-sm: 6px;
  --gnl-radius-md: 8px;
  --gnl-radius-lg: 12px;
  --gnl-radius-full: 50%;
  
  /* Shadows */
  --gnl-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --gnl-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
  --gnl-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  
  /* Transitions */
  --gnl-transition-fast: 0.15s ease;
  --gnl-transition-base: 0.2s ease;
  --gnl-transition-slow: 0.3s ease;
}

/* ============================================
   BASE RESET & TYPOGRAPHY
   ============================================ */
.gnl-wrapper,
.gnl-wrapper *,
.gnl-wrapper *::before,
.gnl-wrapper *::after {
  box-sizing: border-box;
}

.gnl-wrapper {
  font-family: var(--gnl-font-family);
  color: var(--gnl-gray-900);
  line-height: 1.5;
  /* Reset any inherited styles from WordPress theme */
  all: initial;
  all: revert;
}

/* Re-apply our custom properties after reset */
.gnl-wrapper {
  /* Copy all CSS variables here for scoped use */
  --gnl-primary: #3182ce;
  --gnl-primary-hover: #2c5aa0;
  --gnl-primary-light: #e6f2ff;
  
  --gnl-gray-900: #2d3748;
  --gnl-gray-800: #4a5568;
  --gnl-gray-700: #718096;
  --gnl-gray-600: #a0aec0;
  --gnl-gray-500: #cbd5e0;
  --gnl-gray-400: #e2e8f0;
  --gnl-gray-300: #f7fafc;
  --gnl-gray-200: #edf2f7;
  --gnl-gray-100: #ffffff;
  
  --gnl-success: #48bb78;
  --gnl-success-bg: #e6fffa;
  --gnl-warning: #ed8936;
  --gnl-danger: #f56565;
  
  --gnl-space-xs: 4px;
  --gnl-space-sm: 8px;
  --gnl-space-md: 12px;
  --gnl-space-lg: 16px;
  --gnl-space-xl: 20px;
  --gnl-space-2xl: 24px;
  --gnl-space-3xl: 32px;
  --gnl-space-4xl: 48px;
  
  --gnl-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --gnl-font-size-xs: 11px;
  --gnl-font-size-sm: 12px;
  --gnl-font-size-base: 13px;
  --gnl-font-size-md: 14px;
  --gnl-font-size-lg: 15px;
  --gnl-font-size-xl: 17px;
  --gnl-font-size-2xl: 20px;
  --gnl-font-size-3xl: 24px;
  --gnl-font-size-4xl: 28px;
  
  --gnl-radius-sm: 6px;
  --gnl-radius-md: 8px;
  --gnl-radius-lg: 12px;
  --gnl-radius-full: 50%;
  
  --gnl-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --gnl-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
  --gnl-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  
  --gnl-transition-fast: 0.15s ease;
  --gnl-transition-base: 0.2s ease;
  --gnl-transition-slow: 0.3s ease;
  
  /* Now apply basic styling */
  font-family: var(--gnl-font-family);
  color: var(--gnl-gray-900);
  line-height: 1.5;
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */

/* Main Container */
.gnl-container {
  width: 100%;
  max-width: 1200px;
  margin: var(--gnl-space-xl) auto;
  padding: 0 var(--gnl-space-lg);
}

.gnl-container-wide {
  max-width: 1400px;
}

/* Card Component */
.gnl-card {
  background: var(--gnl-gray-100);
  border-radius: var(--gnl-radius-lg);
  box-shadow: var(--gnl-shadow-md);
  overflow: hidden;
  border: 1px solid var(--gnl-gray-500);
  margin-bottom: var(--gnl-space-xl);
}

/* Card Header */
.gnl-card-header {
  background: var(--gnl-gray-100);
  padding: var(--gnl-space-xl);
  border-bottom: 2px solid var(--gnl-gray-500);
}

.gnl-card-header h2,
.gnl-card-header h3 {
  margin: 0;
  font-weight: 700;
  color: var(--gnl-gray-900);
}

.gnl-card-header h2 {
  font-size: var(--gnl-font-size-4xl);
}

.gnl-card-header h3 {
  font-size: var(--gnl-font-size-2xl);
}

/* Card Body */
.gnl-card-body {
  padding: var(--gnl-space-xl);
  background: var(--gnl-gray-300);
  border-bottom: 1px solid var(--gnl-gray-500);
}

/* ============================================
   TABLE COMPONENTS
   ============================================ */

/* Responsive Table Wrapper */
.gnl-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Base Table Styles */
.gnl-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--gnl-gray-100);
}

.gnl-table thead {
  background: var(--gnl-gray-300);
}

.gnl-table th {
  padding: var(--gnl-space-lg) var(--gnl-space-xl);
  text-align: left;
  font-weight: 600;
  font-size: var(--gnl-font-size-base);
  color: var(--gnl-gray-800);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--gnl-gray-500);
}

.gnl-table th.gnl-text-center {
  text-align: center;
}

.gnl-table th.gnl-text-right {
  text-align: right;
}

.gnl-table tbody tr {
  background: var(--gnl-gray-100);
  transition: background-color var(--gnl-transition-base);
}

.gnl-table tbody tr:hover {
  background: var(--gnl-gray-300);
}

.gnl-table td {
  padding: var(--gnl-space-md) var(--gnl-space-xl);
  font-size: var(--gnl-font-size-md);
  color: var(--gnl-gray-900);
  border: 1px solid var(--gnl-gray-500);
}

.gnl-table tbody tr:last-child td {
  border-bottom: 1px solid var(--gnl-gray-500);
}

/* Compact Table Variant */
.gnl-table-compact th,
.gnl-table-compact td {
  padding: var(--gnl-space-sm) var(--gnl-space-md);
}

/* Striped Table Variant */
.gnl-table-striped tbody tr:nth-child(even) {
  background: var(--gnl-gray-200);
}

/* Borderless Table Variant (for player tables) */
.gnl-table-borderless th,
.gnl-table-borderless td {
  border-right: none;
  border-left: none;
}

.gnl-table-borderless thead {
  border-bottom: 2px solid var(--gnl-gray-500);
}

.gnl-table-borderless tbody tr {
  border-bottom: 1px solid var(--gnl-gray-500);
}

.gnl-table-borderless tbody tr:last-child {
  border-bottom: none;
}

/* Score Table (centered, minimal) */
.gnl-score-table {
  max-width: 400px;
  margin: 0 auto;
  box-shadow: var(--gnl-shadow-sm);
}

.gnl-score-table th,
.gnl-score-table td {
  text-align: center;
  padding: var(--gnl-space-md) var(--gnl-space-xl);
}

.gnl-score-table td {
  font-size: var(--gnl-font-size-3xl);
  font-weight: 700;
}

/* ============================================
   TEAM & PLAYER COMPONENTS
   ============================================ */

/* Team Header with Icon */
.gnl-team-header {
  display: flex;
  align-items: center;
  gap: var(--gnl-space-lg);
  margin-bottom: var(--gnl-space-2xl);
  padding: var(--gnl-space-xl);
  background: var(--gnl-gray-100);
  border-bottom: 2px solid var(--gnl-gray-400);
}

.gnl-team-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--gnl-radius-full);
  object-fit: cover;
  background: var(--gnl-gray-100);
  border: 2px solid var(--gnl-gray-400);
  flex-shrink: 0;
}

.gnl-team-name {
  margin: 0;
  font-size: var(--gnl-font-size-4xl);
  font-weight: 700;
  color: var(--gnl-gray-900);
  letter-spacing: 0.5px;
}

.gnl-team-name-short {
  font-size: var(--gnl-font-size-2xl);
  font-weight: 500;
  color: var(--gnl-gray-700);
}

/* Race Icon */
.gnl-race-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--gnl-radius-full);
  object-fit: cover;
}

/* ============================================
   SERIES/MATCH COMPONENTS
   ============================================ */

/* Match Versus Header */
.gnl-match-versus {
  font-weight: 400;
  color: var(--gnl-gray-600);
  padding: 0 var(--gnl-space-sm);
}

/* Score Display */
.gnl-score {
  font-size: var(--gnl-font-size-lg);
  font-weight: 600;
}

.gnl-score-winner {
  color: var(--gnl-gray-900);
  font-weight: 700;
}

.gnl-score-loser {
  color: var(--gnl-gray-700);
}

.gnl-score-highlight {
  background: var(--gnl-success-bg);
}

/* Toggle/Expandable Section */
.gnl-toggle {
  padding: var(--gnl-space-lg) var(--gnl-space-xl);
  background: var(--gnl-gray-100);
  border-bottom: 1px solid var(--gnl-gray-400);
  font-weight: 600;
  color: var(--gnl-gray-800);
  font-size: var(--gnl-font-size-md);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--gnl-transition-base);
}

.gnl-toggle:hover {
  background: var(--gnl-gray-200);
}

.gnl-toggle-icon {
  display: inline-block;
  transition: transform var(--gnl-transition-slow);
  margin-right: var(--gnl-space-sm);
}

.gnl-toggle-icon.expanded {
  transform: rotate(90deg);
}

.gnl-expandable-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--gnl-transition-slow);
  background: var(--gnl-gray-100);
}

.gnl-expandable-content.expanded {
  max-height: 2000px;
}

/* Empty State */
.gnl-empty-state {
  padding: var(--gnl-space-xl);
  text-align: center;
  color: var(--gnl-gray-600);
  font-style: italic;
  background: var(--gnl-gray-300);
  border: 1px solid var(--gnl-gray-400);
  border-radius: var(--gnl-radius-md);
}

/* ============================================
   BADGE & PILL COMPONENTS
   ============================================ */

.gnl-badge {
  display: inline-block;
  padding: var(--gnl-space-xs) var(--gnl-space-md);
  border-radius: var(--gnl-radius-lg);
  font-size: var(--gnl-font-size-sm);
  font-weight: 700;
  white-space: nowrap;
}

.gnl-badge-primary {
  background: var(--gnl-gray-800);
  color: var(--gnl-gray-100);
}

.gnl-badge-success {
  background: var(--gnl-success);
  color: var(--gnl-gray-100);
}

.gnl-badge-mmr {
  background: var(--gnl-gray-800);
  color: var(--gnl-gray-100);
}

/* Rank Medals */
.gnl-rank-medal {
  font-size: var(--gnl-font-size-2xl);
}

.gnl-rank-number {
  color: var(--gnl-gray-700);
  font-weight: 500;
}

/* ============================================
   BUTTON COMPONENTS
   ============================================ */

.gnl-btn {
  display: inline-block;
  padding: var(--gnl-space-sm) var(--gnl-space-md);
  border-radius: var(--gnl-radius-sm);
  font-size: var(--gnl-font-size-xs);
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: background-color var(--gnl-transition-base);
  border: none;
  cursor: pointer;
}

.gnl-btn-primary {
  background: var(--gnl-primary);
  color: var(--gnl-gray-100);
}

.gnl-btn-primary:hover {
  background: var(--gnl-primary-hover);
  color: var(--gnl-gray-100);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Text Alignment */
.gnl-text-left { text-align: left; }
.gnl-text-center { text-align: center; }
.gnl-text-right { text-align: right; }

/* Font Weights */
.gnl-font-normal { font-weight: 400; }
.gnl-font-medium { font-weight: 500; }
.gnl-font-semibold { font-weight: 600; }
.gnl-font-bold { font-weight: 700; }

/* Text Colors */
.gnl-text-primary { color: var(--gnl-gray-900); }
.gnl-text-secondary { color: var(--gnl-gray-700); }
.gnl-text-muted { color: var(--gnl-gray-600); }
.gnl-text-light { color: var(--gnl-gray-500); }

/* Spacing Utilities */
.gnl-mt-0 { margin-top: 0; }
.gnl-mt-sm { margin-top: var(--gnl-space-sm); }
.gnl-mt-md { margin-top: var(--gnl-space-md); }
.gnl-mt-lg { margin-top: var(--gnl-space-lg); }
.gnl-mt-xl { margin-top: var(--gnl-space-xl); }

.gnl-mb-0 { margin-bottom: 0; }
.gnl-mb-sm { margin-bottom: var(--gnl-space-sm); }
.gnl-mb-md { margin-bottom: var(--gnl-space-md); }
.gnl-mb-lg { margin-bottom: var(--gnl-space-lg); }
.gnl-mb-xl { margin-bottom: var(--gnl-space-xl); }

.gnl-p-0 { padding: 0; }
.gnl-p-sm { padding: var(--gnl-space-sm); }
.gnl-p-md { padding: var(--gnl-space-md); }
.gnl-p-lg { padding: var(--gnl-space-lg); }
.gnl-p-xl { padding: var(--gnl-space-xl); }

/* Display Utilities */
.gnl-hidden { display: none; }
.gnl-block { display: block; }
.gnl-inline-block { display: inline-block; }
.gnl-flex { display: flex; }

/* Flex Utilities */
.gnl-flex-row { flex-direction: row; }
.gnl-flex-col { flex-direction: column; }
.gnl-items-center { align-items: center; }
.gnl-justify-center { justify-content: center; }
.gnl-justify-between { justify-content: space-between; }
.gnl-gap-sm { gap: var(--gnl-space-sm); }
.gnl-gap-md { gap: var(--gnl-space-md); }
.gnl-gap-lg { gap: var(--gnl-space-lg); }

/* Width Utilities */
.gnl-w-full { width: 100%; }
.gnl-w-auto { width: auto; }

/* ============================================
   RESPONSIVE DESIGN - Mobile First
   ============================================ */

/* Small devices (phones, less than 640px) */
@media (max-width: 639px) {
  .gnl-container {
    padding: 0 var(--gnl-space-sm);
    margin: var(--gnl-space-md) auto;
  }
  
  .gnl-card-header,
  .gnl-card-body {
    padding: var(--gnl-space-md);
  }
  
  .gnl-table th,
  .gnl-table td {
    padding: var(--gnl-space-sm) var(--gnl-space-md);
    font-size: var(--gnl-font-size-sm);
  }
  
  .gnl-team-icon {
    width: 40px;
    height: 40px;
  }
  
  .gnl-team-name {
    font-size: var(--gnl-font-size-2xl);
  }
  
  /* Hide less important columns on mobile */
  .gnl-hide-mobile {
    display: none;
  }
  
  /* Stack elements vertically on mobile */
  .gnl-mobile-stack {
    flex-direction: column;
  }
  
  /* Reduce font sizes on mobile */
  .gnl-card-header h2 {
    font-size: var(--gnl-font-size-2xl);
  }
  
  .gnl-card-header h3 {
    font-size: var(--gnl-font-size-lg);
  }
}

/* Medium devices (tablets, 640px and up) */
@media (min-width: 640px) {
  .gnl-sm-block { display: block; }
  .gnl-sm-hidden { display: none; }
}

/* Large devices (desktops, 1024px and up) */
@media (min-width: 1024px) {
  .gnl-lg-block { display: block; }
  .gnl-lg-hidden { display: none; }
  
  .gnl-container {
    padding: 0 var(--gnl-space-2xl);
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus styles for keyboard navigation */
.gnl-wrapper .gnl-btn:focus,
.gnl-wrapper .gnl-toggle:focus {
  outline: 2px solid var(--gnl-primary);
  outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .gnl-wrapper *,
  .gnl-wrapper *::before,
  .gnl-wrapper *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .gnl-wrapper {
    --gnl-gray-900: #000000;
    --gnl-gray-100: #ffffff;
  }
  
  .gnl-wrapper .gnl-card,
  .gnl-wrapper .gnl-table {
    border: 2px solid currentColor;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .gnl-wrapper .gnl-toggle,
  .gnl-wrapper .gnl-btn {
    display: none;
  }
  
  .gnl-wrapper .gnl-expandable-content {
    max-height: none !important;
  }
  
  .gnl-wrapper .gnl-card {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .gnl-wrapper .gnl-table tbody tr:hover {
    background: transparent;
  }
}
