/**
 * BracketsFlex Bracket Styles
 * Tournament bracket visualization
 */

/* Bracket Container */
#bracket-container {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    overflow: auto;
    cursor: grab;
    min-height: 600px;
    max-height: calc(100vh - 150px);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

#bracket {
    padding: 20px;
    display: inline-block;
    min-width: 100%;
}

/* Bracket Grid - Vertical layout for regions */
.bracket-grid {
    display: inline-flex;
    flex-direction: column;
    gap: 30px;
    min-width: 100%;
}

/* Region */
.region {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 15px;
    box-shadow: var(--shadow);
}

.region-title {
    text-align: center;
    padding: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.region-bracket {
    display: flex;
    flex-wrap: nowrap;
    gap: 30px;
    min-width: max-content;
}

.region-final {
    width: 100%;
}

.final-bracket {
    flex-direction: column;
    align-items: center;
}

/* Round */
.round {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
    min-width: 180px;
}

.round-header {
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.round-score {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 2px;
}

.round-score.positive { color: var(--success-color); }
.round-score.negative { color: var(--danger-color); }
.round-score.zero { color: var(--text-light); }

.score-detail-hint {
    display: inline-block;
    font-size: 0.6rem;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    border-radius: 50%;
    background: var(--text-light);
    color: var(--card-bg);
    font-weight: 700;
    font-style: normal;
    opacity: 0.4;
    vertical-align: middle;
    cursor: help;
}

.round-header[title] {
    cursor: help;
}

.round-header[title]:hover .score-detail-hint {
    opacity: 0.8;
}

.round-games {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: space-around;
    flex: 1;
}

/* Game spacing by round */
.round-1 .round-games { gap: 10px; }
.round-2 .round-games { gap: 40px; }
.round-3 .round-games { gap: 90px; }
.round-4 .round-games { gap: 200px; }

/* Game */
.game {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-width: 180px;
    position: relative;
    transition: var(--transition);
}

.game:hover {
    box-shadow: var(--shadow);
}

.game.pickable {
    cursor: pointer;
    border-color: var(--primary-color);
}

.game.pickable:hover {
    border-color: var(--primary-dark);
    transform: scale(1.02);
}

.game.unpicked {
    border-color: var(--warning-color);
    background: #fff8e1;
    box-shadow: 0 0 0 1px var(--warning-color);
}

.game.unpicked .game-time {
    background: #fff3cd;
}

.game.needs-jackpot:not(.unpicked) {
    box-shadow: inset 0 -3px 0 0 var(--warning-color);
}

.game.complete {
    border-color: var(--success-color);
}

.game.in-progress {
    border-color: var(--warning-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); }
    50% { box-shadow: 0 0 0 5px rgba(255, 152, 0, 0); }
}

.game-time {
    font-size: 0.7rem;
    color: var(--text-light);
    text-align: center;
    padding: 3px 5px;
    background: var(--bg-color);
    border-radius: var(--radius) var(--radius) 0 0;
}

.game-time.live-indicator {
    background: #d32f2f;
    color: white;
    font-weight: 700;
    animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.live-score, .final-score {
    font-weight: 700;
    font-size: 0.95rem;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 28px;
    text-align: right;
    color: var(--text-color);
}

.final-score {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Add right padding to team-slot when it has a score so pick info doesn't overlap */
.team-slot:has(.live-score),
.team-slot:has(.final-score) {
    padding-right: 40px;
}

/* Team Slot */
.team-slot {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
    position: relative;
}

.team-slot:last-child {
    border-bottom: none;
}

.team-slot .seed {
    font-weight: bold;
    color: var(--text-light);
    font-size: 0.85rem;
    min-width: 20px;
}

.team-slot .team-name {
    flex: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-slot.empty {
    color: var(--text-light);
    font-style: italic;
}

.team-slot.winner {
    background: linear-gradient(90deg, #a5d6a7, transparent);
    font-weight: 500;
}

.team-slot.picked {
    background: linear-gradient(90deg, #e3f2fd, transparent);
}

.team-slot.picked .pick-marker,
.team-slot.picked .pick-confidence,
.team-slot.picked .pick-points {
    color: var(--primary-color);
}

.team-slot.correct {
    background: linear-gradient(90deg, #a5d6a7, transparent);
}

.team-slot.correct .pick-marker,
.team-slot.correct .pick-confidence,
.team-slot.correct .pick-points {
    color: var(--success-color);
}

.team-slot.incorrect {
    text-decoration: line-through;
    opacity: 0.7;
}

.team-slot.incorrect .pick-marker,
.team-slot.incorrect .pick-confidence,
.team-slot.incorrect .pick-points {
    color: var(--danger-color);
}

.pick-confidence {
    font-size: 0.75rem;
    font-weight: 500;
}

.pick-points {
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 2px;
}

.pick-wager {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--warning-color);
    margin-left: 2px;
}

.pick-marker {
    font-weight: bold;
}

/* Confidence Indicator */
.confidence-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--secondary-color);
    border-radius: 0 0 var(--radius) var(--radius);
    transition: width 0.3s ease;
}

/* Pick Panel */
#pick-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.pick-panel-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.pick-panel-content h3 {
    margin-bottom: 15px;
    text-align: center;
}

#pick-game-info {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

#pick-game-info .countdown {
    color: var(--warning-color);
    font-weight: 500;
    margin-top: 5px;
}

#pick-game-info .countdown.expired {
    color: var(--danger-color);
}

#pick-teams {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.pick-team {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    gap: 10px;
}

