/**
 * TU Tennis Rankings - Styles
 *
 * Color Scheme:
 * - Primary teal: #3ca097
 * - Dark teal: #23665f
 * - Accent orange: #ca4f2e
 * - Text brown: #838375
 * - Background beige: #ebeadb
 * - White: #ffffff
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
  --tutr-primary: #3ca097;
  --tutr-primary-dark: #23665f;
  --tutr-accent: #ca4f2e;
  --tutr-text: #838375;
  --tutr-text-dark: #504d3a;
  --tutr-bg-beige: #ebeadb;
  --tutr-bg-white: #ffffff;
  --tutr-border: #e1e1d3;
  --tutr-rank-up: #2e7d32;
  --tutr-rank-down: #c62828;
  --tutr-rank-same: #838375;
  --tutr-hover-bg: #f5f5eb;
  --tutr-serbian-bg: rgba(202, 79, 46, 0.08);
  --tutr-zebra-bg: rgba(0, 0, 0, 0.02);
  --tutr-widget-width: 289px;
}

/* ==========================================================================
   Base Container Styles
   ========================================================================== */

.tutr-rankings-container,
.tutr-widget-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--tutr-text-dark);
  background: var(--tutr-bg-white);
  border-radius: 4px;
  overflow: hidden;
}

.tutr-rankings-container {
  max-width: 100%;
  margin: 0 auto 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tutr-widget-container {
  width: var(--tutr-widget-width);
  max-width: 100%;
}

/* ==========================================================================
   Rankings Header
   ========================================================================== */

.tutr-rankings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--tutr-accent);
  color: var(--tutr-bg-white);
}

.tutr-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.tutr-updated {
  font-size: 11px;
  opacity: 0.9;
}

/* ==========================================================================
   Tab Switcher
   ========================================================================== */

.tutr-widget-tabs {
  display: flex;
  background: var(--tutr-bg-beige);
  border-bottom: 1px solid var(--tutr-border);
}

.tutr-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--tutr-text);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tutr-tab:hover {
  color: var(--tutr-accent);
  background: rgba(202, 79, 46, 0.05);
}

.tutr-tab.active {
  color: var(--tutr-bg-white);
  background: var(--tutr-accent);
}

.tutr-tab.active::after {
  display: none;
}

/* ==========================================================================
   Tab Content
   ========================================================================== */

.tutr-tab-content {
  display: none;
}

.tutr-tab-content.active {
  display: block;
}

/* ==========================================================================
   Full Rankings Table
   ========================================================================== */

.tutr-rankings-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.tutr-rankings-table thead {
  background: var(--tutr-bg-beige);
}

.tutr-rankings-table th {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tutr-text);
  text-align: left;
  border-bottom: 1px solid var(--tutr-border);
}

.tutr-rankings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--tutr-border);
  vertical-align: middle;
}

.tutr-rankings-table tbody tr {
  transition: background-color 0.15s ease;
}

.tutr-rankings-table tbody tr:hover {
  background-color: var(--tutr-hover-bg);
}

.tutr-rankings-table tbody tr:last-child td {
  border-bottom: none;
}

/* Zebra striping for full table */
.tutr-rankings-table tbody tr:nth-child(even):not(.tutr-serbian-player):not(.tutr-serbian-separator) {
  background-color: var(--tutr-zebra-bg);
}

.tutr-rankings-table tbody tr:nth-child(even):not(.tutr-serbian-player):not(.tutr-serbian-separator):hover {
  background-color: var(--tutr-hover-bg);
}

/* Column widths - Full table */
.tutr-col-rank {
  width: 45px;
  text-align: center;
  font-weight: 600;
  color: var(--tutr-text-dark);
}

.tutr-col-change {
  width: 50px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}

.tutr-col-name {
  width: auto;
  font-weight: 500;
}

.tutr-col-country {
  width: 60px;
  text-align: center;
  font-size: 12px;
  color: var(--tutr-text);
}

.tutr-col-points {
  width: 80px;
  text-align: right;
  font-weight: 500;
  color: var(--tutr-text-dark);
}

/* ==========================================================================
   Compact Table (Sidebar Widget)
   ========================================================================== */

.tutr-compact-rankings {
  padding: 0;
}

.tutr-compact-updated {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--tutr-text);
  background: var(--tutr-bg-beige);
  border-bottom: 1px solid var(--tutr-border);
}

.tutr-compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tutr-compact-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--tutr-border);
  vertical-align: middle;
}

.tutr-compact-table tbody tr {
  transition: background-color 0.15s ease;
}

.tutr-compact-table tbody tr:hover {
  background-color: var(--tutr-hover-bg);
}

.tutr-compact-table tbody tr:last-child td {
  border-bottom: none;
}

/* Zebra striping for compact table */
.tutr-compact-table tbody tr:nth-child(even):not(.tutr-serbian-player):not(.tutr-serbian-separator) {
  background-color: var(--tutr-zebra-bg);
}

