/* ============================================================
   comparison.css — Player Shooting Comparison Page

   Top bar + controls bar + 2x2 court grid.
   Adapts grid based on number of active players.
   ============================================================ */

/* --- RESET & BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- TOP BAR --- */
.top-bar {
    background-color: #16213e;
    padding: 14px 24px;
    border-bottom: 2px solid #e94560;
    text-align: center;
    position: relative;
}

.back-link {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: #8892a8;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.back-link:hover {
    color: #e94560;
}

.app-title {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 1px;
}

.app-subtitle {
    font-size: 13px;
    color: #8892a8;
    margin-top: 2px;
}

/* --- CONTROLS BAR --- */
.controls-bar {
    background-color: #16213e;
    border-bottom: 1px solid #2a2a4a;
    padding: 12px 24px;
}

.controls-inner {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    max-width: 1400px;
    margin: 0 auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #e94560;
    letter-spacing: 1px;
}

/* --- SEARCH --- */
.search-group {
    min-width: 200px;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background-color: #0f3460;
    color: #ffffff;
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder {
    color: #5a6a8a;
}

.search-input:focus {
    border-color: #e94560;
}

.search-dropdown {
    list-style: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #0f3460;
    border: 1px solid #2a2a4a;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-dropdown li {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #1a2a4a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-headshot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    background-color: #1a2a4a;
    flex-shrink: 0;
}

.search-dropdown li:hover,
.search-dropdown li.active {
    background-color: #e94560;
    color: #ffffff;
}

.search-dropdown li .team-name {
    font-size: 11px;
    color: #8892a8;
    margin-left: 6px;
}

.search-dropdown li:hover .team-name,
.search-dropdown li.active .team-name {
    color: #ffcccc;
}

.search-dropdown .shot-count {
    font-size: 10px;
    color: #5a6a8a;
}

.search-dropdown .already-added {
    color: #4ecca3;
}

/* --- PLAYER TAGS --- */
.tags-group {
    justify-content: flex-end;
    min-height: 36px;
}

.player-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.player-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background-color: #0f3460;
    border-radius: 6px;
    font-size: 13px;
    border-left: 3px solid #4ecca3;
}

.tag-headshot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    background-color: #1a2a4a;
}

.player-tag-name {
    color: #ffffff;
    font-weight: 600;
}

.player-tag .player-team {
    font-size: 11px;
    color: #8892a8;
}

