/* Team status styles */
.team-row.inactive {
    opacity: 0.7;
    background-color: #f5f5f5;
}

.team-row.inactive:hover {
    opacity: 1;
    transition: opacity 0.2s;
}

.team-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.team-status.active {
    background-color: #4CAF50;
}

.team-status.inactive {
    background-color: #9E9E9E;
}

.team-status.waiting {
    background-color: #FFA500;
}

.team-filters {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

#sort-teams {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.panel-header h2 {
    margin: 0;
}

.header-parent-container {
    display: flex;
    align-items: stretch;
    gap: 20px;
    margin-bottom: 20px;
}

.qr-code-container {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.qr-code-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.qr-code-container p {
    font-size: 0.9em;
    margin: 0 0 15px 0;
}

.qr-code-container p a {
    font-size: 0.75em;
    color: #666;
}

.qr-code-container img {
    width: auto !important;
    height: auto !important;
    max-width: 150px;
    max-height: 150px;
}

.right-content-container {
    flex-grow: 1;
}

.right-content-container h1 {
    margin-top: 0;
    margin-bottom: 10px;
}

.right-content-container #connection-status-dash {
    margin-bottom: 15px;
}

body {
    font-family: Arial, sans-serif; 
    margin: 0; 
    padding: 20px; 
    background-color: #f0f2f5; 
    color: #333; 
}

.dashboard-container { 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
}

.panel { 
    background: white; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

h1, h2 { 
    color: #1c1e21; 
    margin-top: 0; 
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
}

#active-teams-table th {
    width: auto;  /* All columns - auto width */
}

#active-teams-table td {
    text-align: center;
}

/* Monospace font for numeric columns */
#active-teams-table td:nth-child(5),  /* Trace Avg */
#active-teams-table td:nth-child(6),  /* Balance */
#active-teams-table td:nth-child(7),  /* Balanced Random */
#active-teams-table td:nth-child(8) { /* CHSH Value */
    font-family: 'Courier New', monospace;
}

th, td { 
    text-align: center; 
    padding: 5px;
    border-bottom: 1px solid #ddd; 
}

th { 
    background-color: #f7f7f7; 
}

.status-connected { 
    color: green; 
}

.status-disconnected { 
    color: red; 
}

#connection-status-dash { 
    font-weight: bold; 
    margin-bottom: 10px; 
}

.metrics { 
    display: flex; 
    gap: 20px; 
    /* margin-bottom: 20px;  */
}

.metric-card { 
    flex: 1; 
    background-color: #e7f3ff; 
    padding: 15px; 
    border-radius: 5px; 
    text-align: center; 
}

.metric-card h3 { 
    margin: 0 0 10px 0; 
    font-size: 1.2em; 
    color: #0056b3; 
}

.metric-card p { 
    margin: 0; 
    font-size: 1.5em; 
    font-weight: bold; 
}

/* Comprehensive Stats Card Styles */
.comprehensive-stats {
    flex: 2; /* Take up more space than game control card */
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    border-left: 3px solid #0056b3;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

.stat-value {
    font-size: 1.4em;
    font-weight: bold;
    color: #0056b3;
}

/* Responsive design for stats grid */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .metrics {
        flex-direction: column;
    }
}

.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.metric-card button {
    padding: 8px 8px;
    background-color: #0056b3;
    color: white;
    border: 2px solid transparent; /* Default border for visual feedback */
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 5px;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

#pause-game-btn {
    background-color: #ffc107;
}

#pause-game-btn:hover {
    background-color: #e0a800;
}

#pause-game-btn.resume {
    background-color: #28a745;
}

#pause-game-btn.resume:hover {
    background-color: #218838;
}

.metric-card button:hover {
    background-color: #003d82;
    border-color: #4CAF50; /* Add hover border color for feedback */
}

.metric-card button.reset-game {
    background-color: #6c757d;
    border-color: #FFC107; /* Add border color for reset confirmation */
}


.metric-card button.confirm-reset {
    background-color: #dc3545;
}

.players-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 5px;
    font-weight: bold;
    /* text-align: right; */
    align-items: baseline;
}

.players-grid div:first-child, .players-grid div:nth-child(3) {
    color: rgb(100, 100, 100);
}

#ready-players-count {
    font-size: 1.5em;
    font-weight: bold;
}

/* Advanced Controls Section Styles */
.advanced-controls-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.control-section {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 20px;
    background-color: #f8f9fa;
}

.control-section h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.1em;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 8px;
}

/* Game Management Controls */
.game-management-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.reset-description {
    color: #6c757d;
    font-size: 0.95em;
    line-height: 1.4;
}

.reset-btn {
    background-color: #dc3545;
    color: white;
    align-self: flex-start;
}

.reset-btn:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

.reset-btn.confirm-reset {
    background-color: #ffc107;
    color: #212529;
    border: 2px solid #FFC107;
}

.reset-btn.confirm-reset:hover {
    background-color: #e0a800;
}



/* Game Mode Controls */
.game-mode-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.current-mode-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.mode-indicator {
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
}

