/* Stats Popup Styles - CSP Compliant, No Inline Styles */
.stats-popup {
    position: fixed;
    top: 1%;
    left: 50%;
    transform: translate(-50%, 0%);
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 100%);
    border: 2px solid #ff6b35;
    border-radius: 10px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    background: rgba(10, 14, 26, 0.96);
    color: #c8d0e0;
    font-size: 12px;
    max-width: 95vw;
    width: auto;
    min-width: 1600px;
    display: none;
}



.stats-popup.popup-hidden {
    display: none;
}

.stats-popup.popup-visible {
    display: block;
}

.stats-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999;
    display: none;
}

.stats-popup-overlay.overlay-visible {
    display: block;
}

.popup-header {
    justify-content: space-between;
	
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 15px;
    border-bottom: 1px solid #ff6b35;
    background: rgba(42, 42, 78, 0.5);
    border-radius: 8px 8px 0 0;	
}

.popup-title {
    font-weight: bold;
    color: #ffaa66;
    font-size: 18px;
    display: flex;
    gap: 8px;
	flex: 1;
	justify-content: left;
}

.close-popup {
    cursor: pointer;
    font-weight: bold;
    color: #ff6b35;
    font-size: 18px;
}

.close-popup:hover {
    color: #ffaa66;
}

.popup-content {
    padding: 10px 15px;
    max-height: 85vh;
    overflow-y: auto;
}

.map-info-header {
    display: flex;
    flex-wrap: nowrap;          /* Keep everything on one row */
    align-items: baseline;
    gap: 10px;
    margin: 5px 0 10px 0;
    overflow-x: auto;           /* Allow horizontal scroll only if absolutely necessary */
    padding-bottom: 4px;        /* Space for scrollbar if needed */
}

.map-info-header h5 {
	flex-shrink: 0;
    margin: 0;
    color: #ffaa66;
    font-size: 12px;
    border-left: 2px solid #ff6b35;
    padding-left: 8px;
}

