/**
 * Responsive Design - Mobile First
 * Sistema de diseño adaptativo para diferentes dispositivos
 */

/* ============================================
   BREAKPOINTS
   ============================================ */
/*
   - Mobile:        < 576px
   - Mobile Large:  576px - 767px
   - Tablet:        768px - 991px
   - Desktop:       992px - 1199px
   - Desktop Large: >= 1200px
*/

/* ============================================
   MOBILE FIRST: BASE STYLES (< 576px)
   ============================================ */

/* Navbar móvil */
@media (max-width: 767px) {
    .navbar {
        flex-direction: column;
        padding: 10px 15px;
        gap: 10px;
    }
    
    .navbar-brand h1 {
        font-size: 1.5em;
    }
    
    .navbar-user {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }
    
    .navbar-user span {
        font-size: 0.85em;
    }
    
    #logoutBtn {
        padding: 8px 15px;
        font-size: 0.85em;
    }
}

/* Container móvil */
@media (max-width: 767px) {
    .container {
        flex-direction: column;
        min-height: auto;
    }
    
    /* Sidebar como menú horizontal scrollable */
    .sidebar {
        width: 100%;
        padding: 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        position: sticky;
        top: 0;
        z-index: 100;
        background: white;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .menu {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 0;
        margin: 0;
    }
    
    .menu li {
        flex-shrink: 0;
        white-space: nowrap;
    }
    
    .menu li a {
        padding: 12px 15px;
        font-size: 0.9em;
        border-bottom: 3px solid transparent;
    }
    
    .menu li a.active {
        background-color: transparent;
        color: var(--primary-color);
        border-bottom-color: var(--primary-color);
    }
    
    .menu li a:hover {
        background-color: #f5f5f5;
        color: var(--primary-color);
    }
    
    /* Content móvil */
    .content {
        padding: 15px;
        overflow-y: visible;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .section-header h2 {
        font-size: 1.5em;
    }
}

/* ============================================
   DASHBOARD MÓVIL
   ============================================ */
@media (max-width: 767px) {
    /* Banner */
    .motogp-banner {
        height: 200px;
        margin: -15px -15px 20px -15px;
    }
    
    .banner-content h2 {
        font-size: 1.3em;
        padding: 0 10px;
    }
    
    .banner-actions {
        flex-direction: column;
        gap: 10px;
        padding: 0 10px;
    }
    
    .btn-banner {
        width: 100%;
        padding: 12px;
        font-size: 0.95em;
    }
    
    /* Cards del dashboard */
    .dashboard-grid-compact {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard-card-compact {
        padding: 15px;
    }
    
    .dashboard-card-compact h3 {
        font-size: 1.1em;
    }
    
    /* Stats cards */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-card h3 {
        font-size: 0.9em;
    }
    
    .stat-card .stat-number {
        font-size: 2em;
    }
}

/* ============================================
   TABLAS MÓVIL
   ============================================ */
@media (max-width: 767px) {
    /* Tablas scrollables horizontalmente */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    table {
        font-size: 0.85em;
        min-width: 600px;
    }
    
    table th,
    table td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    
    /* Columnas específicas más pequeñas */
    table th:first-child,
    table td:first-child {
        padding-left: 15px;
    }
    
    table th:last-child,
    table td:last-child {
        padding-right: 15px;
    }
    
    /* Botones en tablas */
    .btn-sm {
        padding: 5px 10px;
        font-size: 0.8em;
    }
}

/* ============================================
   CLASIFICACIÓN MÓVIL
   ============================================ */
@media (max-width: 767px) {
    #standingsTable {
        min-width: 650px;
    }
    
    .rider-badge {
        padding: 3px 6px;
        font-size: 0.75em;
        margin: 2px;
    }
    
    .standings-my-row {
        background: rgba(225, 6, 0, 0.05);
    }
}

/* ============================================
   CALENDARIO MÓVIL
   ============================================ */
@media (max-width: 767px) {
    #calendarTable {
        min-width: 700px;
    }
    
    .badge {
        font-size: 0.75em;
        padding: 4px 8px;
    }
}

/* ============================================
   MI EQUIPO MÓVIL
   ============================================ */
@media (max-width: 767px) {
    /* Header Mi Equipo */
    .my-team-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .pole-header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .pole-header-actions button {
        width: 100%;
    }
    
    /* Layout Mi Equipo */
    .my-team-selection-container {
        flex-direction: column;
        gap: 20px;
    }
    
    /* Slots */
    .my-team-slots-wrapper {
        width: 100%;
    }
    
    .my-team-slots {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }
    
    .slot-box {
        min-height: 70px;
    }
    
    .slot-label {
        font-size: 0.75em;
        padding: 5px;
    }
    
    .rider-slot-selection {
        min-height: 65px;
        padding: 8px;
    }
    
    .selected-rider-display .rider-number {
        font-size: 1.3em;
    }
    
    .selected-rider-display .rider-name {
        font-size: 0.75em;
    }
    
    .selected-rider-display .rider-team {
        font-size: 0.65em;
    }
    
    /* Riders grid */
    .my-team-available-riders {
        width: 100%;
    }
    
    .riders-group-section {
        margin-bottom: 15px;
    }
    
    .riders-group-header {
        padding: 10px 12px;
        font-size: 0.9em;
    }
    
    .riders-group-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
        padding: 10px;
    }
    
    .rider-card-selectable {
        padding: 10px;
    }
    
    .rider-card-selectable .rider-number {
        font-size: 1.2em;
    }
    
    .rider-card-selectable .rider-name {
        font-size: 0.8em;
    }
    
    .rider-card-selectable .rider-team {
        font-size: 0.7em;
    }
}

