/**
 * Mobile Navigation Styles for APL
 * Optimized for 375px width and touch interactions
 */

/* Mobile Bottom Navigation */
@media (max-width: 576px) {
    /* Hide desktop navigation on mobile */
    .navbar-nav.me-auto {
        display: none !important;
    }
    
    /* Mobile bottom navigation bar */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bs-white);
        border-top: 1px solid var(--bs-gray-300);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1040;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        height: 56px;
    }
    
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 0;
        text-decoration: none;
        color: var(--bs-gray-600);
        transition: all 0.2s ease;
        position: relative;
        min-height: 56px;
    }
    
    .mobile-nav-item:active {
        background-color: var(--bs-gray-100);
    }
    
    .mobile-nav-item.active {
        color: var(--bs-primary);
    }
    
    .mobile-nav-item i {
        font-size: 20px;
        margin-bottom: 4px;
    }
    
    .mobile-nav-item span {
        font-size: 11px;
        font-weight: 500;
    }
    
    /* Notification badge for mobile nav */
    .mobile-nav-item .badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 16px);
        font-size: 10px;
        padding: 2px 4px;
        min-width: 16px;
    }
    
    /* Adjust main content to account for bottom nav */
    body {
        padding-bottom: 56px;
    }
    
    /* Top navbar adjustments for mobile */
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    /* Mobile-friendly dropdowns */
    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 56px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 0.5rem 0.5rem 0 0;
        border: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .dropdown-item {
        padding: 1rem;
        border-bottom: 1px solid var(--bs-gray-200);
    }
}

/* Card-based layouts for mobile */
@media (max-width: 576px) {
    /* Convert tables to cards */
    .table-responsive {
        display: none;
    }
    
    .mobile-cards {
        display: block;
    }
    
    .mobile-card {
        background: var(--bs-white);
        border: 1px solid var(--bs-gray-300);
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
    }
    
    .mobile-card-title {
        font-weight: 600;
        font-size: 1rem;
        color: var(--bs-dark);
    }
    
    .mobile-card-meta {
        font-size: 0.875rem;
        color: var(--bs-gray-600);
    }
    
    .mobile-card-body {
        font-size: 0.875rem;
    }
    
    .mobile-card-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .mobile-card-actions .btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* Touch-optimized form elements */
@media (max-width: 576px) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Better spacing for form groups */
    .mb-3 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Full-width buttons on mobile */
    .btn-group {
        display: flex;
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
}

/* Swipeable cards for opponent selection */
.swipe-container {
    position: relative;
    height: 400px;
    margin: 1rem 0;
    overflow: hidden;
}

.swipe-card {
    position: absolute;
    width: calc(100% - 2rem);
    left: 1rem;
    top: 0;
    background: var(--bs-white);
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    cursor: grab;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.swipe-card.dragging {
    transition: none;
    cursor: grabbing;
}

.swipe-card.swiped-left {
    transform: translateX(-150%) rotate(-30deg);
    opacity: 0;
}

.swipe-card.swiped-right {
    transform: translateX(150%) rotate(30deg);
    opacity: 0;
}

/* Mobile modal adjustments */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-header {
        border-radius: 0;
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
    }
    
    /* Full-screen modals from bottom */
    .modal.fade .modal-dialog {
        transform: translateY(100%);
    }
    
    .modal.show .modal-dialog {
        transform: translateY(0);
    }
}

/* Loading skeleton for mobile */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.skeleton-button {
    height: 44px;
    border-radius: 0.375rem;
}

/* Responsive utilities */
@media (max-width: 576px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    /* Responsive text sizing */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    
    /* Responsive spacing */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }
    
    /* Stack columns on mobile */
    .row > [class*='col-'] {
        margin-bottom: 1rem;
    }
}

/* Dark mode support for mobile nav */
@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background: var(--bs-dark);
        border-top-color: var(--bs-gray-700);
    }
    
    .mobile-nav-item {
        color: var(--bs-gray-400);
    }
    
    .mobile-nav-item.active {
        color: var(--bs-primary);
    }
    
    .mobile-card {
        background: var(--bs-gray-800);
        border-color: var(--bs-gray-700);
    }
}