.mode-indicator.classic {
    background-color: #e8f4f8;
    color: #0056b3;
    border: 1px solid #b3d7f0;
}

.mode-indicator.new {
    background-color: #e8f5e9;
    color: #28a745;
    border: 1px solid #b3e6b8;
}

.control-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.mode-toggle-btn {
    background-color: #6f42c1;
    color: white;
    align-self: flex-start;
}

.mode-toggle-btn:hover {
    background-color: #5a2d91;
    transform: translateY(-1px);
}

.mode-toggle-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.mode-description {
    background-color: white;
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid #6f42c1;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Theme Controls */
.theme-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.current-theme-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.theme-indicator {
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: capitalize;
    font-size: 0.9em;
    background-color: #e8f5e9;
    color: #28a745;
    border: 1px solid #b3e6b8;
}

.theme-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-selector label {
    font-weight: 500;
    color: #495057;
}

.theme-dropdown {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: white;
    color: #495057;
    font-size: 0.95em;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.theme-dropdown:hover,
.theme-dropdown:focus {
    border-color: #6f42c1;
    outline: none;
}

.theme-description {
    background-color: white;
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid #28a745;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Export Controls */
.export-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.export-description {
    color: #6c757d;
    font-size: 0.95em;
    line-height: 1.4;
}

.export-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.export-btn {
    background-color: #17a2b8;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.export-btn:hover {
    background-color: #138496;
    transform: translateY(-1px);
}

/* Responsive design for advanced controls */
@media (max-width: 768px) {
    .export-buttons {
        flex-direction: column;
    }
    
    .control-btn {
        width: 100%;
        text-align: center;
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    width: 80%;
    max-width: 600px;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-section {
    margin-bottom: 20px;
}

.details-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #f7f7f7;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.hash-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: #f7f7f7;
    padding: 10px;
    border-radius: 4px;
}

#correlation-matrix-table th, 
#correlation-matrix-table td {
    border: 1px solid #ddd;
    padding: 6px;
    text-align: center;
    font-family: monospace;
}

#correlation-matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
    table-layout: fixed; 
}

/* Styles for new classes in correlation matrix */
.corr-matrix-player1-label {
    writing-mode: vertical-lr; /* Lines stack left-to-right */
    width: 0px;
    vertical-align: middle;
    text-align: center;
}

.corr-matrix-player2-header { /* New class for Player 2 header */
    text-align: center;
}

.corr-matrix-error-cell { /* New class for error cell */
    text-align: center;
    padding: 10px;
}

.corr-matrix-row-item-label {
    width: 10%; /* Narrower for A/B/X/Y row labels */
}


.view-details-btn {
    background-color: #0056b3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
}

.view-details-btn:hover {
    background-color: #003d82;
}

/* Team row animation styles */
.team-row {
    position: relative;
    z-index: 1;
}

.team-row.moving {
    z-index: 2; /* Ensure moving rows stay above others */
    will-change: transform;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* Subtle shadow during movement */
}

.team-row.new-team {
    z-index: 1;
    will-change: opacity;
}

/* Styles moved from dashboard.html */
#pause-game-btn {
    display: none; /* Initially hidden */
}

#modal-team-id,
#modal-player1-sid,
#modal-player2-sid,
#modal-chsh-value,
#modal-cross-term-chsh {
    font-family: monospace;
}

#live-answer-log-header,
#teams-header,
#advanced-controls-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}

#live-answer-log-header h2,
#teams-header h2,
#advanced-controls-header h2 {
    margin: 0;
}

#toggle-chevron,
#teams-toggle-chevron,
#advanced-controls-chevron {
    font-weight: bold;
    margin-left: 5px;
    font-size: 1.1em;
}

.streaming-text {
    margin-right: 3px;
}


footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #666;
    /* background-color: #f8f9fa; */
    /* border-top: 1px solid #dee2e6; */
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

.footer-link {
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-link a {
    color: #495057;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.download-section {
    gap: 8px;
}

.download-section strong {
    color: #495057;
    margin-right: 8px;
}

.download-link {
    color: #007bff;
    text-decoration: none;
    margin: 0 6px;
    transition: color 0.2s ease;
}

.download-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

.download-separator {
    color: #6c757d;
    margin: 0 6px;
}

.session-info {
    color: #6c757d;
    /* font-size: 0.9em; */
    margin-top: 0px 6px;
}

.session-id {
    font-family: monospace;
    color: #495057;
    /* font-weight: 500; */
}

/* Spinning refresh icon styles */
.refresh-icon {
    display: inline-block;
    margin-left: 8px;
    margin-right: 10px;
    animation: spin 2s linear infinite;
    width: 25x;
    height: 25px;
    transform-origin: center center;
    vertical-align: middle;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(-360deg);
    }
}

/* New mode column visibility - hide extra columns when only showing success rate */
.new-mode #header-stat2,
.new-mode #header-stat3,
.new-mode #header-stat4,
.new-mode #active-teams-table tbody td:nth-child(6),
.new-mode #active-teams-table tbody td:nth-child(7),
.new-mode #active-teams-table tbody td:nth-child(8) {
    display: none !important;
}