/* ============================================
   PODIUMS MÓVIL
   ============================================ */
@media (max-width: 767px) {
    /* Header Podiums */
    .pole-position-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .pole-header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    /* Selection grid */
    .pole-selection-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .pole-selection-card {
        padding: 15px;
    }
    
    .position-label {
        font-size: 0.9em;
    }
    
    /* Riders grid */
    .pole-riders-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .pole-rider-card {
        padding: 10px;
    }
    
    .pole-rider-card .rider-number {
        font-size: 1.2em;
    }
    
    .pole-rider-card .rider-name {
        font-size: 0.8em;
    }
}

/* ============================================
   MODALES MÓVIL
   ============================================ */
@media (max-width: 767px) {
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header h3 {
        font-size: 1.3em;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    /* Modal Podiums */
    .poles-table-container {
        overflow-x: auto;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    .poles-table {
        font-size: 0.85em;
        min-width: 500px;
    }
    
    .poles-table th,
    .poles-table td {
        padding: 8px 6px;
    }
    
    .rider-number {
        font-size: 0.9em;
    }
    
    .rider-name {
        font-size: 0.8em;
    }
}

/* ============================================
   FORMULARIOS MÓVIL
   ============================================ */
@media (max-width: 767px) {
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 0.9em;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Evitar zoom en iOS */
        padding: 12px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 1em;
    }
    
    /* Form grid */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ============================================
   PROFILE MÓVIL
   ============================================ */
@media (max-width: 767px) {
    .profile-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .profile-card {
        padding: 15px;
    }
    
    .profile-card h3 {
        font-size: 1.1em;
    }
}

/* ============================================
   TABLET: 768px - 991px
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {
    .sidebar {
        width: 200px;
    }
    
    .content {
        padding: 20px;
    }
    
    .dashboard-grid-compact {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .my-team-slots {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .riders-group-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

/* ============================================
   DESKTOP: >= 992px
   ============================================ */
@media (min-width: 992px) {
    .sidebar {
        width: 250px;
    }
    
    .content {
        padding: 30px;
    }
    
    .dashboard-grid-compact {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .my-team-slots {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .riders-group-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* ============================================
   DESKTOP LARGE: >= 1200px
   ============================================ */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .riders-group-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media (max-width: 767px) and (orientation: landscape) {
    .navbar {
        padding: 8px 15px;
    }
    
    .navbar-brand h1 {
        font-size: 1.3em;
    }
    
    .motogp-banner {
        height: 150px;
    }
    
    .menu li a {
        padding: 10px 12px;
    }
    
    .my-team-slots {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    
    .slot-box {
        min-height: 60px;
    }
}

/* ============================================
   SMALL MOBILE: < 400px
   ============================================ */
@media (max-width: 399px) {
    .navbar-brand h1 {
        font-size: 1.2em;
    }
    
    .menu li a {
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .my-team-slots {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .riders-group-grid {
        grid-template-columns: 1fr;
    }
    
    .btn-banner {
        font-size: 0.9em;
        padding: 10px;
    }
    
    table {
        font-size: 0.75em;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .navbar,
    .sidebar,
    .btn,
    .modal {
        display: none !important;
    }
    
    .content {
        padding: 0;
    }
    
    .content-section {
        display: block !important;
    }
}

/* ============================================
   ACCESIBILIDAD: REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   TOUCH DEVICES
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Aumentar área táctil */
    .btn,
    .menu li a,
    .rider-card-selectable,
    .pole-rider-card {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Eliminar hover effects en touch */
    .btn:hover,
    .menu li a:hover,
    .rider-card-selectable:hover,
    .pole-rider-card:hover {
        transform: none;
    }
    
    /* Feedback táctil en active */
    .btn:active,
    .menu li a:active,
    .rider-card-selectable:active,
    .pole-rider-card:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}