.tutr-compact-table tbody tr:nth-child(even):not(.tutr-serbian-player):not(.tutr-serbian-separator):hover {
  background-color: var(--tutr-hover-bg);
}

/* Compact column widths */
.tutr-compact-rank {
  width: 28px;
  text-align: center;
  font-weight: 600;
  color: var(--tutr-text-dark);
  font-size: 12px;
}

.tutr-compact-change {
  width: 36px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
}

.tutr-compact-name {
  padding-left: 4px !important;
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.tutr-compact-points {
  width: 50px;
  text-align: right;
  font-size: 11px;
  color: var(--tutr-text);
}

/* ==========================================================================
   Ranking Change Indicators
   ========================================================================== */

.tutr-rank-up {
  color: var(--tutr-rank-up) !important;
}

.tutr-rank-down {
  color: var(--tutr-rank-down) !important;
}

.tutr-rank-same {
  color: var(--tutr-rank-same) !important;
}

/* ==========================================================================
   Serbian Player Styles
   ========================================================================== */

.tutr-serbian-player {
  background-color: var(--tutr-serbian-bg) !important;
}

.tutr-serbian-player:hover {
  background-color: rgba(202, 79, 46, 0.12) !important;
}

.tutr-serbian-player .tutr-col-name,
.tutr-serbian-player .tutr-compact-name {
  color: #a13d24;
  font-weight: 600;
}

/* Serbian Separator Row */
.tutr-serbian-separator {
  background: var(--tutr-accent) !important;
}

.tutr-serbian-separator td {
  padding: 6px 12px !important;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tutr-bg-white) !important;
  text-align: center;
  border-bottom: none !important;
}

.tutr-serbian-separator:hover {
  background: var(--tutr-accent) !important;
}

/* ==========================================================================
   Load More Button
   ========================================================================== */

.tutr-load-more-container {
  padding: 12px;
  text-align: center;
  background: var(--tutr-bg-beige);
  border-top: 1px solid var(--tutr-border);
}

.tutr-load-more {
  display: inline-block;
  padding: 8px 20px;
  border: none;
  border-radius: 4px;
  background: var(--tutr-accent);
  color: var(--tutr-bg-white);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tutr-load-more:hover {
  background: #a13d24;
  transform: translateY(-1px);
}

.tutr-load-more:active {
  transform: translateY(0);
}

.tutr-load-more:disabled {
  background: var(--tutr-text);
  cursor: not-allowed;
  transform: none;
}

.tutr-load-more.loading {
  position: relative;
  color: transparent;
}

.tutr-load-more.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--tutr-bg-white);
  border-top-color: transparent;
  border-radius: 50%;
  animation: tutr-spin 0.8s linear infinite;
}

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

/* Compact load more */
.tutr-compact-load-more {
  padding: 6px 16px;
  font-size: 12px;
}

/* ==========================================================================
   No Data Message
   ========================================================================== */

.tutr-no-data {
  padding: 20px;
  text-align: center;
  color: var(--tutr-text);
  font-style: italic;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media screen and (max-width: 768px) {
  .tutr-rankings-container {
    margin: 0 -15px 20px;
    border-radius: 0;
  }

  .tutr-rankings-header {
    padding: 10px 12px;
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }

  .tutr-rankings-table th,
  .tutr-rankings-table td {
    padding: 8px 6px;
    font-size: 13px;
  }

  .tutr-col-rank {
    width: 35px;
  }

  .tutr-col-change {
    width: 40px;
    font-size: 11px;
  }

  .tutr-col-country {
    width: 45px;
    font-size: 11px;
  }

  .tutr-col-points {
    width: 60px;
    font-size: 12px;
  }

  .tutr-col-name {
    font-size: 13px;
  }

  /* Hide header row on very small screens */
  @media screen and (max-width: 480px) {
    .tutr-rankings-table thead {
      display: none;
    }

    .tutr-rankings-table tbody tr {
      display: flex;
      flex-wrap: wrap;
      padding: 8px 12px;
      border-bottom: 1px solid var(--tutr-border);
    }

    .tutr-rankings-table tbody td {
      border: none;
      padding: 2px 4px;
    }

    .tutr-rankings-table .tutr-col-rank {
      order: 1;
      width: auto;
      font-size: 14px;
    }

    .tutr-rankings-table .tutr-col-change {
      order: 2;
      width: auto;
    }

    .tutr-rankings-table .tutr-col-name {
      order: 3;
      flex: 1;
      text-align: left;
    }

    .tutr-rankings-table .tutr-col-country {
      order: 4;
      width: auto;
    }

    .tutr-rankings-table .tutr-col-points {
      order: 5;
      width: auto;
      text-align: right;
    }

    .tutr-serbian-separator td {
      width: 100%;
    }
  }
}

/* Widget in sidebar - ensure proper width */
.widget .tutr-widget-container {
  width: 100%;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .tutr-load-more-container {
    display: none;
  }

  .tutr-rankings-table,
  .tutr-compact-table {
    font-size: 10px;
  }

  .tutr-rankings-container {
    box-shadow: none;
  }
}