.map-info-text {
    flex-shrink: 1;
    flex-grow: 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: inline-block;      /* Helps prevent block-level expansion */	
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

.map-info-tip-inline {
    flex-shrink: 1;
    flex-grow: 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: inline-block;      /* Helps prevent block-level expansion */
}

.map-warning-text {
    flex-shrink: 1;
    flex-grow: 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: inline-block;      /* Helps prevent block-level expansion */	
    background: rgba(74, 58, 42, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #ffaa66;
}

.graphs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0;
}

.graph-card {
    flex: 1;
    min-width: 380px;
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    padding: 6px 10px;
    border: 1px solid #3a4055;
}

.graph-card h5 {
    margin: 0 0 5px 0;
    color: #ffaa66;
    font-size: 11px;
    border-left: 2px solid #ff6b35;
    padding-left: 6px;
}

.graph-svg-container {
    width: 100%;
    overflow-x: auto;
}

.graph-svg {
    width: 100%;
    min-width: 370px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.dual-axis-svg {
    width: 100%;
    min-width: 370px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.graph-grid {
    stroke: #3a4055;
    stroke-width: 0.5;
    stroke-dasharray: 3;
}

.graph-axis {
    stroke: #5a7a9a;
    stroke-width: 1;
}

.graph-label-left {
    fill: #66aaff;
    font-size: 8px;
    font-family: monospace;
    text-anchor: end;
}

.graph-label-right {
    fill: #ff6666;
    font-size: 8px;
    font-family: monospace;
    text-anchor: start;
}

.graph-axis-label-left {
    fill: #66aaff;
    font-size: 8px;
    text-anchor: middle;
}

.graph-axis-label-right {
    fill: #ff6666;
    font-size: 8px;
    text-anchor: middle;
}

.graph-axis-label-bottom {
    fill: #888;
    font-size: 7px;
    text-anchor: middle;
}

.graph-area-team1 {
    fill: rgba(102, 170, 255, 0.12);
}

.graph-area-team2 {
    fill: rgba(255, 102, 102, 0.12);
}

.graph-line-team1 {
    fill: none;
    stroke: #66aaff;
    stroke-width: 1.5;
}

.graph-line-team2 {
    fill: none;
    stroke: #ff6666;
    stroke-width: 1.5;
}

.graph-point-team1 {
    fill: #66aaff;
}

.graph-point-team2 {
    fill: #ff6666;
}

.graph-waiting {
    color: #aaa;
    text-align: center;
    padding: 15px;
    font-size: 11px;
}

.two-column-layout {
    display: flex;
    gap: 15px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.two-column-layout .column {
    flex: 1;
    min-width: 240px;
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    padding: 6px 10px;
    border: 1px solid #3a4055;
}

.popup-content h5 {
    margin: 5px 0 5px 0;
    color: #ffaa66;
    font-size: 12px;
    border-left: 2px solid #ff6b35;
    padding-left: 6px;
}

.popup-content .stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
    padding: 2px 0;
    border-bottom: 1px solid #3a4055;
    font-size: 11px;
}

.popup-content .stat-label {
    font-weight: bold;
    color: #8ab3cf;
}

.popup-content .stat-value {
    color: #ffaa66;
}

.popup-content .stat-value.password-enabled {
    color: #ff6666;
}

.match-summary {
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    padding: 6px 10px;
    margin: 6px 0;
    border: 1px solid #3a4055;
}

.match-summary-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
}

.match-summary-map {
    color: #ffaa66;
    font-weight: bold;
    margin-right: 8px;
}

.match-summary-stats {
    color: #8ab3cf;
    margin-left: 8px;
}

.match-summary-tickets-team1 {
    color: #66aaff;
    font-weight: bold;
}

.match-summary-tickets-team2 {
    color: #ff6666;
    font-weight: bold;
}

.match-summary-vs {
    color: #aaa;
}

.match-summary-leader {
    color: #ffaa66;
    margin-left: 8px;
}

.match-summary-kills-team1 {
    color: #66aaff;
}

.match-summary-kills-team2 {
    color: #ff6666;
}

.match-summary-kills-sep {
    color: #aaa;
}

.teams-container {
    display: flex;
    gap: 15px;
    margin: 8px 0;
    flex-wrap: wrap;
	align-items: stretch; /* already default, but explicit */
}

.team-column {
    flex: 1;
    min-width: 440px;
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    padding: 6px 8px;
    border: 1px solid #3a4055;
    display: flex;
    flex-direction: column;
    height: auto; /* allow natural height, but flex stretch will match */	
}

.team-column .players-table {
    flex: 1;
}

.team-header {
    text-align: center;
    font-weight: bold;
    padding: 4px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
}

.team-header.team1 {
    background: rgba(42, 74, 106, 0.8);
    color: #66aaff;
}

.team-header.team2 {
    background: rgba(74, 42, 42, 0.8);
    color: #ff6666;
}

.team-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 6px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
}

.team-stats-empty {
    text-align: center;
    padding: 8px;
    color: #aaa;
}

.team-stats .kills-line {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}

.team-stats .rank-highlight {
    color: #ffaa66;
    font-weight: bold;
    font-size: 12px;
    margin-top: 3px;
    border-top: 1px solid #3a4055;
    padding-top: 3px;
}

.players-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}

.players-table th,
.players-table td {
    padding: 3px 4px;
    text-align: left;
    border-bottom: 1px solid #3a4055;
}

.players-table th {
    background: #2a2a4e;
    color: #ffaa66;
    font-weight: bold;
    font-size: 10px;
}

.players-table .team-1 {
    color: #66aaff;
}

.players-table .team-2 {
    color: #ff6666;
}

.players-table .rank-cell {
    font-weight: bold;
    color: #ffaa66;
}

.players-table .negative-kills {
    color: #ff8888;
}

.player-link-cell {
    padding: 0;
}

.player-stats-link {
    display: block;
    padding: 3px 4px;
    color: inherit;
    text-decoration: none;
}

.player-stats-link:hover {
    text-decoration: underline;
    background: rgba(255, 255, 255, 0.05);
}

.team-1 .player-stats-link:hover {
    color: #88ccff;
}

.team-2 .player-stats-link:hover {
    color: #ff8888;
}

.time-of-day {
    color: #88ccff;
}

.player-count-badge.clickable {
    cursor: pointer;
}

.clickable-status {
    cursor: pointer;
    border-bottom: 1px dashed #ff6b35;
}

@media (max-width: 1600px) {
    .stats-popup {
        min-width: 95vw;
    }
    .graphs-container {
        flex-direction: column;
    }
    .team-column {
        min-width: 100%;
    }
    .two-column-layout {
        flex-direction: column;
    }
    .match-summary-row {
        flex-direction: column;
        gap: 5px;
    }
}