.player-tag-remove {
    background: none;
    border: none;
    color: #8892a8;
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.player-tag-remove:hover {
    color: #e94560;
}

/* --- FILTERS --- */
.filter-group {
    min-width: 0;
}

.filter-options {
    display: flex;
    gap: 4px 10px;
    flex-wrap: wrap;
}

.filter-options label {
    font-size: 12px;
    color: #a0a8b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.filter-options input[type="radio"] {
    accent-color: #e94560;
}

.filter-select {
    padding: 6px 8px;
    font-size: 12px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background-color: #0f3460;
    color: #ffffff;
    outline: none;
    cursor: pointer;
}

.filter-select:focus {
    border-color: #e94560;
}

/* --- COMPARISON GRID --- */
.comparison-main {
    flex: 1;
    padding: 12px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.comparison-grid {
    display: grid;
    gap: 16px;
    width: 100%;
    max-width: 1200px;
    /* Default: 2x2 */
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
}

/* Adaptive grid based on player count */
.comparison-grid.players-0 .court-panel,
.comparison-grid.players-1 .court-panel:nth-child(n+2),
.comparison-grid.players-2 .court-panel:nth-child(n+3),
.comparison-grid.players-3 .court-panel:nth-child(n+4) {
    /* Hide unused panels */
}

.comparison-grid.players-0 {
    grid-template-columns: 1fr;
    max-width: 600px;
}

.comparison-grid.players-1 {
    grid-template-columns: 1fr;
    max-width: 600px;
}

.comparison-grid.players-2 {
    grid-template-columns: 1fr 1fr;
    max-width: 1200px;
}

.comparison-grid.players-3,
.comparison-grid.players-4 {
    grid-template-columns: 1fr 1fr;
    max-width: 1200px;
}

/* --- COURT PANEL --- */
.court-panel {
    background-color: #16213e;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

/* --- EXPAND / MINIMIZE BUTTON --- */
.expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background-color: #0f3460;
    color: #8892a8;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    padding: 0;
    line-height: 1;
}

.expand-btn:hover {
    background-color: #e94560;
    border-color: #e94560;
    color: #ffffff;
}

/* Expanded panel — takes full grid width */
.court-panel.expanded {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    z-index: 5;
    border-color: #e94560;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
}

.court-panel.expanded .panel-court {
    max-height: none;
}

.court-panel.expanded .panel-court .court-svg {
    max-height: none;
}

/* Hide non-expanded panels when one is expanded */
.comparison-grid.has-expanded .court-panel:not(.expanded) {
    display: none !important;
}

/* Hide expand button on empty panels */
.court-panel.empty .expand-btn {
    display: none;
}

.court-panel.active {
    border-color: #3a3a5a;
}

.court-panel.empty {
    border-style: dashed;
    justify-content: center;
    min-height: 300px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.court-panel.empty:hover {
    opacity: 0.7;
    border-color: #e94560;
}

.empty-label {
    font-size: 14px;
    color: #5a6a8a;
    text-align: center;
}

.empty-label .plus-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
    color: #3a4a6a;
}

/* --- PANEL HEADER --- */
.panel-header {
    width: 100%;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a4a;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.panel-headshot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    background-color: #1a2a4a;
    border: 2px solid #3a3a5a;
}

.panel-player-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.panel-player-team {
    font-size: 12px;
    color: #8892a8;
    margin-left: 6px;
}

.panel-view-toggles {
    display: flex;
    gap: 2px;
    margin-left: auto;
    margin-right: 34px;
    padding: 2px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background-color: #0a1628;
}

.view-toggle-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    color: #6a7a9a;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.view-toggle-btn:hover {
    color: #c0c8d8;
    background-color: #1a2a4a;
}

.view-toggle-btn.active {
    background-color: #e94560;
    color: #ffffff;
}

/* --- PANEL COURT (SVG container) --- */
.panel-court {
    width: 100%;
    max-height: 320px;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.panel-court .court-svg {
    width: 100%;
    max-height: 320px;
    display: block;
}

/* --- PANEL STATS --- */
.panel-stats {
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #2a2a4a;
}

.panel-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    text-align: center;
}

.stat-box {
    padding: 6px 4px;
    background-color: #0f3460;
    border-radius: 6px;
}

.stat-box-label {
    font-size: 10px;
    color: #8892a8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-box-value {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-top: 2px;
}

.stat-box-value.good { color: #4ecca3; }
.stat-box-value.avg { color: #f0c040; }
.stat-box-value.poor { color: #e94560; }

.stat-box-detail {
    font-size: 10px;
    color: #6a7a9a;
    margin-top: 1px;
}

/* Zone splits compact row */
.panel-splits {
    margin-top: 6px;
}

.panel-splits-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.panel-splits-table th {
    text-align: left;
    padding: 3px 4px;
    color: #8892a8;
    font-weight: 600;
    font-size: 9px;
    text-transform: uppercase;
    border-bottom: 1px solid #2a2a4a;
}

.panel-splits-table td {
    padding: 3px 4px;
    color: #c0c8d8;
    border-bottom: 1px solid #1a2a3e;
}

.panel-splits-table .zone-name {
    color: #ffffff;
    font-weight: 500;
}

/* --- TOOLTIP --- */
.tooltip {
    position: fixed;
    background-color: #16213e;
    border: 1px solid #e94560;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: #e0e0e0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
    white-space: nowrap;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip .tip-label {
    font-weight: 600;
    color: #ffffff;
}

.tooltip .tip-made { color: #4ecca3; }
.tooltip .tip-missed { color: #e94560; }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .comparison-grid {
        grid-template-columns: 1fr;
        max-width: 600px;
    }

    .controls-inner {
        flex-direction: column;
        gap: 12px;
    }

    .search-group {
        width: 100%;
    }

    .panel-header {
        flex-wrap: wrap;
        justify-content: center;
    }

    .panel-view-toggles {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 12px 16px;
    }

    .back-link {
        position: static;
        display: block;
        transform: none;
        margin-bottom: 6px;
        text-align: left;
    }

    .controls-bar {
        padding: 10px 16px;
    }

    .comparison-main {
        padding: 12px;
    }
}
