/* ===========================================
   SHARED UI COMPONENTS
   Reusable primitives for GSFT application
   =========================================== */

/* ======================================
   1. CARDS
   ====================================== */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: none;
  max-width: 100%;
  margin-bottom: var(--space-sm);
  overflow-x: hidden;
  padding: var(--space-sm);
  box-shadow: var(--shadow-lg);  /* Use shadow-lg for major cards */
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

/* Bento-box style for major content containers */
.bento-box {
  background-color: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);  /* Standard shadow for major cards */
  margin-bottom: 20px;
  padding: 15px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: block;
}

/* Inner card style - used for nested cards, legends, filters */
.legend-card {
  width: fit-content;
  box-shadow: none !important;
  border: 1px solid #dee2e6;
}

.card__header,
.card__content {
  padding: 1rem;
}

.card__header h1,
.card__content h1,
.card__content h2,
.card__content p {
  margin: 0;
}

.card__actions {
  padding: 1rem;
  text-align: center;
}

.card__actions button,
.card__actions a {
  margin: 0 0.25rem;
}

/* Bento-style card title */
.bento-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-success);
  padding: 5px;
  margin: 0;
  display: flex;
  align-items: center;
}

/* Bento header (for rules cards, etc.) */
.bento-header {
  margin-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ======================================
   2. FORM INPUTS & SELECTS
   ====================================== */
input:not([type="checkbox"]):not([type="radio"]),
textarea {
  height: var(--input-height);
  padding: var(--input-padding);
  font-size: var(--input-font-size);
  line-height: 24px;
  border: 0px solid var(--color-border-default);
  border-radius: var(--radius-lg);
}

select {
  height: var(--input-height);
  padding: var(--input-padding);
  font-size: var(--input-font-size);
  line-height: 24px;
  border: 0px solid var(--color-border-default);
  border-radius: var(--radius-lg);
}

.form-select {
  padding-left: 10px;
  background-color: var(--color-bg-input);
  color: black;
}

/* ======================================
   3. INPUT GROUPS
   ====================================== */
.input-group-spacing {
  margin-top: 0.25rem;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
  margin-bottom: 0.25rem;
  width: calc(100% - 1rem);
}

.input-group-spacing .form-select {
  flex: 1;
  min-width: 0;
  width: auto;
  border: 1px solid var(--color-border-input);
}

.custom-dropdown-height {
  height: var(--input-height-sm);
  padding: 0.25rem 0.3rem;
}

/* Input group text (labels) */
.input-group-text {
  background-color: var(--color-bg-input-group);
  border-color: var(--color-border-input);
}

label.input-group-text.custom-dropdown-height {
  border: none;
  background-color: var(--color-bg-label);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* Round label background (grey pill labels) */
.rnd-label-bkgrnd {
  width: 55px;
  background-color: var(--color-bg-rnd-label);
  color: white;
  display: flex;
  align-items: center;
  font-weight: var(--font-weight-semibold);
  font-size: 0.8rem;
  justify-content: center;
  border-color: var(--color-border-input);
}

/* Dropdown buffer (yellow background labels) */
label.dropdown-buffer.custom-dropdown-height {
  border: none;
  background-color: var(--color-bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* ======================================
   4. BUTTONS
   ====================================== */
.btnx {
  display: inline-block;
  padding: 0.25rem 1rem;
  text-decoration: none;
  font: inherit;
  border: 1px solid #00695c;
  color: #00695c;
  background: white;
  border-radius: 3px;
  cursor: pointer;
}

.btnx:hover,
.btnx:active {
  background-color: #00695c;
  color: white;
}

.btn-xs {
  font-size: var(--font-size-xs);
  padding: 0.25rem 0.5rem;
}

.modal-btn-green {
  background-color: var(--color-btn-green);
  border-color: var(--color-btn-green);
  color: white;
}

.modal-btn-green:hover,
.modal-btn-green:focus,
.modal-btn-green:active {
  background-color: var(--color-btn-green-hover);
  border-color: #1e7e34;
}

.modal-btn-red {
  background-color: var(--color-btn-red);
  border-color: var(--color-btn-red);
  color: white;
}

.modal-btn-red:hover,
.modal-btn-red:focus,
.modal-btn-red:active {
  background-color: var(--color-btn-red-hover);
  border-color: var(--color-btn-red-hover);
}

.invisible-button {
  background-color: transparent;
  border: none;
  color: white;
  cursor: pointer;
  font: inherit;
  display: inline;
}

.invisible-button:hover,
.invisible-button:focus {
  color: #ffeb3b;
}

/* ======================================
   5. TABLES - Base styles only
   Note: Phase-specific tables override these
   ====================================== */
.table {
  width: 100%;
  border-collapse: collapse;
}

/* REMOVED: max-width constraints that were breaking phase1 tables */
/* Phase-specific tables should define their own constraints */

.table-sm {
  line-height: var(--line-height-tight);
  font-size: var(--font-size-sm);
}

/* ======================================
   5b. ROUND COLOUR SCALE
   Standard blue progression for round labels
   R1 (lightest) → Final (richest)
   ====================================== */
.round-r1    { background-color: #f0f7ff !important; color: #1e40af !important; }
.round-r2    { background-color: #dbeafe !important; color: #1e40af !important; }
.round-r3    { background-color: #bfdbfe !important; color: #1e3a8a !important; }
.round-r4    { background-color: #93c5fd !important; color: #1e3a8a !important; }
.round-qf    { background-color: #60a5fa !important; color: #fff !important; }
.round-sf    { background-color: #3b82f6 !important; color: #fff !important; }
.round-final { background-color: #1d4ed8 !important; color: #fff !important; font-weight: 700; }

/* Pulse animation — inset box-shadow paints above background but below text,
   so no !important conflict and no effect on layout or flex height. */
.input-group.pulse-box-thin .round-r4,
.input-group.pulse-box-thin .round-qf,
.input-group.pulse-box-thin .round-sf,
.input-group.pulse-box-thin .round-final {
  animation: labelBreath 2s ease-in-out infinite;
}

@keyframes labelBreath {
  0%, 100% { box-shadow: inset 0 0 0 200px #60a5fa; }
  50%       { box-shadow: inset 0 0 0 200px #1A73E8; }
}

/* ======================================
   6. MODALS
   ====================================== */
.modal-content,
.modal-body,
.modal-header {
  background: var(--color-bg-card);
}

.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem);
}

.modal-sm {
  max-width: 320px;
}

/* ======================================
   7. TOASTS
   ====================================== */
#toast-container {
  top: 60px;
  right: 20px;
  z-index: var(--z-toast);
}

.toast.show {
  opacity: 1;
}

/* ======================================
   8. NAVIGATION HEADER
   ====================================== */
.main-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background-color: #00695c;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  z-index: var(--z-fixed);
}

.main-header__nav {
  height: 100%;
  display: none;
  align-items: center;
}

.main-header__item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.main-header__item {
  margin: 0 1rem;
  padding: 0;
}

.main-header__item a {
  text-decoration: none;
  color: white;
}

.main-header__item a:hover,
.main-header__item a:active,
.main-header__item a.active {
  color: #ffeb3b;
}

/* Tournament-specific header colors */
.main-header.auo { background-color: var(--color-tournament-auo); }
.main-header.fro { background-color: var(--color-tournament-fro); }
.main-header.wim { background-color: var(--color-tournament-wim); }
.main-header.uso { background-color: var(--color-tournament-uso); }
.main-header.none { background-color: var(--color-tournament-none); }

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  display: inline-block;
}

.nav-link:hover,
.nav-link:focus {
  color: #ffeb3b;
}

.nav-link-active {
  color: #ffeb3b;
  pointer-events: none;
}

.nav-link-form {
  display: inline;
}

.nav-item {
  display: inline-block;
}

/* ======================================
   9. MOBILE NAVIGATION
   ====================================== */
.mobile-nav {
  width: 30rem;
  height: 100vh;
  max-width: 90%;
  position: fixed;
  left: 0;
  top: 0;
  background: white;
  z-index: 10;
  padding: 2rem 1rem 1rem 2rem;
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
}

.mobile-nav.open {
  transform: translateX(0);
}

.mobile-nav__item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

.mobile-nav__item {
  margin: 1rem;
  padding: 0;
}

.mobile-nav__item a {
  text-decoration: none;
  color: black;
  font-size: 1.5rem;
  padding: 0.5rem 2rem;
}

.mobile-nav__item a:active,
.mobile-nav__item a:hover,
.mobile-nav__item a.active {
  background: #00695c;
  color: white;
  border-radius: 3px;
}

#side-menu-toggle {
  border: 1px solid white;
  font: inherit;
  padding: 0.5rem;
  display: block;
  background: transparent;
  color: white;
  cursor: pointer;
}

#side-menu-toggle:focus {
  outline: none;
}

#side-menu-toggle:active,
#side-menu-toggle:hover {
  color: #ffeb3b;
  border-color: #ffeb3b;
}

/* ======================================
   10. NOTIFICATIONS & WARNINGS
   ====================================== */
.warning {
  color: red;
  font-weight: bold;
  font-size: 75%;
}

.qf-warning-text {
  color: red;
  font-style: italic;
}

.notification-hidden {
  display: none;
  font-size: 0.9em;
  color: orange;
  margin-top: 10px;
}

/* ======================================
   11. COUNTDOWN TIMERS
   ====================================== */
.timer-container {
  min-height: 54px;  /* Reserve space for status bar (height + margins) to prevent layout shift */
  display: flex;
  flex-direction: column;
}

.prediction-timer {
  border-radius: var(--radius-sm);
  height: calc(1.3rem + 10px);
  padding: 0.25rem 0.5rem;
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  margin-top: 12px;
  margin-bottom: 4px;
  margin-left: calc(0.5rem + 12.5%);
  margin-right: calc(0.5rem + 12.5%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-active {
  background-color: var(--color-success);
  border-color: var(--color-success-border);
  color: #28a745;
}

.countdown-expired,
.countdown-complete {
  background-color: var(--color-danger);
  border-color: var(--color-danger-border);
  color: #842029;
  font-size: 1.0rem;
}

.countdown-coming-soon {
  background-color: #e2e3e5;
  border-color: #d3d3d4;
  color: #6c757d;
}

.countdown-display,
.cutoff-display,
.coming-soon-display {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-medium);
  width: 100%;
  font-size: 1.0rem;
}

.countdown-value {
  color: #28a745;
  font-weight: bold;
}

.cutoff-time {
  color: #28a745;
  font-weight: bold;
}

/* ======================================
   12. SMALL FORM LABELS
   ====================================== */
.label-sm {
  font-size: var(--font-size-sm);
}

.status-cell {
  font-size: var(--font-size-sm);
}

.footnote-text {
  line-height: 0.1;
  font-size: var(--font-size-xs);
}

/* ======================================
   13. RESPONSIVE NAVIGATION
   ====================================== */
@media (min-width: 768px) {
  .main-header__nav {
    display: flex;
  }

  #side-menu-toggle {
    display: none;
  }
}

/* ======================================
   14. MOBILE HEADER CARD
   Reusable mobile header component for all pages
   ====================================== */

/* Base mobile header card styles */
.mobile-header-card {
  background-color: var(--color-bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  height: 210px;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.mobile-header-cap {
  text-align: center;
  padding: 0.375rem 0;
  height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mobile-header-cap-text {
  color: #fff;
  font-size: 0.85rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: var(--line-height-tight);
}

.mobile-header-cap-text.unofficial-text {
  color: #ffc107;
}

.mobile-header-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 0.75rem;
}

.mobile-header-logo {
  max-width: 300px;
  height: auto;
}

.mobile-header-title {
  color: var(--color-text-heading);
  text-align: center;
  margin: 0 0 1.25rem;
  font-size: 1.4rem;
}

/* Last Match Update line in mobile header */
.mobile-header-update {
  text-align: center;
  margin-top: -10px;  /* Reduce gap between title (1.25rem margin-bottom) and update text to ~10px */
  padding-bottom: 10px;  /* 10px gap to bottom of header */
  font-size: 0.8rem;
  line-height: 1.2;
}

/* When update line is present, tighten title bottom margin to exactly 10px */
.mobile-header-title + .mobile-header-update {
  margin-top: 0;
}
.mobile-header-title:has(+ .mobile-header-update) {
  margin-bottom: 10px;
}

.mobile-header-update-text {
  color: var(--color-text-muted, #6c757d);
  font-size: 0.8rem;
  line-height: 1.2;
}

/* Dashboard variant (black header) */
.mobile-header-card--dashboard .mobile-header-cap {
  background-color: #000;
  border-bottom: 3px solid #333;
}

/* Auth variant (black header) */
.mobile-header-card--auth .mobile-header-cap {
  background-color: #000;
  border-bottom: 3px solid #333;
}

.mobile-header-card--auth {
  height: auto;
}

.mobile-header-card--auth .mobile-header-logo-wrap {
  padding: 1.5rem 1rem 1rem;
}

.mobile-header-card--auth .mobile-header-logo {
  max-width: 400px;
}

/* Mobile Header - Mobile Adjustments */
@media (max-width: 576px) {
  .mobile-header-logo-wrap {
    padding: 1rem 0.5rem 0.5rem;
  }
  
  .mobile-header-logo {
    min-width: 280px;
  }
  
  .mobile-header-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }
  
  .mobile-header-card--auth .mobile-header-logo-wrap {
    padding: 1.25rem 1rem 0.75rem;
  }
  
  .mobile-header-card--auth .mobile-header-logo {
    max-width: 320px;
  }
}

@media (max-width: 450px) {
  .mobile-header-card--auth .mobile-header-logo {
    min-width: 320px;
  }
}

@media (max-width: 375px) {
  .mobile-header-cap-text {
    font-size: 0.75rem;
    letter-spacing: 1.5px;
  }
  
  .mobile-header-logo {
    max-width: 200px;
  }
  
  .mobile-header-title {
    font-size: 1.1rem;
  }
}

/* ======================================
   15. PAGE LAYOUT CONTAINER
   ====================================== */
.page-content-wrapper {
  /* Matches container-fluid structure */
}

@media (min-width: 992px) {
  .page-content-wrapper {
    padding-left: 0;
    padding-right: 0;
  }
}

/* ======================================
   16. DESKTOP BRANDED HEADER
   3-column layout: Racquets | GSFT Info | Stats Panel
   ====================================== */

.desktop-branded-header {
  display: none;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
  position: relative;
  margin-top: var(--navbar-content-gap, 0);
  overflow: hidden;
  background-color: var(--color-bg-card);
  max-width: 100%;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-lg);
}

/* Show on large screens */
@media (min-width: 992px) {
  .desktop-branded-header {
    display: flex;
  }
}

/* Column 1: Racquets Logo */
.desktop-branded-header__racquets {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 0 0 30px;
  background-color: transparent;
  position: relative;
  z-index: 1;
}

.desktop-branded-header__racquets-img {
  height: 150px;
  width: auto;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
}

.desktop-branded-header__clay-overlay {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: auto;
  pointer-events: none;
  z-index: 0;
  clip-path: inset(0 320px 0 0);
}

/* Column 2: Stacked Content */
.desktop-branded-header__center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  position: relative;
  z-index: 1;
}

.desktop-branded-header__logo-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 24px;   /* Fixed px - was 1.5rem */
  padding-bottom: 4px; /* Fixed px - was 0.25rem */
}

.desktop-branded-header__gsft-img {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.desktop-branded-header__tournament-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 1px;    /* Fixed px - was 0.05rem */
  padding-bottom: 4px; /* Fixed px - was 0.25rem */
}

.desktop-branded-header__tournament-text {
  margin: 0;
  font-size: 20px; /* Fixed px to avoid rem inheritance from different page font-sizes */
  font-weight: var(--font-weight-semibold);
  text-align: center;
  line-height: 1.2; /* Fixed to prevent page line-height inheritance */
}

.desktop-branded-header__title-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 4px;    /* Fixed px - was 0.25rem */
  padding-bottom: 20px; /* Fixed px - was 1.25rem */
}

.desktop-branded-header__page-title {
  margin: 0;
  font-size: 28px; /* Fixed px to avoid rem inheritance from different page font-sizes */
  font-weight: var(--font-weight-bold);
  text-align: center;
  line-height: 1.2; /* Fixed to prevent page line-height inheritance */
}

/* Update Row */
.desktop-branded-header__update-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 4px;   /* Fixed px - was 0.25rem */
  padding-bottom: 8px; /* Fixed px - was 0.5rem */
}

.desktop-branded-header__update-text {
  color: var(--color-text-muted);
  font-size: 14px; /* Fixed px to avoid rem inheritance from different page font-sizes */
  text-align: center;
  line-height: 1.2; /* Fixed to prevent page line-height inheritance */
}

/* Column 3: Stats Panel */
.desktop-branded-header__stats {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 24px;  /* Fixed px - was 1rem 1.5rem */
  background-color: transparent;
  border-left: 2px solid var(--color-border-default);
  position: relative;
  z-index: 1;
  font-family: var(--font-family-mono);
  font-size: 14px;     /* Fixed px - was 0.875rem */
  line-height: 1.4;    /* Fixed to prevent page line-height inheritance */
  min-width: 280px;
}

.desktop-branded-header__stat-row {
  padding: 6px 0;      /* Fixed px - was 0.35rem 0 */
  border-bottom: 1px solid var(--color-border-default);
}

.desktop-branded-header__stat-row:last-child {
  border-bottom: none;
}

.desktop-branded-header__stat-value {
  float: right;
}