.map-info-tip {
    margin: 2px 0;
    font-size: 10px;
    color: #aaa;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
}



@media (max-width: 1600px) {
    .map-info-tip-inline {
        white-space: normal;
    }
}


.graph-point-team1, .graph-point-team2 {
    r: 2px;
    cursor: pointer;
}

.graph-point-team1:hover, .graph-point-team2:hover {
    r: 6px;
    filter: brightness(1.2);
}


/* Expandable server/settings panel */
details.server-settings-details {
    margin: 8px 0;
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    border: 1px solid #3a4055;
    padding: 4px;
}

details.server-settings-details summary {
    cursor: pointer;
    font-size: 11px;
    padding: 6px 12px;
    color: #ffaa66;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    outline: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

details.server-settings-details summary::-webkit-details-marker {
    display: none;
}

details.server-settings-details summary::before {
    content: '▶';
    font-size: 10px;
    margin-right: 8px;
    transition: transform 0.2s;
}

details.server-settings-details[open] summary::before {
    content: '▼';
}

details.server-settings-details .two-column-layout {
    margin-top: 8px;
}






/* Two‑column grid for server details inside the expandable area */
.server-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    margin-top: 8px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 2px 4px;
    border-bottom: 1px solid #3a4055;
}

.detail-label {
    font-weight: bold;
    color: #8ab3cf;
}

.detail-value {
    color: #ffaa66;
}

/* Ensure the details element has proper styling (if not already present) */
details.server-settings-details {
    margin: 8px 0;
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    border: 1px solid #3a4055;
    padding: 4px;
}

details.server-settings-details summary {
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    color: #ffaa66;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    outline: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

details.server-settings-details summary::-webkit-details-marker {
    display: none;
}

details.server-settings-details summary::before {
    content: '▶';
    font-size: 10px;
    margin-right: 8px;
    transition: transform 0.2s;
}

details.server-settings-details[open] summary::before {
    content: '▼';
}


.team-stats-placeholder {
    opacity: 0.5;
    text-align: center;
}



.players-table .empty-row td {
    text-align: center;
    color: #aaa;
}




.match-summary .avg-rank-team1 {
    color: #66aaff;   /* IS team color (light blue) */
}

.match-summary .avg-rank-team2 {
    color: #ff6666;   /* Clan team color (light red) */
}



/* Responsive adjustments for popup */
@media (max-width: 1200px) {
    .stats-popup {
        min-width: 95vw;
        width: 95vw;
        left: 2.5%;
        transform: none;
    }
    
    .graphs-container {
        flex-direction: column;
    }
    
    .graph-card {
        min-width: auto;
        width: 100%;
    }
    
    .graph-svg,
    .dual-axis-svg {
        min-width: auto;
        width: 100%;
    }
    
    .team-column {
        min-width: 100%;
    }
    
    .map-info-header {
        flex-wrap: wrap;
    }
}

@media (max-width: 700px) {
    .stats-popup {
        top: 1%;
        left: 1%;
        right: 1%;
        width: 98%;
        transform: none;
        min-width: auto;
    }
    
    .popup-content {
        padding: 5px;
    }
    
    .players-table th,
    .players-table td {
        font-size: 9px;
        padding: 2px 2px;
    }
    
    .team-stats .kills-line {
        flex-direction: column;
        gap: 2px;
    }
}




/* Graphs container – side by side with wrapping, no overlap */
.graphs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0;
}

.graph-card {
    flex: 1 1 180px;          /* grow, shrink, base width 380px */
    min-width: 280px;         /* allow smaller on narrow windows */
    background: rgba(22, 26, 37, 0.9);
    border-radius: 6px;
    padding: 6px 10px;
    border: 1px solid #3a4055;
    overflow-x: auto;         /* scroll inside card if content overflows */
}

.graph-card h5 {
    margin: 0 0 5px 0;
    color: #ffaa66;
    font-size: 11px;
    border-left: 2px solid #ff6b35;
    padding-left: 6px;
}

.graph-svg-container {
    width: 100%;
    overflow-x: auto;         /* horizontal scroll for the SVG if needed */
}

