/* 
 * Padel 7AM - Mobile First Design
 * Native App Experience for Mobile Devices
 */

/* ==================== MOBILE VIEWPORT & BASE ==================== */
@media (max-width: 991px) {
    /* Prevent zoom on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Safe area for notch devices */
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Disable horizontal scroll */
    body, html {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==================== BOTTOM NAVIGATION (Mobile Only) ==================== */
@media (max-width: 991px) {
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: #0a2342;
        box-shadow: 0 -4px 20px rgba(10, 35, 66, 0.3);
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0.5rem 0;
        z-index: 1030;
        border-top: 3px solid #ffd400;
    }
    
    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: rgba(255, 255, 255, 0.7);
        text-decoration: none;
        font-family: 'Roboto Condensed', sans-serif;
        font-size: 0.7rem;
        font-weight: 700;
        padding: 0.5rem;
        transition: all 0.3s ease;
        position: relative;
        min-width: 0; /* Allow shrinking */
    }
    
    .mobile-bottom-nav-item span:not(.coming-soon-badge) {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .mobile-bottom-nav-item i {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
        transition: all 0.3s ease;
    }
    
    .mobile-bottom-nav-item:active {
        transform: scale(0.95);
    }
    
    .mobile-bottom-nav-item.active {
        color: #ffd400;
    }
    
    .mobile-bottom-nav-item.active i {
        transform: translateY(-3px);
        filter: drop-shadow(0 4px 6px rgba(255, 212, 0, 0.5));
    }
    
    .mobile-bottom-nav-item.active::before {
        content: '';
        position: absolute;
        top: -2px;
        left: 50%;
        transform: translateX(-50%);
        width: 40%;
        height: 3px;
        background: #ffd400;
        border-radius: 0 0 3px 3px;
    }
    
    /* Guest menu - Disabled item (Coming Soon) */
    .mobile-bottom-nav-item-disabled {
        opacity: 0.6;
        position: relative;
        cursor: not-allowed;
    }
    
    .mobile-bottom-nav-item-disabled:active {
        transform: none;
    }
    
    .coming-soon-badge {
        position: absolute;
        top: 4px;
        right: 8px;
        background: #ffd400;
        color: white;
        font-size: 0.55rem;
        font-weight: 800;
        padding: 2px 6px;
        border-radius: 8px;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
        animation: pulse-badge 2s ease-in-out infinite;
    }
    
    @keyframes pulse-badge {
        0%, 100% { 
            transform: scale(1);
            opacity: 1;
        }
        50% { 
            transform: scale(1.05);
            opacity: 0.9;
        }
    }
    
    /* Guest menu - Highlight item (Login CTA) */
    .mobile-bottom-nav-item-highlight {
        position: relative;
    }
    
    .mobile-bottom-nav-item-highlight::before {
        content: '';
        position: absolute;
        top: -2px;
        left: 50%;
        transform: translateX(-50%);
        width: 60%;
        height: 3px;
        background: #10b981;
        border-radius: 0 0 3px 3px;
        animation: glow-login 2s ease-in-out infinite;
    }
    
    @keyframes glow-login {
        0%, 100% { 
            opacity: 1;
            box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
        }
        50% { 
            opacity: 0.7;
            box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
        }
    }
    
    .mobile-bottom-nav-item-highlight i {
        animation: bounce-icon 2s ease-in-out infinite;
    }
    
    @keyframes bounce-icon {
        0%, 100% { 
            transform: translateY(0);
        }
        50% { 
            transform: translateY(-3px);
        }
    }
    
    /* Adjust for 5 items in guest menu */
    .mobile-bottom-nav:has(> :nth-child(5)) .mobile-bottom-nav-item {
        padding: 0.4rem 0.2rem;
        font-size: 0.65rem;
    }
    
    .mobile-bottom-nav:has(> :nth-child(5)) .mobile-bottom-nav-item i {
        font-size: 1.3rem;
        margin-bottom: 0.2rem;
    }
    
    .mobile-bottom-nav:has(> :nth-child(5)) .coming-soon-badge {
        font-size: 0.5rem;
        padding: 1px 4px;
        top: 2px;
        right: 4px;
    }
    
    /* Add bottom padding to main content */
    main {
        padding-bottom: 90px !important;
    }
    
    /* Hide footer on mobile (we have bottom nav) */
    .desktop-only-footer {
        display: none !important;
    }
    
    /* Back Button Mobile - Improved */
    .btn-back-mobile {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        padding: 10px 18px;
        background: white;
        color: #0a2342;
        border-radius: 50px;
        text-decoration: none;
        font-family: 'Roboto Condensed', sans-serif;
        font-weight: 700;
        font-size: 0.85rem;
        box-shadow: 0 2px 8px rgba(10, 35, 66, 0.1);
        transition: all 0.3s ease;
        border: 2px solid #ffd400;
    }
    
    .btn-back-mobile i {
        font-size: 1.1rem;
        transition: transform 0.3s ease;
        color: #395a9e;
    }
    
    .btn-back-mobile:active {
        transform: scale(0.95);
        box-shadow: 0 1px 4px rgba(10, 35, 66, 0.2);
    }
    
    .btn-back-mobile:hover,
    .btn-back-mobile:focus {
        color: #0a2342;
        background: #ffd400;
        border-color: #0a2342;
    }
    
    .btn-back-mobile:active i {
        transform: translateX(-4px);
    }
    
    /* Hide desktop navbar on mobile */
    .navbar .navbar-collapse {
        display: none !important;
    }
    
    /* Improved Mobile Navbar */
    .navbar {
        padding: 0.5rem 1rem !important;
        background: #0a2342 !important;
        box-shadow: 0 2px 12px rgba(10, 35, 66, 0.3) !important;
        backdrop-filter: blur(10px);
        min-height: 60px;
        border-bottom: 3px solid #ffd400 !important;
    }
    
    .navbar .container-fluid {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .navbar-brand {
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        margin: 0 !important;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .navbar-logo {
        height: 50px;
        width: auto;
        max-width: 180px;
        object-fit: contain;
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
        transition: transform 0.3s ease, filter 0.3s ease;
    }
    
    .navbar-brand:active .navbar-logo {
        transform: scale(0.96);
    }
    
    .navbar-brand:hover .navbar-logo {
        filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3)) brightness(1.05);
    }
    
    
    .navbar-toggler {
        display: none !important;
    }
}

/* ==================== DESKTOP NAVBAR OVERRIDES ==================== */
@media (min-width: 992px) {
    .navbar {
        padding: 0.75rem 1.5rem !important;
    }
    
    .navbar .container-fluid {
        justify-content: space-between !important;
    }
    
    .navbar-brand {
        position: relative !important;
        left: auto !important;
        transform: none !important;
        margin-right: 2rem !important;
    }
    
    .navbar-logo {
        height: 55px;
        max-width: 200px;
    }
    
    .navbar-collapse {
        display: flex !important;
    }
    
    /* Desktop navigation links styling */
    .navbar-nav .nav-link {
        padding: 0.5rem 1rem;
        border-radius: 8px;
        transition: all 0.3s ease;
        font-family: 'Roboto Condensed', sans-serif;
        font-weight: 700;
        margin: 0 0.25rem;
    }
    
    .navbar-nav .nav-link:hover {
        background: #ffd400;
        color: #0a2342 !important;
        transform: translateY(-2px);
    }
    
    .navbar-nav .nav-link:active {
        transform: translateY(0);
    }
    
    /* Desktop dropdown styling */
    .dropdown-menu {
        border-radius: 12px;
        border: 2px solid #ffd400;
        box-shadow: 0 8px 24px rgba(10, 35, 66, 0.15);
        padding: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .dropdown-item {
        border-radius: 8px;
        padding: 0.6rem 1rem;
        transition: all 0.2s ease;
        font-family: 'Roboto Condensed', sans-serif;
        font-weight: 600;
    }
    
    .dropdown-item:hover {
        background: #ffd400;    
        color: #0a2342;
        transform: translateX(4px);
    }
    
    .dropdown-item i {
        margin-right: 8px;
        width: 20px;
        text-align: center;
        color: #395a9e;
    }
    
    /* Show footer on desktop */
    .desktop-only-footer {
        display: block !important;
    }
}

/* ==================== MOBILE TYPOGRAPHY ==================== */
@media (max-width: 991px) {
    body {
        font-size: 15px;
        line-height: 1.5;
    }
    
    h1, .h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    h2, .h2 {
        font-size: 1.5rem !important;
    }
    
    h3, .h3 {
        font-size: 1.25rem !important;
    }
    
    h4, .h4 {
        font-size: 1.1rem !important;
    }
    
    .display-3 {
        font-size: 2rem !important;
    }
    
    .lead {
        font-size: 1.1rem;
    }
}

/* ==================== MOBILE SPACING ==================== */
@media (max-width: 991px) {
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    main {
        padding-top: 65px !important;
    }
    
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .mt-4, .my-4 {
        margin-top: 1.5rem !important;
    }
    
    .mt-5, .my-5 {
        margin-top: 2rem !important;
    }
    
    .mb-4, .my-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mb-5, .my-5 {
        margin-bottom: 2rem !important;
    }
}

/* ==================== MOBILE BUTTONS ==================== */
@media (max-width: 991px) {
    .btn {
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
        font-weight: 700;
        min-height: 48px; /* Touch target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .btn-sm {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    
    .btn-lg {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        min-height: 54px;
    }
    
    .btn i {
        font-size: 1.1em;
    }
    
    /* Button groups on mobile */
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        flex: 1;
        min-width: 44px;
    }
    
    /* Full width buttons on mobile */
    .mobile-full-width {
        width: 100% !important;
        display: block !important;
    }
}

/* ==================== MOBILE CARDS ==================== */
@media (max-width: 991px) {
    .card {
        margin-bottom: 1rem;
        border-radius: 1rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    .card-header {
        padding: 1rem 1.25rem;
        font-size: 1.1rem;
    }
    
    .stats-card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .stats-icon {
        width: 3rem !important;
        height: 3rem !important;
        font-size: 1.5rem !important;
    }
    
    .stats-value {
        font-size: 2rem !important;
    }
    
    .stats-label {
        font-size: 0.85rem !important;
    }
    
    /* Hero card mobile */
    .hero-section {
        padding: 2.5rem 1.5rem !important;
        border-radius: 1rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-section p {
        font-size: 1rem !important;
    }
}

/* ==================== MOBILE FORMS ==================== */
@media (max-width: 991px) {
    .form-control,
    .form-select {
        padding: 0.85rem 1rem;
        font-size: 16px; /* Prevent zoom */
        border-radius: 0.75rem;
        min-height: 48px;
        -webkit-appearance: none;
    }
    
    .form-control:focus,
    .form-select:focus {
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    }
    
    .form-label {
        font-size: 0.95rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
    }
    
    /* Checkbox & Radio - larger touch targets */
    .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
        margin-top: 0;
    }
    
    .form-check-label {
        padding-left: 0.5rem;
        line-height: 1.5rem;
    }
    
    /* Form groups */
    .row.g-3 > * {
        margin-bottom: 1rem;
    }
    
    /* Full width form elements on mobile */
    .col-md-2, .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-10 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ==================== MOBILE TABLES ==================== */
@media (max-width: 991px) {
    /* Hide default table on mobile */
    .table-responsive > table.table {
        display: none;
    }
    
    /* Create card-based layout for tables */
    .table-responsive::after {
        content: attr(data-mobile-msg);
        display: block;
        text-align: center;
        padding: 1rem;
        color: var(--gray);
        font-style: italic;
    }
    
    /* Mobile table cards */
    .mobile-table-card {
        background: white;
        border-radius: 1rem;
        padding: 1.25rem;
        margin-bottom: 1rem;
        box-shadow: var(--shadow);
        border: 2px solid #ffd400;
        transition: all 0.3s ease;
    }
    
    .mobile-table-card:active {
        transform: scale(0.98);
        box-shadow: var(--shadow-sm);
    }
    
    .mobile-table-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1rem;
        padding-bottom: 1rem;
        border-bottom: 2px solid #ffd400;
    }
    
    .mobile-table-card-title {
        font-family: 'Anton', sans-serif;
        font-size: 1.1rem;
        font-weight: 400;
        color: #0a2342;
        margin: 0;
        text-transform: uppercase;
    }
    
    .mobile-table-card-row {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(10, 35, 66, 0.1);
    }
    
    .mobile-table-card-row:last-child {
        border-bottom: none;
    }
    
    .mobile-table-card-label {
        font-family: 'Roboto Condensed', sans-serif;
        font-weight: 700;
        color: #395a9e;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .mobile-table-card-value {
        font-family: 'Roboto Condensed', sans-serif;
        font-weight: 700;
        color: #0a2342;
        text-align: right;
    }
    
    .mobile-table-card-actions {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 2px solid #ffd400;
        display: flex;
        gap: 0.5rem;
    }
    
    .mobile-table-card-actions .btn {
        flex: 1;
    }
}

/* ==================== MOBILE TABS ==================== */
@media (max-width: 991px) {
    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 3px solid #ffd400;
        margin-bottom: 1.5rem;
        padding-bottom: 0;
        background: #f8fafc;
    }
    
    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }
    
    .nav-tabs .nav-link {
        padding: 0.85rem 1.25rem;
        font-size: 0.9rem;
        font-family: 'Roboto Condensed', sans-serif;
        font-weight: 700;
        white-space: nowrap;
        border: none;
        border-bottom: 3px solid transparent;
        border-radius: 0;
        color: #0a2342 !important;
        background: transparent;
    }
    
    .nav-tabs .nav-link.active {
        border-bottom-color: #ffd400;
        background: rgba(255, 212, 0, 0.1);
        color: #0a2342 !important;
        font-weight: 700;
    }
    
    .nav-tabs .nav-link:hover {
        background: rgba(255, 212, 0, 0.05);
        color: #0a2342 !important;
    }
    
    .tab-content {
        border: none !important;
        padding: 0 !important;
    }
}

/* ==================== MOBILE ALERTS ==================== */
@media (max-width: 991px) {
    .alert {
        padding: 1rem;
        font-size: 0.9rem;
        border-radius: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .alert i {
        font-size: 1.2rem;
    }
}

/* ==================== MOBILE BADGES ==================== */
@media (max-width: 991px) {
    .badge {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        font-weight: 700;
    }
}

/* ==================== MOBILE MODAL ==================== */
@media (max-width: 991px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 1.25rem;
    }
    
    .modal-header,
    .modal-footer {
        padding: 1.25rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
}

/* ==================== MOBILE FOOTER ==================== */
@media (max-width: 991px) {
    .footer {
        padding: 2rem 0;
        margin-top: 2rem;
        text-align: center;
    }
    
    .footer .row > * {
        text-align: center !important;
        margin-bottom: 0.5rem;
    }
    
    .footer .col-md-6:last-child {
        margin-bottom: 0;
    }
}

/* ==================== MOBILE UTILITIES ==================== */
@media (max-width: 991px) {
    /* Text alignment */
    .mobile-text-center {
        text-align: center !important;
    }
    
    /* Flex utilities */
    .d-flex.justify-content-between:not(.mobile-keep-row):not(.flex-column):not(.flex-md-row) {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    
    .d-flex.justify-content-between.mobile-keep-row {
        flex-direction: row !important;
    }
    
    /* Hide on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Show only on mobile */
    .mobile-only {
        display: block !important;
    }
    
    /* Full width on mobile */
    .mobile-full-width {
        width: 100% !important;
    }
    
    /* Hero section specific */
    .hero-section .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        display: flex !important;
    }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 992px) {
    .mobile-only {
        display: none !important;
    }
    
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* ==================== MOBILE SEARCH & FILTER ==================== */
@media (max-width: 991px) {
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin: 0;
        padding: 0.85rem 1rem;
        border-radius: 0.75rem;
        font-size: 16px;
    }
    
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        margin-bottom: 1rem;
    }
    
    .dataTables_wrapper .dataTables_length select {
        padding: 0.5rem;
        border-radius: 0.5rem;
        font-size: 16px;
    }
}

/* ==================== MOBILE PULL TO REFRESH INDICATOR ==================== */
@media (max-width: 991px) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* ==================== MOBILE TOUCH FEEDBACK ==================== */
@media (max-width: 991px) {
    .card:active,
    .stats-card:active {
        transform: scale(0.98);
    }
    
    a:active,
    button:active {
        opacity: 0.7;
    }
}

/* ==================== MOBILE LANDSCAPE MODE ==================== */
@media (max-width: 991px) and (orientation: landscape) {
    .hero-section {
        padding: 2rem 1.5rem !important;
    }
    
    main {
        padding-top: 60px !important;
    }
}

/* ==================== SMALL MOBILE (< 576px) ==================== */
@media (max-width: 575px) {
    body {
        font-size: 14px;
    }
    
    h1, .h1 {
        font-size: 1.5rem !important;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .mobile-bottom-nav-item {
        font-size: 0.65rem;
    }
    
    .mobile-bottom-nav-item i {
        font-size: 1.3rem;
    }
}

/* ==================== VERY LARGE MOBILE (Tablets) ==================== */
@media (min-width: 768px) and (max-width: 991px) {
    /* Show 2 columns for stats cards on tablets */
    .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ==================== STICKY HEADER ON SCROLL (Mobile) ==================== */
@media (max-width: 991px) {
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1029;
    }
}

/* ==================== MOBILE ACCESSIBILITY ==================== */
@media (max-width: 991px) {
    /* Larger focus indicators for touch */
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Skip to content link for screen readers */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--primary-color);
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 100;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}

/* ==================== MOBILE PWA ENHANCEMENTS ==================== */
@media (max-width: 991px) {
    /* Full viewport height for app-like experience */
    .mobile-fullscreen {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    /* Hide URL bar on scroll */
    @supports (-webkit-touch-callout: none) {
        body {
            min-height: -webkit-fill-available;
        }
    }
}

/* ==================== MOBILE LOADING STATES ==================== */
@media (max-width: 991px) {
    .loading-spinner {
        width: 2.5rem;
        height: 2.5rem;
        border-width: 4px;
    }
    
    .btn.loading {
        position: relative;
        pointer-events: none;
        color: transparent !important;
    }
    
    .btn.loading::after {
        content: '';
        position: absolute;
        width: 1.25rem;
        height: 1.25rem;
        top: 50%;
        left: 50%;
        margin-left: -0.625rem;
        margin-top: -0.625rem;
        border: 2px solid transparent;
        border-top-color: white;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }
}

/* ==================== MOBILE SAFE AREAS (iOS) ==================== */
@media (max-width: 991px) {
    @supports (padding: max(0px)) {
        .navbar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
        
        .mobile-bottom-nav {
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
            padding-bottom: env(safe-area-inset-bottom);
            height: calc(70px + env(safe-area-inset-bottom));
        }
        
        main {
            padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important;
        }
    }
}


