/* Mobile-First Bootstrap Enhancements for LottoMuse */

/* =================================================================
   MOBILE-FIRST RESPONSIVE ENHANCEMENTS
   ================================================================= */

/* Enhanced Mobile Navigation */
@media (max-width: 767.98px) {
    .navbar-brand {
        font-size: 1.1rem !important;
        letter-spacing: 0.5px !important;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem !important;
        margin: 0.25rem 0 !important;
    }
    
    .navbar-collapse {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }
}

/* Reduce body-bottom padding for chat pages as those pages have their own
   scrollable container and fixed footer handling. This avoids duplicate
   padding that can produce the white gap below content. */
body.chat-page {
    padding-bottom: 0 !important;
}


/* Mobile-Optimized Form Controls */
@media (max-width: 767.98px) {
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem !important;
    }
    
    .btn {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
        min-height: 44px; /* Touch-friendly minimum */
    }
    
    .btn-sm {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
        min-height: 38px;
    }
}

/* Enhanced Card Responsiveness */
@media (max-width: 575.98px) {
    .card {
        border-radius: 1rem !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    .card-body {
        padding: 1.25rem !important;
    }
    
    .card-header {
        padding: 1rem 1.25rem !important;
        border-radius: 1rem 1rem 0 0 !important;
    }
}

/* Mobile-Friendly Tables */
@media (max-width: 767.98px) {
    .table-responsive {
        border-radius: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table td,
    .table th {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.875rem !important;
        vertical-align: middle !important;
    }
    
    .table .btn {
        font-size: 0.75rem !important;
        padding: 0.375rem 0.75rem !important;
        min-height: auto !important;
    }
}

/* Enhanced Modal Responsiveness */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 1rem !important;
    }
    
    .modal-header,
    .modal-footer {
        padding: 1rem !important;
    }
    
    .modal-body {
        padding: 1.25rem !important;
    }
}

/* Mobile-Optimized Typography */
@media (max-width: 767.98px) {
    h1, .h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }
    
    h2, .h2 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.875rem !important;
    }
    
    h3, .h3 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.75rem !important;
    }
    
    .lead {
        font-size: 1.125rem !important;
        line-height: 1.5 !important;
    }
}

/* Enhanced Button Spacing for Touch */
@media (max-width: 767.98px) {
    .btn + .btn {
        margin-left: 0 !important;
        margin-top: 0.5rem !important;
    }
    
    .btn-group-vertical .btn {
        margin-top: 0 !important;
    }
    
    .d-grid .btn + .btn {
        margin-top: 0.75rem !important;
    }
}

/* Mobile-Friendly Form Groups */
@media (max-width: 767.98px) {
    .row.g-3 {
        --bs-gutter-x: 1rem !important;
        --bs-gutter-y: 1rem !important;
    }
    
    .mb-3 {
        margin-bottom: 1.25rem !important;
    }
    
    .form-floating > label {
        padding: 1rem !important;
    }
}

/* Enhanced Alert Responsiveness */
@media (max-width: 767.98px) {
    .alert {
        border-radius: 0.75rem !important;
        padding: 1rem !important;
        font-size: 0.9rem !important;
    }
    
    .alert-dismissible .btn-close {
        padding: 1rem !important;
    }
}

/* Mobile-Optimized Navigation Pills/Tabs */
@media (max-width: 767.98px) {
    .nav-pills .nav-link,
    .nav-tabs .nav-link {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        white-space: nowrap !important;
    }
    
    .nav-pills,
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
    
    .nav-pills::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none !important;
    }
}

/* Touch-Friendly Pagination */
@media (max-width: 767.98px) {
    .pagination .page-link {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* Mobile-Optimized Dropdowns */
@media (max-width: 767.98px) {
    .dropdown-menu {
        border-radius: 0.75rem !important;
        padding: 0.5rem !important;
        min-width: 200px !important;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem !important;
        font-size: 0.9rem !important;
    }
}

/* Enhanced Spacing for Mobile */
@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .py-4 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* Mobile-Specific Utilities */
@media (max-width: 767.98px) {
    .mobile-stack > * + * {
        margin-top: 1rem !important;
    }
    
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
}

/* Enhanced Focus States for Mobile */
@media (max-width: 767.98px) {
    .form-control:focus,
    .form-select:focus,
    .btn:focus {
        box-shadow: 0 0 0 0.25rem rgba(91, 62, 144, 0.25) !important;
        border-color: #5B3E90 !important;
    }
}

/* Safe Area Support for Modern Mobile Devices */
@supports (env(safe-area-inset-bottom)) {
    @media (max-width: 767.98px) {
        .pb-3,
        .py-3 {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
        }
        
        .mb-3 {
            margin-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* Improved Accessibility for Mobile */
@media (max-width: 767.98px) {
    .sr-only-mobile {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .hide-mobile {
        display: none !important;
    }
}

/* ==========================================
   Fix: Use dynamic viewport height for mobile
   Avoids 100vh address-bar issue that creates
   white space under scrollable content on mobile
   ========================================== */
@media (max-width: 991px) {
    /* Fallback variable so older browsers still get a working unit */
    :root { --vh: 1vh; }

    /* Preferred modern unit (dynamic viewport height) */
    @supports (height: 100dvh) {
        .app-container,
        .chatgpt-container,
        .chatgpt-sidebar,
        .chat-container {
            height: 100dvh !important;
            min-height: 100dvh !important;
            max-height: 100dvh !important;
        }
    }

    /* Fallback for browsers without support for 100dvh: use --vh set by JS */
    @supports not (height: 100dvh) {
        .app-container,
        .chatgpt-container,
        .chatgpt-sidebar,
        .chat-container {
            height: calc(var(--vh, 1vh) * 100) !important;
            min-height: calc(var(--vh, 1vh) * 100) !important;
            max-height: calc(var(--vh, 1vh) * 100) !important;
        }
    }
}

