/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM - Tolosa CF Eskubaloia
   Diseño optimizado para Navegadores Móviles (Safari/Chrome)
   ========================================================================== */

@media (max-width: 768px) {
    /* 1. REGLAS CRÍTICAS DE INTERACCIÓN (iOS Safari Fixes) */
    input, textarea, select {
        font-size: 1rem !important; /* Mínimo 16px para evitar zoom automático en iOS */
        -webkit-user-select: text !important;
        user-select: text !important;
        touch-action: manipulation; /* Elimina delay de 300ms */
        border-radius: var(--radius-sm);
    }

    body {
        display: block !important; /* Reset de flex estructural */
        padding-bottom: 20px;
    }

    #app-container {
        display: block !important;
        min-height: 100vh;
    }

    /* 2. HEADER Y NAVEGACIÓN (Layout de 2 Filas) */
    .glass-header {
        flex-direction: column;
        padding: 0.75rem 0 0 0;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        z-index: 1000;
        border-radius: 0 0 1.5rem 1.5rem;
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }

    .header-logo {
        width: 100%;
        justify-content: center;
        padding: 0 1rem;
    }

    .header-logo img {
        height: 32px;
    }

    .header-logo h1 {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    /* Nav como barra de Tabs Horizontal Scrollable */
    nav {
        width: 100%;
        overflow-x: auto;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 0 0.75rem 0.5rem 0.75rem;
        gap: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Ocultar scrollbar Firefox */
    }

    nav::-webkit-scrollbar {
        display: none; /* Ocultar scrollbar Chrome/Safari */
    }

    nav .nav-btn {
        flex: 0 0 auto; /* No permitir que se encojan */
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-height: 44px;
        background: transparent;
        border: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    nav .nav-btn i {
        font-size: 1.2rem;
    }

    nav .nav-btn span {
        display: inline-block;
    }

    nav .nav-btn.active {
        background: rgba(59, 130, 246, 0.1);
        color: var(--accent-primary);
        box-shadow: none;
    }

    .season-selector-wrapper {
        margin-left: auto;
        padding-left: 0.5rem;
    }

    .season-select {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }

    /* 3. CONTENIDO PRINCIPAL */
    main {
        padding: 1rem 0.75rem;
        display: block !important;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* 4. DASHBOARD Y CARDS */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-card .value {
        font-size: 1.5rem;
    }

    /* Lista de Partidos */
    .match-item {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
    }

    .match-info {
        width: 100%;
    }

    .match-result {
        width: 100%;
        justify-content: center;
        padding: 0.75rem;
        background: rgba(255,255,255,0.03);
        border-radius: var(--radius-sm);
    }

    /* 5. FORMULARIOS Y MODALES */
    .form-card {
        padding: 1.25rem 1rem;
        margin-bottom: 1rem;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        font-size: 1rem;
    }

    /* Auth Modal como Bottom Sheet */
    #auth-modal {
        display: none;
        align-items: flex-end; /* Posicionar abajo */
        padding: 0;
    }

    #auth-modal .auth-card {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        margin: 0;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* 6. TABLAS DE ESTADÍSTICAS */
    .table-container, .stats-container {
        margin: 0 -0.75rem; /* Sangrado negativo para que el scroll llegue al borde */
        padding: 0 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 560px;
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
    }

    /* 7. PARTIDO EN VIVO (Botones de Jugador) */
    .live-players-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .live-player-btn {
        min-height: 52px;
        padding: 0.5rem !important;
        font-size: 0.9rem !important;
    }
}

/* BREAKPOINT: iPhone SE y Móviles muy pequeños */
@media (max-width: 380px) {
    nav .nav-btn span {
        display: none; /* Solo iconos en pantallas diminutas */
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .header-logo h1 {
        font-size: 0.85rem;
    }
}

/* BREAKPOINT: Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .glass-header {
        padding: 1rem;
    }
}
