/* Mobile-First Responsive Design for Sailing Elo */

/* ===== MOBILE BREAKPOINTS ===== */
/* Mobile: 320px - 768px */
/* Tablet: 768px - 1024px */
/* Desktop: 1024px+ */

/* ===== BASE MOBILE STYLES ===== */
@media (max-width: 768px) {
    
    /* ===== HEADER & NAVIGATION ===== */
    header {
        flex-direction: column;
        padding: 1rem;
        position: relative;
    }
    
    .logo {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    /* Mobile Navigation */
    nav {
        width: 100%;
    }
    
    nav ul {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    nav ul li {
        margin: 0;
        width: 100%;
    }
    
    nav ul li a {
        display: block;
        padding: 0.75rem;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
        text-align: center;
        transition: background 0.2s;
    }
    
    nav ul li a:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    /* Search input mobile */
    nav input[type="text"] {
        width: 100%;
        margin: 0.5rem 0 0 0;
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* ===== HERO SECTION ===== */
    .hero-text {
        position: static;
        transform: none;
        margin: 1rem;
        padding: 1rem;
        width: auto;
    }
    
    .hero-text h1 {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }
    
    .hero-text p {
        font-size: 1rem;
    }
    
    /* ===== MAIN CONTENT ===== */
    main {
        padding: 1rem;
    }
    
    section h2 {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
    }
    
    /* ===== CARDS & GRIDS ===== */
    .race-cards {
        flex-direction: column;
        gap: 1rem;
    }
    
    .race-card {
        width: 100%;
        max-width: none;
    }
    
    .competitor-cards {
        flex-direction: column;
        overflow-x: visible;
    }
    
    .competitor-card {
        width: 100%;
        max-width: none;
    }
    
    /* ===== TABLES - MOBILE RESPONSIVE ===== */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    table {
        min-width: 600px; /* Ensure table doesn't get too cramped */
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
    
    /* Mobile table card layout alternative */
    .table-mobile-cards {
        display: none;
    }
    
    .table-mobile-cards .card {
        background: white;
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .table-mobile-cards .card-header {
        font-weight: bold;
        color: #1b3a57;
        margin-bottom: 0.5rem;
        font-size: 1.1rem;
    }
    
    .table-mobile-cards .card-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.25rem;
        padding: 0.25rem 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .table-mobile-cards .card-label {
        font-weight: 600;
        color: #666;
        min-width: 80px;
    }
    
    .table-mobile-cards .card-value {
        color: #333;
        text-align: right;
        flex: 1;
    }
    
    /* ===== FORMS & FILTERS ===== */
    .filters-row {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .filter-group {
        width: 100%;
    }
    
    input[type="text"], 
    input[type="search"], 
    select, 
    textarea {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        border: 1px solid #ddd;
        border-radius: 4px;
        box-sizing: border-box;
    }
    
    button {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px;
        border: none;
        border-radius: 4px;
        background: #1b3a57;
        color: white;
        cursor: pointer;
        transition: background 0.2s;
    }
    
    button:hover {
        background: #2c4a67;
    }
    
    /* ===== PAGINATION ===== */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .pagination button {
        width: auto;
        min-width: 40px;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* ===== STATS & DASHBOARD ===== */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
        text-align: center;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.9rem;
    }
    
    /* ===== BREADCRUMBS ===== */
    .breadcrumb {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    
    .breadcrumb ol {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    /* ===== FOOTER ===== */
    footer ul {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    footer ul li {
        margin: 0;
    }
}

/* ===== TABLET STYLES ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    
    /* Header adjustments */
    header {
        padding: 1rem 1.5rem;
    }
    
    nav ul {
        gap: 1rem;
    }
    
    /* Grid adjustments */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Table adjustments */
    table {
        font-size: 0.95rem;
    }
    
    th, td {
        padding: 0.75rem 1rem;
    }
}

/* ===== ANALYSIS PAGE MOBILE ===== */
@media (max-width: 768px) {
    
    /* Analysis page layout */
    main {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    #sidebar {
        width: 100% !important;
        position: static !important;
        height: auto !important;
        overflow: visible !important;
        margin-bottom: 1rem;
    }
    
    #main-content {
        width: 100% !important;
        padding: 1rem !important;
        overflow: visible !important;
    }
    
    #graph-container {
        height: 400px !important;
        min-height: 400px;
    }
    
    /* Chart.js responsive */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ===== UTILITY CLASSES ===== */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* ===== TOUCH-FRIENDLY INTERACTIONS ===== */
@media (max-width: 768px) {
    
    /* Larger touch targets */
    a, button, input, select {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    *:hover {
        transform: none !important;
    }
    
    /* Better focus states for accessibility */
    a:focus, button:focus, input:focus, select:focus {
        outline: 2px solid #00a8ff;
        outline-offset: 2px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    header, footer, nav, .pagination, .filters-row {
        display: none !important;
    }
    
    main {
        padding: 0 !important;
    }
    
    table {
        font-size: 12px !important;
    }
    
    th, td {
        padding: 0.25rem !important;
    }
}