.pick-team:hover {
    border-color: var(--primary-color);
    background: #f8f8f8;
}

.pick-team.selected {
    border-color: var(--primary-color);
    background: #e8f5e9;
}

.pick-team .seed {
    font-weight: bold;
    color: var(--text-light);
    font-size: 1.1rem;
}

.pick-team .name {
    flex: 1;
    font-size: 1rem;
}

.pick-vs {
    text-align: center;
    color: var(--text-light);
    font-weight: bold;
}

/* Confidence Slider */
.confidence-slider {
    margin-bottom: 20px;
}

.confidence-slider label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

.confidence-slider input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #f44336, #ff9800, #4CAF50);
    border-radius: 4px;
    outline: none;
}

.confidence-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.confidence-slider input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
}

#confidence-value {
    font-weight: bold;
    color: var(--primary-color);
}

/* Pick Actions */
.pick-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Bracket connectors (CSS lines connecting games) */
.round-2 .game::before,
.round-3 .game::before,
.round-4 .game::before,
.round-5 .game::before,
.round-6 .game::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    width: 15px;
    height: 1px;
    background: var(--border-color);
}

/* Vertical connectors */
.round-2 .game:nth-child(odd)::after,
.round-3 .game:nth-child(odd)::after,
.round-4 .game::after {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    width: 1px;
    height: 50px;
    background: var(--border-color);
}

.round-2 .game:nth-child(even)::after,
.round-3 .game:nth-child(even)::after {
    content: '';
    position: absolute;
    left: -15px;
    bottom: 50%;
    width: 1px;
    height: 50px;
    background: var(--border-color);
}

/* Inline Picker */
.game.picker-open {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
    z-index: 10;
}

.team-slot.inline-selected {
    background: linear-gradient(90deg, #bbdefb, transparent) !important;
    font-weight: 600;
}

.inline-picker {
    padding: 8px 10px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 0 0 var(--radius) var(--radius);
}

.inline-picker-slider {
    margin-bottom: 6px;
}

.inline-picker-slider label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.inline-conf-value {
    font-weight: bold;
    color: var(--primary-color);
}

.inline-conf-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #f44336, #ff9800, #4CAF50);
    border-radius: 3px;
    outline: none;
}

.inline-conf-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.inline-conf-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.inline-picker-preview {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
}

.inline-win {
    color: var(--success-color);
}

.inline-loss {
    color: var(--danger-color);
}

/* Inline Jackpot */
.inline-jackpot {
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
    margin-top: 6px;
}

.inline-jackpot label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--warning-color);
}

.inline-jackpot-margin {
    width: 55px;
    padding: 2px 4px;
    font-size: 0.75rem;
    border: 1px solid var(--warning-color);
    border-radius: var(--radius);
    text-align: right;
}

.inline-jackpot-error {
    display: none;
    font-size: 0.65rem;
    color: var(--danger-color);
    font-weight: 600;
    margin-top: 3px;
}

.inline-jackpot.jackpot-missing .inline-jackpot-margin {
    border-color: var(--danger-color);
    background: #fff5f5;
}

.inline-jackpot.jackpot-missing .inline-jackpot-error {
    display: block;
}

/* Inline Wager */
.inline-wager:empty {
    display: none;
}

.inline-wager {
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
    margin-top: 4px;
}

.inline-wager-team {
    margin-bottom: 4px;
}

.inline-wager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    margin-bottom: 3px;
}

.inline-wager-label {
    font-weight: 600;
    color: var(--text-color);
}

.inline-wager-avail {
    color: var(--text-light);
}

.inline-wager-row {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 3px;
}

.inline-wager-amount {
    width: 60px;
    padding: 2px 4px;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-align: right;
}

.inline-wager-max {
    padding: 2px 6px;
    font-size: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--card-bg);
    transition: var(--transition);
}

.inline-wager-max:hover {
    background: var(--bg-color);
}

.inline-wager-max:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.inline-wager-clear {
    padding: 2px 6px;
    font-size: 0.7rem;
    border: 1px solid var(--danger-color);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--card-bg);
    color: var(--danger-color);
    transition: var(--transition);
}

.inline-wager-clear:hover:not(:disabled) {
    background: var(--danger-color);
    color: white;
}

.inline-wager-clear:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.inline-wager-team.wager-locked {
    opacity: 0.4;
}

.inline-wager-team.wager-locked .inline-wager-amount {
    background: var(--bg-color);
}

.inline-wager-preview {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 600;
}

.inline-wager-win {
    color: var(--success-color);
}

.inline-wager-loss {
    color: var(--danger-color);
}

/* Games table in admin */
.games-table {
    font-size: 0.9rem;
}

.games-table th, .games-table td {
    padding: 8px 10px;
}
