/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --secondary-color: #50c878;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --success-color: #27ae60;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --border-color: #ddd;
    --text-color: #333;
    --text-muted: #777;
    --bg-color: #f5f7fa;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 16px;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--dark-color);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 16px;
}

.login-form {
    margin-top: 20px;
}

/* Navbar */
.navbar {
    background: var(--dark-color);
    color: white;
    padding: 15px 20px;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: bold;
}

.navbar-brand i {
    font-size: 24px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-size: 14px;
}

.btn-logout {
    color: white;
    text-decoration: none;
    font-size: 18px;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(255,255,255,0.1);
}

/* Sidebar */
.sidebar {
    background: white;
    padding: 20px 0;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
    position: sticky;
    top: 60px;
    z-index: 999;
    overflow-x: auto;
}

.sidebar {
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px 20px;
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    min-width: 80px;
}

.sidebar-item i {
    font-size: 20px;
}

.sidebar-item span {
    font-size: 12px;
}

.sidebar-item:hover,
.sidebar-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h1 {
    font-size: 28px;
    color: var(--dark-color);
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.card-header h2 {
    font-size: 20px;
    color: var(--dark-color);
}

.card-body {
    padding: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.stat-info h3 {
    font-size: 32px;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
}

.btn-secondary:hover {
    background: #555;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: var(--light-color);
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-color);
    white-space: nowrap;
}

.data-table td {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: rgba(74, 144, 226, 0.05);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow-y: auto;
    padding: 20px;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    margin: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    color: var(--dark-color);
}

.close {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.close:hover {
    color: var(--dark-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mb-3 {
    margin-bottom: 15px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-secondary {
    background: var(--text-muted);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar-brand span {
        display: none;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 10px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .login-card {
        padding: 20px;
    }
    
    .sidebar-item span {
        font-size: 11px;
    }
    
    .sidebar-item {
        padding: 12px 15px;
        min-width: 70px;
    }
    
    .usuarios-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .checkbox-content {
        padding: 12px;
    }
    
    .juego-table-wrapper {
        max-height: 60vh;
    }
    
    .juego-table {
        font-size: 12px;
        min-width: 400px;
    }
    
    .juego-table th,
    .juego-table td {
        padding: 8px;
    }
    
    .participante-name {
        font-size: 12px;
    }
    
    .participante-total {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .valor-input {
        padding: 8px;
        font-size: 16px;
    }
}

/* Usuarios Grid para selección de participantes */
.usuarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.usuario-checkbox-item {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: var(--transition);
}

.usuario-checkbox-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.1);
}

.usuario-checkbox-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.checkbox-label {
    display: block;
    padding: 15px;
    cursor: pointer;
    margin: 0;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-content {
    background: rgba(74, 144, 226, 0.1);
    border-color: var(--primary-color);
}

.checkbox-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: var(--transition);
}

.checkbox-content::before {
    content: '';
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    background: white;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-content::before {
    background: var(--primary-color);
    border-color: var(--primary-color);
    content: '✓';
    color: white;
    font-size: 18px;
    font-weight: bold;
}

.usuario-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.usuario-info strong {
    color: var(--dark-color);
    font-size: 16px;
}

.usuario-dni {
    color: var(--text-muted);
    font-size: 14px;
}

.orden-container {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.orden-label {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 14px;
    margin: 0;
}

.orden-input {
    width: 60px;
    padding: 8px;
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    background: white;
    color: var(--primary-color);
    cursor: default;
}

.orden-input:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.info-box {
    background: #e3f2fd;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-box p {
    margin: 5px 0;
    color: var(--dark-color);
}

.contador-participantes {
    font-weight: bold;
    font-size: 16px;
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.contador-insuficiente {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.contador-ok {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.contador-exceso {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Juego Tabla Dinámica */
.juego-container {
    width: 100%;
}

.juego-tabla {
    overflow: hidden;
}

.juego-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    margin-bottom: 20px;
}

.juego-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 500px;
}

.juego-table th,
.juego-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.ronda-header {
    background: var(--dark-color);
    color: white;
    font-weight: bold;
    position: sticky;
    left: 0;
    z-index: 10;
    min-width: 100px;
}

.ronda-number {
    background: var(--light-color);
    font-weight: bold;
    position: sticky;
    left: 0;
    z-index: 5;
    text-align: left;
    min-width: 100px;
}

.participante-header {
    background: var(--primary-color);
    color: white;
    font-weight: bold;
    min-width: 120px;
    vertical-align: bottom;
    padding: 15px 10px;
}

.participante-name {
    font-size: 14px;
    margin-bottom: 5px;
}

.participante-total-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.participante-total {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.btn-reingreso {
    font-size: 11px;
    padding: 4px 8px;
    margin-top: 5px;
}

/* Barra de progreso */
.participante-header-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 100%;
    min-height: 150px;
    position: relative;
    padding: 5px;
}

.participante-info-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
}

.participante-name {
    font-size: 14px;
    font-weight: bold;
    text-align: left;
    margin-bottom: 5px;
}

.progress-bar-container-vertical {
    width: 30px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: flex-end;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.progress-bar-vertical {
    width: 100%;
    min-height: 2px;
    border-radius: 15px 15px 0 0;
    transition: height 0.3s ease, background-color 0.3s ease;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-end;
}

.progress-green {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.progress-yellow {
    background: linear-gradient(90deg, #f39c12, #f1c40f);
}

.progress-orange {
    background: linear-gradient(90deg, #e67e22, #f39c12);
}

.progress-red {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.valor-cell {
    background: white;
    min-width: 100px;
}

.valor-display {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-color);
    display: block;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.valor-input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    font-size: 16px;
    text-align: center;
    font-weight: bold;
    transition: var(--transition);
    background: white;
}

.valor-input:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    background: #fff;
}

.ronda-row {
    transition: var(--transition);
}

.ronda-row:hover {
    background: rgba(74, 144, 226, 0.05);
}

.ronda-row.nueva-ronda {
    background: #fff3cd;
}

.ronda-row.nueva-ronda .ronda-number {
    background: #ffc107;
    color: var(--dark-color);
}

.ronda-form {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .sidebar-item,
    .btn-logout {
        min-height: 44px;
        min-width: 44px;
    }
    
    .data-table tbody tr {
        border-bottom: 2px solid var(--border-color);
    }
    
    .checkbox-label {
        min-height: 60px;
    }
    
    .valor-input {
        min-height: 48px;
        font-size: 18px;
    }
}

