/* Stats pages shared styles */

.stats-page {
  #nav {
    border-inline: 1px solid var(--color-border-darker);
    backdrop-filter: blur(12px);
  }

  #main-content {
    justify-content: start;

    /* Layout */
    .full-width {
      width: 100%;
      padding: 5rem 1rem 1rem;
    }

    .section-heading {
      font-size: 1.5rem;
      font-weight: 600;
      margin: 0.5rem 0;
      padding-bottom: 0.5rem;
      clear: both;
      color: var(--color-text);
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 1rem;
    }

    .grid-card {
      width: 100%;
    }

    /* Card components */
    .card {
      background: var(--color-bg);
      border: 1px solid var(--color-border-darker);
      border-radius: 8px;
      overflow: hidden;
    }

    .card-header {
      padding: 0.75rem;
      border-bottom: 1px solid var(--color-border-darker);
      background-color: var(--color-border);
    }

    .card-header-flex {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .card-header-link {
      display: block;
      color: inherit;
      text-decoration: none;
    }

    .card-header-link .txt-h3 {
      text-decoration: underline;
    }

    .card-header-link:hover .card-header {
      background-color: var(--color-border-dark);
    }

    .card-body {
      padding: 1rem;
    }

    .card-body.compact {
      padding: 0.5rem;
    }

    /* Spacing utilities */
    .margin-block {
      margin-block: 1rem;
    }

    .margin-bottom {
      margin-bottom: 1rem;
    }

    .margin-top {
      margin-top: 1.5rem;
    }

    .margin-top-lg {
      margin-top: 2rem;
    }

    /* State classes */
    .current-user {
      background-color: var(--color-selected);
    }

    /* Typography */
    .txt-h3 {
      font-size: 1rem;
      font-weight: 500;
      margin: 0;
      color: var(--color-text);
    }

    .txt-h4 {
      font-size: 1.1rem;
      font-weight: 600;
      margin: 0 0 1rem 0;
      color: var(--color-text);
    }

    .txt-right {
      text-align: right;
    }

    .txt-left {
      text-align: left;
    }

    .txt-center {
      text-align: center;
    }

    .txt-small {
      font-size: 0.85rem;
    }

    .txt-faded {
      color: var(--color-text-faded);
    }

    .txt-truncate {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Table styles */
    .table {
      border-collapse: collapse;
      width: 100%;
    }

    .table th,
    .table td {
      padding: 0.5rem;
      border-bottom: 1px solid var(--color-border-darker);
    }

    .compact .table th,
    .compact .table td {
      padding: 0.25rem 0.5rem;
    }

    .compact-table .table th,
    .compact-table .table td {
      padding: 0.25rem 0.5rem;
    }

    .table th {
      text-align: left;
      font-weight: normal;
    }

    .table-container {
      padding: 0.25rem 0;
    }

    .compact-rows th,
    .compact-rows td {
      padding: 0.25rem 0.5rem;
    }

    /* Column width classes */
    .col-rank {
      width: 20px;
    }

    .col-date {
      width: 90px;
      white-space: nowrap;
    }

    .col-count {
      width: 80px;
    }

    .col-full {
      max-width: 0;
      width: 100%;
    }

    /* Avatar styles */
    .avatar-xs {
      width: 18px;
      height: 18px;
      font-size: 9px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      overflow: hidden;
      background: var(--color-border-darker);
      border: 1px solid var(--color-border-darker);
      color: var(--color-text);
      flex-shrink: 0;
    }

    .avatar-xs img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .overflow-x-auto {
      overflow-x: auto;
    }

    /* Stats page link styles */
    .full-width a {
      color: var(--color-text);
      text-decoration: none;
    }

    .full-width a:visited {
      color: var(--color-text);
    }

    .full-width a:hover {
      text-decoration: underline;
    }

    /* User row styles */
    .user-row {
      display: flex;
      align-items: center;
      gap: 4px;
      min-width: 0;
      text-decoration: none;
    }

    .user-row:hover {
      text-decoration: underline;
    }

    .user-row--end {
      justify-content: flex-end;
    }

    .user-row--full {
      width: 100%;
    }

    /* Separator row - visual divider for current user outside top list */
    .separator-row td {
      padding: 0.25rem;
    }

    .separator-line {
      border-top: 1px dashed var(--color-border-darker);
      margin: 0.25rem 0;
    }

    /* Sparkline chart */
    .sparkline {
      display: flex;
      align-items: flex-end;
      gap: 1px;
      height: 60px;
      padding: 0.5rem 0;
    }

    .sparkline__bar {
      flex: 1;
      min-width: 2px;
      background: var(--color-border-darker);
      border-radius: 1px 1px 0 0;
      transition: background 0.15s ease;
      position: relative;
    }

    .sparkline__bar:hover {
      background: var(--color-text);
    }

    .sparkline__bar[data-tooltip]:hover::after {
      content: attr(data-tooltip);
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
      background: var(--color-text);
      color: var(--color-bg);
      padding: 0.25rem 0.5rem;
      border-radius: 4px;
      font-size: 0.75rem;
      white-space: nowrap;
      pointer-events: none;
      z-index: 10;
      margin-bottom: 4px;
    }

    /* Loading indicator - z-index needed to stay above dynamically loaded content */
    #loading-indicator {
      display: none;
      text-align: center;
      padding: 0.5rem;
      margin: 1rem 0;
      position: relative;
      z-index: 10;
      clear: both;
    }

    .loading-spinner {
      display: inline-block;
      width: 2rem;
      height: 2rem;
      border: 0.25rem solid var(--color-border);
      border-radius: 50%;
      border-top-color: var(--color-link);
      animation: spin 1s ease-in-out infinite;
    }

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

    #error-message {
      display: none;
      text-align: center;
      padding: 1rem;
      margin: 1rem 0;
      background-color: var(--color-bg-negative);
      border: 1px solid var(--color-negative);
      border-radius: 0.5rem;
      color: var(--color-negative);
    }
  }
}
