/* ABOUTME: Modern DataTable styling with clean aesthetics and glass morphism */
/* ABOUTME: Overrides Bootstrap 3 DataTables styles for contemporary look */

/* ============================================
   1. CSS Variables - Table Theme
   ============================================ */
:root {
  /* Table Colors */
  --table-bg: rgba(64, 64, 64, 0.2);
  --table-header-bg: rgba(0, 0, 0, 0.85);
  --table-header-text: #ffffff;
  --table-border: rgba(0, 0, 0, 0.1);
  --table-stripe-bg: rgba(0, 0, 0, 0.02);
  --table-hover-bg: rgba(59, 130, 246, 0.1);
  --table-text: #2c2c2c;
  --table-shadow: rgba(0, 0, 0, 0.1);

  /* Interactive States */
  --table-focus-color: #3b82f6;
  --table-success: #10b981;
  --table-warning: #f59e0b;
  --table-danger: #ef4444;

  /* Spacing */
  --table-padding: 1rem;
  --table-padding-sm: 0.75rem;

  /* Typography */
  --table-font-size: 0.95rem;
  --table-font-weight: 400;
  --table-header-font-weight: 600;
}

/* ============================================
   2. Table Container & Wrapper
   ============================================ */
.container {
  background: none !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
  padding: 1.5rem;
  box-shadow: none;
  max-width: 100%;
  width: 100%;
}

.dataTables_wrapper {
  background: rgba(64, 64, 64, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px var(--table-shadow),
              0 2px 4px -1px var(--table-shadow);
  margin-bottom: 2rem;
}

/* Table responsive wrapper */
.table-responsive {
  border-radius: 8px;
  overflow: hidden;
}

/* ============================================
   3. Table Base Styles
   ============================================ */
.table {
  width: 100% !important;
  margin-bottom: 0 !important;
  border-collapse: separate !important;
  border-spacing: 0;
  font-size: var(--table-font-size);
  color: var(--table-text);
}

.table > tbody > tr,
.table tbody tr {
  background-color: #ffffff !important;
}

.table-striped > tbody > tr:nth-of-type(odd),
.table-striped tbody tr:nth-of-type(odd) {
  background-color: #f5f5f5 !important;
}

.table-bordered,
.table-bordered > thead > tr > th,
.table-bordered > tbody > tr > td {
  border: 1px solid var(--table-border) !important;
}

/* ============================================
   4. Table Header
   ============================================ */
.table > thead > tr > th,
table thead th {
  background: var(--table-header-bg) !important;
  color: var(--table-header-text) !important;
  font-weight: var(--table-header-font-weight);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  padding: var(--table-padding) !important;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1) !important;
  position: relative;
  vertical-align: middle;
}

/* First header cell rounded corner */
.table > thead > tr > th:first-child,
table thead th:first-child {
  border-top-left-radius: 8px;
}

/* Last header cell rounded corner */
.table > thead > tr > th:last-child,
table thead th:last-child {
  border-top-right-radius: 8px;
}

/* DataTables sorting indicators */
.table > thead > tr > th.sorting,
.table > thead > tr > th.sorting_asc,
.table > thead > tr > th.sorting_desc {
  cursor: pointer;
  position: relative;
  padding-right: 2.5rem !important;
}

.table > thead > tr > th.sorting:after,
.table > thead > tr > th.sorting_asc:after,
.table > thead > tr > th.sorting_desc:after {
  position: absolute;
  right: 0.75rem;
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  opacity: 0.5;
  font-size: 0.75rem;
}

.table > thead > tr > th.sorting:after {
  content: "\f0dc"; /* fa-sort */
}

.table > thead > tr > th.sorting_asc:after {
  content: "\f0de"; /* fa-sort-up */
  opacity: 1;
  color: var(--table-focus-color);
}

.table > thead > tr > th.sorting_desc:after {
  content: "\f0dd"; /* fa-sort-down */
  opacity: 1;
  color: var(--table-focus-color);
}

/* ============================================
   5. Table Body & Cells
   ============================================ */
.table > tbody > tr > td,
table tbody td {
  padding: var(--table-padding-sm) var(--table-padding) !important;
  vertical-align: middle;
  border-color: var(--table-border) !important;
}

/* Hover state - no default hover effects, controlled by page-specific CSS */
.table > tbody > tr:hover,
.table-hover > tbody > tr:hover,
table tbody tr:hover {
  background-color: inherit;
}

.table > tbody > tr > td:hover,
table tbody td:hover {
  background-color: inherit;
}

