/* Estilos personalizados para Rummikub - Optimizado para móviles */

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px; /* Tamaño base para evitar zoom en móviles */
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.25rem;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
    margin-bottom: 1rem;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.btn {
    min-height: 44px; /* Tamaño mínimo táctil recomendado */
    font-weight: 500;
}

.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* Optimización para móviles */
@media (max-width: 768px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .navbar-nav {
        text-align: center;
    }
    
    .card {
        margin-bottom: 0.75rem;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
    
    .card-text {
        font-size: 0.9rem;
    }
    
    /* Botones más grandes en móvil */
    .btn {
        min-height: 48px;
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    
    .btn-sm {
        min-height: 40px;
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Tablas responsivas */
.table-responsive {
    border-radius: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.score-table {
    min-width: 300px;
}

.score-table th,
.score-table td {
    padding: 0.5rem;
    text-align: center;
    white-space: nowrap;
}

.score-input {
    width: 70px;
    min-height: 44px;
    font-size: 1rem;
    text-align: center;
}

@media (max-width: 576px) {
    .score-table {
        font-size: 0.85rem;
    }
    
    .score-input {
        width: 60px;
        font-size: 0.9rem;
    }
    
    .score-table th,
    .score-table td {
        padding: 0.375rem 0.25rem;
    }
}

/* Badges y estados */
.game-status {
    font-size: 0.875rem;
    font-weight: 500;
}

.game-status.active {
    color: #198754;
}

.game-status.finished {
    color: #6c757d;
}

.winner-badge {
    background-color: #ffd700;
    color: #000;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

.position-badge {
    display: inline-block;
    min-width: 2rem;
    text-align: center;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.875rem;
}

.position-1 { background-color: #ffd700; color: #000; }
.position-2 { background-color: #c0c0c0; color: #000; }
.position-3 { background-color: #cd7f32; color: #fff; }
.position-default { background-color: #6c757d; color: #fff; }

/* Estadísticas */
.stats-card .card-body {
    text-align: center;
    padding: 1rem;
}

.stats-number {
    font-size: 1.75rem;
    font-weight: bold;
    color: #0d6efd;
    line-height: 1.2;
}

.stats-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

@media (max-width: 576px) {
    .stats-number {
        font-size: 1.5rem;
    }
    
    .stats-card .card-body {
        padding: 0.75rem;
    }
}

/* Login y formularios */
.login-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.login-card {
    border-radius: 1rem;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: white;
    text-align: center;
    padding: 1.5rem;
}

.login-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.form-floating {
    margin-bottom: 1rem;
}

.form-floating .form-control {
    border-radius: 0.5rem;
    min-height: 48px;
    font-size: 1rem;
}

.form-floating label {
    font-size: 0.9rem;
}

/* Alertas */
.alert {
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

/* Lista de juegos */
.game-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.game-card {
    border-left: 4px solid #0d6efd;
    transition: transform 0.2s ease;
}

.game-card:hover {
    transform: translateY(-2px);
}

.game-card.active {
    border-left-color: #198754;
}

.game-card.finished {
    border-left-color: #6c757d;
}

/* Navegación */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.navbar-toggler {
    border: none;
    padding: 0.25rem 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* Botones de acción flotantes */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

@media (max-width: 576px) {
    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
}

/* Animaciones */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar personalizado para webkit */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Optimizaciones táctiles */
button, .btn, a {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

/* Espaciado específico para móviles */
@media (max-width: 768px) {
    .mt-4 { margin-top: 1.5rem !important; }
    .mb-4 { margin-bottom: 1.5rem !important; }
    .py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
}

/* Grid responsivo para estadísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* Mejoras de accesibilidad */
.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Colores para diferentes tipos de fichas */
.tile-red { color: #dc3545; font-weight: bold; }
.tile-blue { color: #0d6efd; font-weight: bold; }
.tile-yellow { color: #ffc107; font-weight: bold; }
.tile-black { color: #212529; font-weight: bold; }

/* Footer pegajoso */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    flex: 1;
}

footer {
    margin-top: auto;
}

/* Estilos para el dashboard de estadísticas */
.bg-gradient {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.stats-icon {
    opacity: 0.8;
}

.stats-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.table th {
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 2px solid #dee2e6;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.table-info {
    background: linear-gradient(90deg, rgba(13, 202, 240, 0.1), rgba(13, 202, 240, 0.05)) !important;
    border-left: 4px solid #0dcaf0;
}

.position-badge {
    font-size: 0.875rem;
    font-weight: bold;
    padding: 0.375rem 0.5rem;
    border-radius: 50%;
    min-width: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.position-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.position-2 {
    background: linear-gradient(135deg, #c0c0c0, #e5e5e5);
    color: #000;
    box-shadow: 0 2px 4px rgba(192, 192, 192, 0.3);
}

.position-3 {
    background: linear-gradient(135deg, #cd7f32, #daa520);
    color: #fff;
    box-shadow: 0 2px 4px rgba(205, 127, 50, 0.3);
}

.position-default {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: #fff;
}

/* Responsive para estadísticas */
@media (max-width: 768px) {
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
    }
    
    .position-badge {
        min-width: 2rem;
        font-size: 0.75rem;
        padding: 0.25rem 0.375rem;
    }
    
    .stats-number {
        font-size: 1.5rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .bg-gradient h1 {
        font-size: 1.5rem;
    }
    
    .card-header h4,
    .card-header h5 {
        font-size: 1rem;
    }
}

/* Animaciones para el dashboard */
.fade-in .card {
    animation: slideInUp 0.6s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
