/* style.css */

/* ==========================================================================\
   1. Core Layout & Container Setup
   ========================================================================== */
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background-color: #f8f9fa;
  color: #212529;
  margin: 0;
  padding: 20px;
}
.container-fluid {
  max-width: 1400px;
  margin: 0 auto;
}
#bracketContainer {
  width: 100%;
  overflow-x: auto;
  padding: 20px 0;
  margin-top: 20px;
}
#bracket {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 40px;
  padding: 10px;
}

/* ==========================================================================
   2. Bracket Column & Matchup Geometry
   ========================================================================== */
.round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 100%;
  width: max-content;
  min-width: 150px; /* UPDATED: Shrunk from 200px so columns can be narrower */
  margin-right: 10px;
}

.round:last-child {
  margin-right: 0;
}

.round-title {
  font-weight: 700;
  text-align: center;
  padding-bottom: 15px;
  color: #495057;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #000000;
  margin-bottom: 20px;
}

/* --- UPDATED: Locked to 150px with slightly tighter inner padding --- */
.matchup {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  padding: 8px; /* Tighter padding saves precious horizontal space */
  background: #fff;
  border: 1px solid #909196;
  border-radius: 6px;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.05);
  width: 150px; /* Forces it to exactly 150px */
  max-width: 150px; /* Strict maximum limit */
  box-sizing: border-box;
  overflow: hidden;
}

/* --- UPDATED: Removed old min/max widths, scaled down text and padding --- */
.player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px; /* Reduced gap between name and trophy */
  padding: 6px 8px; /* Scaled down padding */
  font-size: 12px; /* Scaled down font size so more of the name fits */
  border-radius: 4px;
  background: #f8f9fc;
  margin: 4px 0;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  white-space: nowrap;
  width: 100%;
  max-width: 100%; /* Stripped old 240px rule */
  min-width: 0; /* Stripped old 160px rule */
  box-sizing: border-box;
  overflow: hidden;
}

/* (Keep your existing .name-text and .player:hover rules below here) */
.player .name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  margin-right: 4px;
}

.player:hover {
  background: #4e73df;
  color: #fff;
}
.player.winner {
  background: #1cc88a !important;
  color: #fff !important;
  font-weight: 600;
}

/* ==========================================================================
   Red Name Styling for Top Player
   ========================================================================== */
.red-text {
  color: #dc3545; /* A clean, highly visible red */
  font-weight: 800;
}

/* Ensure the red text cleanly turns white when hovered or when the player wins */
.player:hover .red-text,
.player.winner .red-text {
  color: #ffffff !important;
}

/* ==========================================================================\
   3. Embed Optimization Structural Overrides
   ========================================================================== */
body.is-embedded-view {
  padding: 0 0 30px 0 !important;
  margin: 0 !important;
  background-color: transparent !important;
  height: auto !important;
  min-height: unset !important;
  overflow-y: hidden !important;
}
body.is-embedded-view #mainApplicationWorkspace {
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
}
body.is-embedded-view #bracketContainer {
  margin-top: 0 !important;
  padding: 5px 20px !important;
  overflow-y: hidden !important;
  overflow-x: auto !important;
}

body.is-embedded-view #creationControls,
body.is-embedded-view #historySelect,
body.is-embedded-view .control-card,
body.is-embedded-view h1,
body.is-embedded-view h2,
body.is-embedded-view #displayTournamentTitle,
body.is-embedded-view hr,
body.is-embedded-view .btn,
body.is-embedded-view #saveBracketBtn,
body.is-embedded-view #shareBtn,
body.is-embedded-view #deleteBracketBtn,
body.is-embedded-view #embedContainer,
body.is-embedded-view #authCardContainer,
body.is-embedded-view header {
  display: none !important;
}

body.is-embedded-view .col-md-4,
body.is-embedded-view .col-lg-4,
body.is-embedded-view .col-sm-4,
body.is-embedded-view [class*="col-"]:has(#creationControls),
body.is-embedded-view [class*="col-"]:has(#historySelect) {
  display: none !important;
}

body.is-embedded-view .col-md-8,
body.is-embedded-view .col-lg-8,
body.is-embedded-view .col-sm-8,
body.is-embedded-view [class*="col-"]:has(#bracketContainer) {
  width: 100% !important;
  flex: 0 0 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
}

/* Ensure the print button displays even when embedded */
body.is-embedded-view #printBracketBtn {
  display: inline-block !important;
}

/* Ensure the print button isn't visible when you actually send the page to print */
@media print {
  /* 1. Force the browser to print background colors (Required for the green fill) */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 2. Force the Winner background to be visible */
  body.is-embedded-view .player.winner {
    /* If your green color is defined in your main .winner class, 
           inherit !important will pull that style into the print view. */
    background-color: inherit !important;
    border: 1px solid #000 !important; /* Adds a solid border to help the winner stand out */
    -webkit-print-color-adjust: exact !important;
  }

  /* 3. Ensure text is dark and visible */
  body.is-embedded-view .player {
    color: #000 !important;
    opacity: 1 !important;
  }

  /* 4. Hide the print button */
  #printBracketBtn,
  body.is-embedded-view #printBracketBtn {
    display: none !important;
  }
}

/* Disable all mouse interaction for player boxes in embedded view */
body.is-embedded-view .player {
  pointer-events: none !important; /* The mouse ignores the element */
  cursor: default !important; /* Ensures the mouse doesn't change */
}

/* Ensure the Print Button remains clickable */
body.is-embedded-view #printBracketBtn {
  pointer-events: auto !important; /* Forces the print button to stay clickable */
}

/* Hide the Multi-Club Switcher when viewing via an IFrame Embed */
body.is-embedded-view #clubContextSwitcherElement {
  display: none !important;
}

/* ==========================================================================
   Round Deadline Date Selectors 
   ========================================================================== */
.round-date-container {
  display: flex;
  align-items: flex-start; /* Aligns "By:" to the top row instead of center */
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
  color: #6c757d;
}

.dates-wrapper {
  display: flex;
  flex-direction: column; /* Forces the inputs to stack on top of each other */
  align-items: center; /* Centers the dates and the word "or" */
  gap: 2px;
}

.round-date-label {
  font-weight: 600;
  color: #666;
  margin-top: 2px; /* Slight bump to align it with the first date input text */
}

.round-date-or {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  margin: 2px 0;
}

.round-date-input {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-family: inherit;
  color: #495057;
  cursor: pointer;
  padding: 0;
  text-align: center; /* Centers the date string inside its box */
}

body.is-embedded-view .round-date-input::-webkit-calendar-picker-indicator {
  display: none !important;
}

/* ==========================================================================
   Embedded View Overrides: Keep Header and Details Visible 
   ========================================================================== */
body.is-embedded-view #tournamentDisplayHeader {
  display: block !important;
  text-align: center;
  margin-bottom: 25px !important;
  padding: 0 20px !important;
}

body.is-embedded-view #tournamentDisplayHeader > div {
  display: block !important;
}

body.is-embedded-view #displayTournamentTitle,
body.is-embedded-view h2#displayTournamentTitle {
  display: block !important;
  font-size: 1.5rem;
}

body.is-embedded-view #displayTournamentDetails {
  display: block !important;
}
