/* ===== Campo de texto elegante ===== */
.input-camara {
    background-color: rgba(40, 40, 40, 0.8);
    color: #fff;
    padding: 8px 12px;
    border: 2px solid #28a745;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    width: 300px;
}
.input-camara::placeholder {
    color: rgba(255, 255, 255, 0.6);
}
.input-camara:focus {
    border-color: #a6f5b5;
    box-shadow: 0 0 8px #28a745;
    background-color: rgba(50, 50, 50, 0.9);
}
/* ===== Botón verde animado ===== */
.btn-camara {
    background-color: #28a745;
    color: white;
    padding: 8px 16px;
    border: 2px solid #28a745;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    animation: bordeParpadeo 2s infinite;
}
.btn-camara:hover {
    background-color: #218838;
    transform: scale(1.05);
}
.btn-camara:active {
    background-color: #1e7e34;
    transform: scale(0.98);
}
/* Animación del borde del botón */
@keyframes bordeParpadeo {
    0%   { border-color: #28a745; box-shadow: 0 0 5px #28a745; }
    50%  { border-color: #a6f5b5; box-shadow: 0 0 15px #a6f5b5; }
    100% { border-color: #28a745; box-shadow: 0 0 5px #28a745; }
}
body {
    font-family: 'Inter', sans-serif;
    background-color: #0b0f19;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    background-color: #1a202c;
    border-radius: 1rem;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
}
.header {
    border-bottom: 2px solid #2d3748;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.game-area {
    background-color: #2d3748;
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.button {
    background-color: #4a5568;
    color: #cbd5e0;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
    text-align: center;
}
.button:hover {
    background-color: #718096;
    color: #fff;
}
.input-field {
    background-color: #4a5568;
    color: #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    width: 100%;
    box-sizing: border-box;
    border: 2px solid transparent;
}
.input-field:focus {
    outline: none;
    border-color: #63b3ed;
}
.table-header, .table-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
}
.table-header {
    background-color: #2d3748;
    font-weight: 600;
    border-bottom: 1px solid #4a5568;
}
.table-row {
    background-color: #4a5568;
    margin-bottom: 0.5rem;
}
/* Estilos mejorados para las mesas de billar */
.billiard-table {
    background: linear-gradient(135deg, #1a472a 0%, #0d2818 100%);
    border: 12px solid #8B4513;
    border-radius: 20px;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}
.billiard-table::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 10% 10%, rgba(255,255,255,0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 90%, rgba(255,255,255,0.05) 0%, transparent 20%);
    pointer-events: none;
}
.player-panel {
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow:
        0 10px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}
.player-panel:hover {
    transform: translateY(-5px);
}
.player-panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, #63b3ed, #4299e1);
}
.player-panel.player1::after {
    background: linear-gradient(90deg, #f6e05e, #ecc94b);
}
.player-panel.player2::after {
    background: linear-gradient(90deg, #e2e8f0, #cbd5e0);
}
.score-display {
    font-size: 5rem;
    font-weight: 900;
    line-height: 1;
    margin: 1rem 0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.score-display:hover {
    transform: scale(1.05);
}
.score-display.player1 {
    color: #f6e05e;
}
.score-display.player2 {
    color: #e2e8f0;
}
.score-display::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: currentColor;
    border-radius: 3px;
    opacity: 0.7;
}
.score-button {
    background: linear-gradient(145deg, #4a5568, #2d3748);
    border: none;
    color: #e2e8f0;
    font-weight: 700;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-size: 1rem;
}
.score-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
.score-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.score-button.positive {
    background: linear-gradient(145deg, #48bb78, #38a169);
}
.score-button.negative {
    background: linear-gradient(145deg, #f56565, #e53e3e);
}
.score-button.special {
    background: linear-gradient(145deg, #9f7aea, #805ad5);
}
.player-name {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    margin-bottom: 1rem;
    transition: all 0.2s;
}
.player-name:focus {
    outline: none;
    border-color: #63b3ed;
    background: rgba(255, 255, 255, 0.15);
}
.player-name.player1 {
    color: #1a202c;
    background: rgba(246, 224, 94, 0.2);
}
.player-name.player2 {
    color: #1a202c;
    background: rgba(226, 232, 240, 0.2);
}
.camera-container {
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.camera-url-input {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
    width: 100%;
    transition: all 0.2s;
}
.camera-url-input:focus {
    outline: none;
    border-color: #63b3ed;
    background: rgba(255, 255, 255, 0.15);
}
.camera-button {
    background: linear-gradient(145deg, #4299e1, #3182ce);
    color: white;
    border: none;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.camera-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
.reset-button {
    background: linear-gradient(145deg, #e53e3e, #c53030);
    color: white;
    border: none;
    font-weight: 700;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}
.table-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.table-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, #f6e05e, #ecc94b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.table-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: #a0aec0;
}
.ball-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.ball-icon.yellow {
    background: radial-gradient(circle at 30% 30%, #f6e05e, #d69e2e);
}
.ball-icon.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #e2e8f0);
}
.score-animation {
    animation: scoreChange 0.5s ease;
}
@keyframes scoreChange {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
/* ===== SECCIÓN DE CÁMARA MEJORADA (CONSOLIDADA Y SIN CONFLICTOS) ===== */
.camera-section {
    margin-bottom: 1rem;
    display: flex;          /* 1. Lo convierte en un contenedor flexible */
    flex-direction: column; /* 2. Apila los elementos (controles y visor) verticalmente */
    height: 100%;          /* 3. Ocupa el 100% de la altura de la celda de la cuadrícula */
    flex-grow: 1;
    min-width: 300px;
}

.camera-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.camera-status {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-loading { background-color: #fbbf24; color: #78350f; }
.status-recording { background-color: #10b981; color: #064e3b; }
.status-replay { background-color: #3b82f6; color: #1e3a8a; }
.status-fallback { background-color: #f59e0b; color: #78350f; }
.status-error { background-color: #ef4444; color: #ffffff; }

.recording-btn { background: linear-gradient(145deg, #10b981, #059669); }
.replay-btn { background: linear-gradient(145deg, #3b82f6, #2563eb); }
.replay-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hidden { display: none !important; }

/* VISOR DE CÁMARA FLEXIBLE - ÚNICA DEFINICIÓN */
.camera-viewer-container {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 2px solid #63b3ed;
    width: 100%;
    flex-grow: 1;
    min-height: 250px;
    box-shadow: 0 0 15px rgba(99, 179, 237, 0.5);
    background: #000;
    position: relative;
}

/* Asegura que el video y el iframe llenen el contenedor flexible */
.camera-viewer-container video,
.camera-viewer-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    object-fit: cover;
}

/* Media queries para ajustar la altura mínima, NO la altura fija */
@media (max-width: 768px) {
    .score-display { font-size: 3.5rem; }
    .table-title { font-size: 1.8rem; }
    .camera-viewer-container { min-height: 200px; } /* Ajuste para móviles */
}

/* Estilos para el modal de resumen */
.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background-color: #2d3748;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f6e05e;
}
.close-button {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}
.close-button:hover {
    color: #e2e8f0;
}
.modal-body {
    margin-bottom: 1.5rem;
}
.modal-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #4a5568;
}
.modal-row:last-child {
    border-bottom: none;
    font-weight: 700;
    font-size: 1.2rem;
    color: #48bb78;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}
.modal-button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.modal-button-secondary {
    background-color: #4a5568;
    color: #e2e8f0;
}
.modal-button-secondary:hover {
    background-color: #718096;
}
.modal-button-primary {
    background-color: #48bb78;
    color: white;
}
.modal-button-primary:hover {
    background-color: #38a169;
}
/* Estilos para el panel de usuario */
.user-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.user-info {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-weight: 600;
    color: #f6e05e;
}
.user-role {
    font-size: 0.8rem;
    color: #a0aec0;
}
.logout-button {
    background: none;
    border: none;
    color: #f56565;
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}
.logout-button:hover {
    color: #fc8181;
}
/* ===== FUERZA VISOR DE CÁMARA (SOLUCIÓN DEFINITIVA) ===== */
.camera-viewer-container {
    flex-grow: 1 !important;
    min-height: 300px !important;
    height: 100% !important;
    width: 100% !important;
    position: relative !important;
}

.camera-viewer-container video,
.camera-viewer-container iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    object-fit: cover !important;
}

#agentdvr-fallback-nuevo-1,
#agentdvr-fallback-nuevo-2,
#agentdvr-fallback-nuevo-3,
#agentdvr-fallback-nuevo-4,
#agentdvr-fallback-nuevo-5,
#agentdvr-fallback-nuevo-6 {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
}
/* --- Botón de Cerrar Sesión --- */
.logout-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999; /* Asegura que esté por encima de todo */
    background-color: #dc2626;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.logout-btn:hover {
    background-color: #b91c1c;
    transform: scale(1.05);
}

.logout-btn:active {
    background-color: #059669;
    transform: scale(0.95);
}