/* Active/Selected row */
.table > tbody > tr.active,
.table > tbody > tr.info,
table tbody tr.info {
  background-color: rgba(255, 220, 180, 0.4) !important;
}

/* ============================================
   6. DataTables Controls
   ============================================ */

/* Length selector */
.dataTables_length {
  margin-bottom: 1rem;
}

.dataTables_length label {
  font-weight: 500;
  color: var(--table-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dataTables_length select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--table-border);
  border-radius: 6px;
  background: white;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.dataTables_length select:focus {
  outline: none;
  border-color: var(--table-focus-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Search filter */
.dataTables_filter {
  margin-bottom: 1rem;
}

.dataTables_filter label {
  font-weight: 500;
  color: var(--table-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dataTables_filter input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--table-border);
  border-radius: 6px;
  background: white;
  font-size: 0.9rem;
  transition: all 0.2s;
  min-width: 250px;
}

.dataTables_filter input:focus {
  outline: none;
  border-color: var(--table-focus-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Info text */
.dataTables_info {
  padding: 0.75rem 0;
  color: var(--table-text);
  font-size: 0.9rem;
}

/* Pagination */
.dataTables_paginate {
  padding: 0.75rem 0;
}

.dataTables_paginate .pagination {
  margin: 0;
  display: flex;
  gap: 0.25rem;
}

.dataTables_paginate .pagination > li > a,
.dataTables_paginate .pagination > li > span {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--table-border);
  border-radius: 6px;
  background: white;
  color: var(--table-text);
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.dataTables_paginate .pagination > li > a:hover {
  background: var(--table-hover-bg);
  border-color: var(--table-focus-color);
  color: var(--table-focus-color);
}

.dataTables_paginate .pagination > .active > a,
.dataTables_paginate .pagination > .active > span {
  background: var(--table-focus-color);
  border-color: var(--table-focus-color);
  color: white;
}

.dataTables_paginate .pagination > .disabled > a,
.dataTables_paginate .pagination > .disabled > span {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   7. Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
  .dataTables_wrapper {
    padding: 1rem;
  }

  .table > thead > tr > th,
  .table > tbody > tr > td {
    padding: 0.5rem !important;
    font-size: 0.85rem;
  }

  .dataTables_filter input {
    min-width: 150px;
  }

  /* Stack controls vertically on mobile */
  .dataTables_length,
  .dataTables_filter {
    margin-bottom: 0.75rem;
  }

  .dataTables_length label,
  .dataTables_filter label {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================
   8. Custom Score Cell Styles
   ============================================ */
.score-cell {
  font-weight: 500;
}

/* Workout header clickable */
.workout-header {
  cursor: pointer;
  transition: all 0.2s;
}

.workout-header:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

.info-icon {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.workout-header:hover .info-icon {
  opacity: 1;
}

/* Cap indicator */
.cap-indicator {
  color: var(--table-warning);
  font-weight: 600;
  font-size: 0.8em;
}

/* ============================================
   9. Loading & Processing States
   ============================================ */
.dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px var(--table-shadow);
  font-weight: 500;
  color: var(--table-text);
}

/* ============================================
   10. Empty State
   ============================================ */
.dataTables_empty {
  padding: 3rem 1rem !important;
  text-align: center;
  color: rgba(44, 44, 44, 0.5);
  font-style: italic;
}

/* ============================================
   11. Fixed Header Enhancement
   ============================================ */
.fixedHeader-floating {
  background: var(--table-header-bg) !important;
  box-shadow: 0 4px 6px var(--table-shadow);
}

/* ============================================
   12. Competition Header Styling
   ============================================ */
header {
  background: none !important;
  box-shadow: none !important;
  border: none !important;
}

.container > header {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

#competitionHeader {
  text-align: center;
  margin-bottom: 1rem;
  padding: 1rem 1rem;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
}

#competitionTitle {
  font-size: 2.5rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#headerImage {
  max-width: none;
  width: auto;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  margin: 0 auto;
  display: block;
}

/* ============================================
   13. Form Controls Enhancement
   ============================================ */
.form-control {
  border: 1px solid var(--table-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.2s;
  background: white;
  height: auto;
  line-height: 1.4;
}

.form-control:focus {
  border-color: var(--table-focus-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

.form-group label {
  font-weight: 500;
  color: #ffffff !important;
  margin-bottom: 0.5rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
}

/* ============================================
   14. Print Styles
   ============================================ */
@media print {
  .dataTables_wrapper {
    background: white;
    box-shadow: none;
  }

  .dataTables_length,
  .dataTables_filter,
  .dataTables_info,
  .dataTables_paginate {
    display: none !important;
  }

  .table > thead > tr > th {
    background: #333 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