.graph-svg,
.dual-axis-svg {
    display: block;
    width: 100%;
    min-width: 350px;         /* ensure readability, triggers scroll in container */
    height: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

/* When window gets too narrow for two columns, switch to vertical */
@media (max-width: 850px) {
    .graphs-container {
        flex-direction: column;
    }
    .graph-card {
        min-width: auto;
    }
}

.team-header-ffa {
    text-align: center;
    font-weight: bold;
    padding: 4px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 12px;
    background: rgba(255, 170, 102, 0.3);
    color: #ffaa66;
}


.live-label {
    font-weight: bold;
    font-size: 16px;                /* bigger */
    color: #aaa;
    background: rgba(255, 107, 53, 0.1);
    padding: 2px 50px;
    border-radius: 4px;
    border: 1px solid rgba(255, 107, 53, 0.3);
    white-space: nowrap;
}

.historic-link {
    color: #88ccff;
    text-decoration: none;
    font-size: 14px;
    padding: 5px 12px;
    border-radius: 4px;
    transition: background 0.2s, border 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.15);   /* dim outline */
    background: rgba(255, 255, 255, 0.03);
    white-space: nowrap;
    flex-shrink: 0;
}

.historic-link:hover {
    background: rgba(136, 204, 255, 0.15);
    border-color: rgba(136, 204, 255, 0.3);
    text-decoration: underline;
}

.close-popup {
    cursor: pointer;
    font-weight: bold;
    color: #ff6b35;
    font-size: 18px;
    padding: 0 4px;
    flex-shrink: 0;
}

.close-popup:hover {
    color: #ffaa66;
}

/* Responsive adjustments for header */
@media (max-width: 600px) {
    .popup-header {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .popup-title {
        justify-content: center;
    }
    .historic-link {
        align-self: center;
    }
    .close-popup {
        align-self: flex-end;
    }
}







/* Popup header */
.popup-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 15px;
    border-bottom: 1px solid #ff6b35;
    background: rgba(42, 42, 78, 0.5);
    border-radius: 8px 8px 0 0;
}

/* Left: server name */
.server-name-left {
    font-weight: bold;
    color: #ffaa66;
    font-size: 16px;
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 100px;
}

/* Center: Live Battlezone Telemetry */
.live-label-center {
    font-weight: normal;
    font-size: 14px;
    color: #aaa;
    background: rgba(255, 107, 53, 0.2);
    padding: 4px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 107, 53, 0.3);
    white-space: nowrap;
    flex: 1;
    text-align: center;
    min-width: 120px;
}

/* Right actions: historic link + close button */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.historic-link {
    color: #88ccff;
    text-decoration: none;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 4px;
    transition: background 0.2s, border 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
    white-space: nowrap;
}

.historic-link:hover {
    background: rgba(136, 204, 255, 0.15);
    border-color: rgba(136, 204, 255, 0.3);
    text-decoration: underline;
}

.close-popup {
    cursor: pointer;
    font-weight: bold;
    color: #ff6b35;
    font-size: 18px;
    padding: 0 4px;
}

.close-popup:hover {
    color: #ffaa66;
}

/* Responsive: stack on narrow screens */
@media (max-width: 700px) {
    .popup-header {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .server-name-left,
    .live-label-center {
        flex: none;
        text-align: center;
        width: 100%;
    }
    .header-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
}










/* Popup header */
.popup-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-bottom: 1px solid #ff6b35;
    background: rgba(42, 42, 78, 0.5);
    border-radius: 8px 8px 0 0;
}

.popup-server-name {
    justify-self: start;
    font-weight: bold;
    color: #ffaa66;
    font-size: 16px;
    white-space: nowrap;
}

.live-label {
    justify-self: center;
    font-weight: bold;
    font-size: 16px;
    color: #aaa;
    background: rgba(255, 107, 53, 0.05);
    padding: 2px 50px;
    border-radius: 4px;
    border: 1px solid rgba(255, 107, 53, 0.3);
    white-space: nowrap;
}

.header-right {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
}

.historic-link {
    color: #88ccff;
    text-decoration: none;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 4px;
    transition: background 0.2s, border 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.historic-link:hover {
    background: rgba(136, 204, 255, 0.15);
    border-color: rgba(136, 204, 255, 0.3);
    text-decoration: underline;
}

.close-popup {
    cursor: pointer;
    font-weight: bold;
    color: #ff6b35;
    font-size: 18px;
    padding: 0 4px;
}

/* Responsive: stack on narrow screens */
@media (max-width: 600px) {
    .popup-header {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .popup-server-name {
        justify-self: center;
    }
    .live-label {
        justify-self: center;
    }
    .header-right {
        justify-self: center;
    }
}