/* Responsive Design Styles */

/* Mobile First Approach - Base styles are for mobile */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
    
    .search-box input {
        width: 250px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
    
    .search-box input {
        width: 300px;
    }
    
    .nav-tabs {
        flex-direction: row;
    }
    
    .modal-content {
        width: 80%;
        max-width: 500px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    .search-box input {
        width: 350px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .search-box input {
        width: 400px;
    }
}

/* Extra extra large devices (very large desktops, 1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1600px;
    }
}

/* Mobile-specific styles (max-width: 768px) */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    /* Header layout on mobile */
    .header {
        padding: 1rem 0;
        min-height: auto;
    }
    
    .header h1 {
        font-size: var(--font-size-xl);
    }

    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        position: relative;
        min-height: auto;
    }

    .header-title {
        flex: 1;
        min-width: 0;
        text-align: left;
        padding-right: 0;
        overflow: hidden;
    }

    .header-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .header-title h1 {
        font-size: var(--font-size-lg);
        margin-bottom: 0;
        line-height: var(--line-height-tight);
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal;
    }

    .global-season-selector {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

    .global-season-selector label {
        font-size: var(--font-size-sm);
        flex-shrink: 0;
    }

    .global-season-selector select {
        flex: 1;
        max-width: 200px;
        font-size: var(--font-size-sm);
        min-width: 140px;
    }

    #user-info {
        position: absolute;
        top: 0.75rem;
        right: 1rem;
        z-index: 10;
    }

    .user-menu-trigger {
        padding: 0.35rem 0.65rem;
        font-size: var(--font-size-sm);
        gap: 0.4rem;
    }

    .user-avatar {
        width: 26px;
        height: 26px;
        font-size: var(--font-size-xs);
    }

    .user-name {
        display: none;
    }

    .user-menu-arrow {
        font-size: var(--font-size-xs);
    }

    .user-menu-dropdown {
        min-width: 200px;
        right: 0;
        top: calc(100% + 0.25rem);
    }

    .nav-tabs-container {
        margin-bottom: 1rem;
    }

    .nav-tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: auto;
        min-width: max-content;
    }
    
    .nav-tab {
        flex: 0 0 auto;
        min-width: 100px;
        padding: 0.75rem 0.75rem;
        font-size: var(--font-size-sm);
        border-bottom: none;
        border-right: 1px solid #e9ecef;
    }
    
    .nav-tab:last-child {
        border-right: none;
    }

    .search-box {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box input {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .table {
        font-size: var(--font-size-sm);
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }
    
    /* Hide less important columns on mobile */
    .table .hide-mobile {
        display: none;
    }
    
    /* Stack table cells vertically on very small screens */
    .table-responsive-stack {
        display: block;
        width: 100%;
    }
    
    .table-responsive-stack thead {
        display: none;
    }
    
    .table-responsive-stack tbody,
    .table-responsive-stack tr,
    .table-responsive-stack td {
        display: block;
        width: 100%;
    }
    
    .table-responsive-stack tr {
        border: 1px solid #dee2e6;
        margin-bottom: 1rem;
        border-radius: 0.25rem;
        padding: 0.5rem;
    }
    
    .table-responsive-stack td {
        border: none;
        padding: 0.25rem 0;
        text-align: left;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label) ": ";
        font-weight: var(--font-weight-bold);
        display: inline-block;
        width: 40%;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1.5rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        margin: 0.25rem 0;
        width: 100%;
    }

    .category-tabs-container {
        margin: 0.75rem 0;
    }

    .category-tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .category-tab {
        flex: 0 0 auto;
        text-align: center;
        min-width: 80px;
        padding: 0.5rem 0.75rem;
        font-size: var(--font-size-sm);
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination button {
        padding: 0.375rem 0.75rem;
        font-size: var(--font-size-sm);
    }

    /* Form adjustments for mobile */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Button adjustments for mobile */
    .btn {
        padding: 0.75rem 1rem;
        font-size: var(--font-size-base);
        min-height: 44px; /* iOS touch target minimum */
    }
    
    /* Shorter button labels on mobile */
    .btn .btn-text-full {
        display: inline !important;
    }
    
    .btn .btn-text-mobile {
        display: none !important;
    }
    
    @media (max-width: 768px) {
        .btn .btn-text-full {
            display: none !important;
        }
        
        .btn .btn-text-mobile {
            display: inline !important;
        }
    }
    
    /* Tab toolbar adjustments for mobile */
    .tab-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .tab-toolbar > div:first-child {
        width: 100%;
    }
    
    /* Export button container adjustments for mobile */
    .export-button-container {
        width: 100%;
    }
    
    .export-button-container .btn-export {
        width: 100%;
        justify-content: center;
    }

    /* Header adjustments for mobile - already handled above */

    /* Status bar adjustments */
    .status-bar {
        font-size: var(--font-size-sm);
        padding: 0.75rem;
    }

    /* Loading message adjustments */
    .loading {
        padding: 1.5rem;
        font-size: var(--font-size-sm);
    }

    /* Race number badge adjustments */
    .race-number {
        font-size: 0.8em;
        padding: 1px 4px;
    }

    /* Email icon adjustments */
    .email-icon {
        font-size: 1.2em;
    }

    /* Division icon adjustments */
    .division-icon {
        font-size: 1em;
    }
}

/* Very small devices (max-width: 480px) */
@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .header {
        padding: 0.75rem 0;
        margin-bottom: 1rem;
    }
    
    .header-title h1 {
        font-size: var(--font-size-lg);
    }

    .header-title p {
        font-size: var(--font-size-sm);
    }

    #user-info {
        top: 0.25rem;
        right: 0.5rem;
    }

    #user-info .user-name {
        font-size: var(--font-size-xs);
    }

    #logout-btn {
        padding: 0.35rem 0.7rem;
        font-size: var(--font-size-xs);
    }

    .nav-tab {
        min-width: 90px;
        padding: 0.65rem 0.65rem;
        font-size: var(--font-size-sm);
    }
    
    .tab-content {
        padding: 1rem;
    }
    
    .modal-content {
        width: 94%;
        margin: 1% auto;
        padding: 1rem;
        max-height: 98vh;
    }
    
    .table th,
    .table td {
        padding: 0.375rem;
        font-size: var(--font-size-sm);
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: var(--font-size-sm);
    }
    
    .form-group input,
    .form-group select {
        padding: 0.5rem;
        font-size: 16px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        margin: 1% auto;
        max-height: 95vh;
    }
    
    .header {
        padding: 0.75rem 0;
    }

    .header-title h1 {
        font-size: var(--font-size-lg);
    }

    .header-title p {
        font-size: var(--font-size-sm);
    }

    #user-info {
        top: 0.25rem;
        right: 0.75rem;
    }
    
    .nav-tabs {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    
    .nav-tab {
        flex: 0 0 auto;
        min-width: 90px;
        padding: 0.6rem 0.6rem;
        font-size: var(--font-size-sm);
    }
}

/* Print styles */
@media print {
    .nav-tabs,
    .modal,
    .btn,
    .pagination {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .header {
        background: none !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .tab-content {
        display: block !important;
        box-shadow: none !important;
        border: 1px solid #000;
    }
    
    .table {
        box-shadow: none !important;
        border: 1px solid #000;
    }
    
    .table th,
    .table td {
        border: 1px solid #000;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .table th,
    .table td {
        border: 1px solid #000;
    }
    
    .modal-content {
        border: 2px solid #000;
    }
}

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

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    /* This would be implemented if dark mode is added */
    /* For now, we maintain the light theme */
}
