/* Premium Mobile-First Leaderboard Styles */

/* ===== BASE MOBILE STYLES (320px+) ===== */
.leaderboard-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.leaderboard-controls .row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.leaderboard-controls .col-md-6,
.leaderboard-controls .col-md-3,
.leaderboard-controls .col-12 {
  width: 100%;
}

.leaderboard-results-info {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 8px;
  text-align: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Premium Input Styles */
.leaderboard-controls .form-control,
.leaderboard-controls .form-select {
  background: linear-gradient(135deg, rgba(26, 33, 56, 0.95) 0%, rgba(26, 33, 56, 0.85) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.leaderboard-controls .form-control:focus,
.leaderboard-controls .form-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12), 0 4px 12px rgba(0, 0, 0, 0.2);
  background: rgba(26, 33, 56, 1);
  transform: translateY(-1px);
  color: var(--text-primary);
}

.leaderboard-controls .form-control::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Premium Tabs - Mobile First */
.sessions-stats-tabs {
  width: 100%;
}

.tabs-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(26, 33, 56, 0.8) 0%, rgba(26, 33, 56, 0.6) 100%);
  padding: 10px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.tabs-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  opacity: 0.5;
}

.tab-btn {
  flex: 1;
  min-width: calc(50% - 4px);
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.5);
  transform: scaleX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.1) 100%);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transform: translateY(-2px);
  z-index: 1;
  font-weight: 700;
  text-shadow: none;
}

.tab-btn.active::before {
  left: 0;
}

.tab-btn.active::after {
  transform: scaleX(1);
}

.tab-btn:not(.active):hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

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

.tab-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab-btn:focus:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--text-primary);
}

.tab-btn:focus.active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  color: var(--text-primary);
}

.tab-btn span {
  position: relative;
  z-index: 1;
  color: inherit;
}

.tab-btn.active span {
  color: var(--text-primary);
}

/* Premium Table Container */
.leaderboard-table-container {
  background: linear-gradient(135deg, rgba(26, 33, 56, 0.95) 0%, rgba(26, 33, 56, 0.9) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  overflow: hidden;
  position: relative;
}

.leaderboard-table-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  z-index: 1;
}

/* Mobile Table Styles - Card Layout */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.leaderboard-table thead {
  display: none;
}

.leaderboard-table tbody {
  display: block;
  width: 100%;
  padding: 8px;
}

.leaderboard-table tr {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(26, 33, 56, 0.9) 0%, rgba(26, 33, 56, 0.7) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.leaderboard-table tr::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.leaderboard-table tr::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.leaderboard-table tr:hover::before,
.leaderboard-table tr.text-gold::before {
  opacity: 1;
}

.leaderboard-table tr:hover::after {
  opacity: 1;
}

.leaderboard-table tr:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.leaderboard-table tr.text-gold {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(26, 33, 56, 0.85) 100%);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.leaderboard-table tr.text-gold::before {
  opacity: 1;
  width: 6px;
}

.leaderboard-table td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  padding-left: 0;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
  min-height: 44px;
  gap: 12px;
}

.leaderboard-table td:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.leaderboard-table td::before {
  content: attr(data-label);
  position: static;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.85;
  min-width: 120px;
  text-align: left;
  transform: none;
  top: auto;
}

.leaderboard-table td:first-child {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  padding-top: 0;
}

.leaderboard-table td:first-child::before {
  min-width: 80px;
}

.leaderboard-table td:nth-child(2) {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.leaderboard-table td:nth-child(2)::before {
  min-width: 100px;
}

/* Premium Rank Badges */
.leaderboard-table td:first-child::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  margin-left: 10px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* Your Rank Container - Premium */
.leaderboard-your-rank-container.card-body {
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(26, 33, 56, 0.9) 100%);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  position: relative;
  overflow: hidden;
}

.leaderboard-your-rank-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
}

.leaderboard-your-rank-container h4 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.leaderboard-your-rank-container.hidden {
  display: none;
}

/* Premium Pagination */
.leaderboard-pagination-container {
  display: flex;
  justify-content: center;
  margin: 28px 0 16px;
  padding: 0 12px;
}

.lb-pagination {
  display: inline-flex;
  gap: 10px;
  background: linear-gradient(135deg, rgba(26, 33, 56, 0.95) 0%, rgba(26, 33, 56, 0.85) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  flex-wrap: wrap;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.lb-pagination::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  opacity: 0.6;
}

.lb-page-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.lb-page-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
}

