﻿/* =============================================================
   Base styles
   ============================================================= */
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
#title img {
  max-width: 100%;
  height: auto;
}

/* =============================================================
   Results table - base
   Order: table container -> structural cells -> utility elements
   ============================================================= */
.resultstable.table {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.875rem;
  --bs-table-border-color: var(--bs-border-color);
  border: var(--bs-table-border-color) var(--bs-border-width) solid;
  --bs-table-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);
  --bs-table-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);
}

/* Uniform padding for all data/header cells */
.resultstable.table > :not(caption) > * > * {
  padding: 0.25rem;
}

/* Header cells */
.resultstable th {
  vertical-align: top !important;
  padding-right: 20px !important;
}

/* Time / score column cells */
.resultstable td.sporttype-score {
  width: 110px;
  min-width: 110px;
  text-align: left;
  position: relative;
}
.resultstable th.sporttype-score {
    width: 110px;
    min-width: 110px;
}

/* Muted info block & score badge */
.resultstable .text-muted.small {
  font-size: 0.875rem;
  line-height: 1.25;
  color: var(--bs-secondary-color);
}
.resultstable .sporttype-score .fw-bold {
  color: var(--bs-emphasis-color);
  font-weight: var(--bs-font-weight-semibold);
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
}

/* Tablesorter theme alignment */
.resultstable.tablesorter-default,
.resultstable.tablesorter-default th,
.resultstable.tablesorter-default td,
.resultstable.tablesorter-default thead td,
.resultstable.tablesorter-default tfoot td,
.resultstable.tablesorter-default .header,
.resultstable.tablesorter-default .tablesorter-header {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  font-size: 0.875rem !important;
}

/* Podium highlighting */
.resultstable .table-success {
  --bs-table-bg: #d1e7dd;
  --bs-table-striped-bg: #c3e6cb;
  --bs-table-hover-bg: #b6dfcc;
  --bs-table-border-color: #badbcc;
}
.resultstable .table-secondary {
  --bs-table-bg: #e2e3e5;
  --bs-table-striped-bg: #d3d4d6;
  --bs-table-hover-bg: #c4c5c7;
  --bs-table-border-color: #d3d4d6;
}

/* =============================================================
   Responsive (≤ 992px)
   ============================================================= */
@media (max-width: 991.98px) {
  .resultstable .start-number-col {
    display: none;
  }

  .resultstable td.sporttype-score,
  .resultstable th.sporttype-score,
  .resultstable td.team-code,
  .resultstable th.team-code {
    width: 85px;
    min-width: 85px;
    max-width: 85px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .resultstable td.team-code,
  .resultstable th.team-code {
    overflow: hidden;
  }

  /* Hide time/status blocks by default on mobile */
  .resultstable .text-muted.small {
    display: none;
  }

  /* Score reposition */
  .resultstable .fw-bold {
    position: static;
    display: block;
    text-align: right;
  }

  /* Tooltip activation (hover, focus, JS toggle) */
  .resultstable td.sporttype-score.show-time-tooltip .text-muted.small.has-time-data,
  .resultstable td.sporttype-score:focus-within .text-muted.small.has-time-data,
  .resultstable td.sporttype-score:hover .text-muted.small.has-time-data {
    display: block !important;
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: #fff !important;
    padding: 0.5rem;
    border-radius: 0.375rem;
    z-index: 1050;
    font-size: 0.75rem;
    line-height: 1.2;
    max-width: 240px;
    white-space: normal;
    word-wrap: break-word;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.3);
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.25rem;
  }

  .resultstable td.text-end {
    position: relative;
    overflow: visible;
    cursor: pointer;
  }

  .resultstable td.text-end:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
  }
}

/* =============================================================
   Reduced motion accessibility
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .resultstable td.text-end:hover {
    background-color: inherit !important;
  }
}

/* =============================================================
   Print adjustments
   ============================================================= */
@media print {
  html, body {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
  }

  body {
    margin: 0;
    /* Scale the body content and adjust effective viewport */
    transform: scale(0.9);
    transform-origin: 0 0;
    /* Expand the content area to account for scaling */
    width: 113%;
    min-height: 113vh;
  }

  #title img {
    height: 70%;
  }

  #box {
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  .table-responsive {
    padding-right: 3px !important;
  }

  /* Override responsive styles for print - show all content */
  .resultstable .start-number-col {
    display: table-cell !important;
  }

  .resultstable td.sporttype-score,
  .resultstable th.sporttype-score {
    width: 110px !important;
    min-width: 110px !important;
    max-width: none !important;
  }

  .resultstable td.team-code,
  .resultstable th.team-code {
    width: auto !important;
    min-width: auto !important;
    max-width: none !important;
    overflow: visible !important;
    white-space: normal !important;
    text-overflow: clip !important;
  }

  /* Show time/status blocks in print */
  .resultstable .text-muted.small {
    display: block !important;
    position: static !important;
    background: none !important;
    color: var(--bs-secondary-color) !important;
    padding: 0 !important;
    border-radius: 0 !important;
    z-index: auto !important;
    font-size: 0.875rem !important;
    line-height: 1.25 !important;
    max-width: none !important;
    white-space: normal !important;
    word-wrap: normal !important;
    box-shadow: none !important;
    pointer-events: auto !important;
    border: none !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin-top: 0 !important;
  }

  /* Reset score positioning for print */
  .resultstable .sporttype-score .fw-bold {
    position: absolute !important;
    top: 0.25rem !important;
    right: 0.25rem !important;
  }

  /* Reset hover states for print */
  .resultstable td.text-end {
    position: relative !important;
    overflow: visible !important;
    cursor: default !important;
  }

  .resultstable td.text-end:hover {
    background-color: inherit !important;
  }
}

@page {
  -prince-shrink-to-fit: auto;
  margin: 24pt 38pt;
  size: A4;
}