.lb-page-btn.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.1) 100%);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transform: translateY(-2px);
  font-weight: 700;
  text-shadow: none;
}

.lb-page-btn:active:not(:disabled) {
  transform: translateY(0);
}

.lb-page-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.lb-page-btn:focus:not(.active):not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--text-primary);
}

.lb-page-btn:focus.active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  color: var(--text-primary);
}

.lb-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* Loading State */
.tab-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.tab-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.tab-loading p {
  font-size: 1rem;
  margin: 0;
}

/* ===== TABLET STYLES (768px+) ===== */
@media (min-width: 768px) {
  .leaderboard-controls {
    gap: 16px;
  }

  .leaderboard-controls .row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
  }

  .leaderboard-controls .col-md-6 {
    flex: 0 0 calc(50% - 8px);
    max-width: calc(50% - 8px);
  }

  .leaderboard-controls .col-md-3 {
    flex: 0 0 calc(33.333% - 11px);
    max-width: calc(33.333% - 11px);
  }

  .leaderboard-controls .col-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .tabs-header {
    gap: 12px;
    padding: 12px;
  }

  .tab-btn {
    min-width: auto;
    flex: 1;
    padding: 16px 24px;
    font-size: 0.95rem;
  }

  .leaderboard-results-info {
    text-align: left;
    padding: 10px 16px;
  }

  .leaderboard-table tbody {
    padding: 12px;
  }

  /* Tablet: Show table as table but with better spacing */
  .leaderboard-table thead {
    display: table-header-group;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(26, 33, 56, 0.8) 100%);
  }

  .leaderboard-table thead th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  }

  .leaderboard-table tbody {
    display: table-row-group;
  }

  .leaderboard-table tr {
    display: table-row;
    margin-bottom: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .leaderboard-table tr::before {
    display: none;
  }

  .leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
    box-shadow: none;
    border-color: transparent;
  }

  .leaderboard-table tr.text-gold {
    background: rgba(255, 255, 255, 0.08);
    border-color: transparent;
    box-shadow: none;
  }

  .leaderboard-table td {
    display: table-cell;
    padding: 16px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.9rem;
  }

  .leaderboard-table td::before {
    display: none;
  }

  .leaderboard-table td:first-child {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    padding-left: 16px;
  }

  .leaderboard-table td:first-child::after {
    display: none;
  }

  .leaderboard-table td:nth-child(2) {
    font-weight: 600;
    font-size: 0.95rem;
  }

  .total-time-col,
  .total-correct-col,
  .total-attempts-col,
  .total-sessions-col {
    display: table-cell;
  }
}

/* ===== DESKTOP STYLES (1024px+) ===== */
@media (min-width: 1024px) {
  .leaderboard-controls {
    gap: 16px;
  }

  .tabs-header {
    gap: 16px;
    padding: 12px;
  }

  .tab-btn {
    padding: 16px 24px;
    font-size: 1rem;
  }

  .leaderboard-table-container {
    border-radius: 20px;
  }

  .leaderboard-table thead th {
    padding: 20px 16px;
    font-size: 0.9rem;
  }

  .leaderboard-table td {
    padding: 20px 16px;
    font-size: 0.95rem;
  }

  .leaderboard-your-rank-container.card-body {
    padding: 28px;
  }

  .leaderboard-your-rank-container h4 {
    font-size: 1.5rem;
  }

  .lb-pagination {
    gap: 10px;
    padding: 10px;
  }

  .lb-page-btn {
    padding: 12px 18px;
    font-size: 1rem;
    min-width: 48px;
    min-height: 48px;
  }
}

/* ===== LARGE DESKTOP STYLES (1440px+) ===== */
@media (min-width: 1440px) {
  .leaderboard-table thead th {
    padding: 24px 20px;
  }

  .leaderboard-table td {
    padding: 24px 20px;
    font-size: 1rem;
  }
}

/* Achievement Badges Premium Styling */
.plan-badge {
  display: inline-block;
  margin: 0 4px;
  font-size: 1.2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.2s ease;
}

.plan-badge:hover {
  transform: scale(1.2) rotate(5deg);
}

/* Text Gold Class */
/* Text Highlight Class (for user's own row) */
.text-highlight {
  color: var(--text-primary) !important;
}

.text-highlight td {
  color: var(--text-primary) !important;
}

/* Keep text-gold for backward compatibility */
.text-gold {
  color: var(--text-primary) !important;
}

.text-gold td {
  color: var(--text-primary) !important;
}

/* Smooth Transitions */
* {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
