/* ==============================================
   MOBILE UX TOUCH TARGET IMPROVEMENTS
   Critical fixes for mobile usability
   ============================================== */

/* ===== CORE TOUCH TARGET STANDARDS ===== */
/* All interactive elements must meet 44px minimum */

.drawer-menu-link,
.drawer-menu-link button,
.bottom-nav-item,
button,
.btn,
.button,
input[type="submit"],
input[type="button"],
input[type="reset"],
.form-control,
select,
.dropdown-toggle,
.nav-link,
.card-action,
.clickable,
[role="button"],
[onclick] {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 12px 16px !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

/* Special handling for mobile drawer links */
.mobile-drawer .drawer-menu-link {
    min-height: 60px !important;
    min-width: 70px !important;
    padding: 10px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
    gap: 4px !important;
    background: transparent !important;
    border: none !important;
    font-family: inherit !important;
}

/* ===== MOBILE DRAWER LAYOUT FIXES ===== */
/* Make drawer truly horizontal and scrollable */

.mobile-drawer {
    position: fixed !important;
    bottom: 70px !important; /* Above bottom nav */
    left: 0 !important;
    right: 0 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-top: 1px solid #e0e0e0 !important;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.1) !important;
    z-index: 1001 !important;
    display: none !important;
    padding: 8px 0 !important;
    height: 80px !important;
    overflow: hidden !important;
}

.mobile-drawer.show {
    display: block !important;
}

.drawer-content {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-behavior: smooth !important;
    padding: 0 8px !important;
    gap: 8px !important;
    /* Hide scrollbar */
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.drawer-content::-webkit-scrollbar {
    display: none !important;
}

.drawer-menu-list {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    height: 100% !important;
}

.drawer-menu-item {
    flex-shrink: 0 !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ===== RESPONSIVE TOUCH TARGETS BY VIEWPORT ===== */

/* iPhone SE (375px) */
@media (max-width: 375px) {
    .drawer-menu-link,
    .bottom-nav-item {
        min-width: 50px !important;
        min-height: 50px !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    .mobile-drawer .drawer-menu-link {
        min-width: 60px !important;
        min-height: 60px !important;
        padding: 8px 10px !important;
    }
    
    button, .btn {
        min-height: 44px !important;
        padding: 10px 14px !important;
        font-size: 14px !important;
    }
}

/* iPhone 12 (390px) */
@media (min-width: 376px) and (max-width: 390px) {
    .drawer-menu-link,
    .bottom-nav-item {
        min-width: 55px !important;
        min-height: 50px !important;
        padding: 10px 14px !important;
    }
    
    .mobile-drawer .drawer-menu-link {
        min-width: 65px !important;
        min-height: 60px !important;
        padding: 10px 12px !important;
    }
}

/* iPad and larger (768px+) */
@media (min-width: 768px) {
    .mobile-drawer {
        display: none !important;
    }
    
    /* Desktop touch targets can be smaller but still accessible */
    button, .btn {
        min-height: 40px !important;
        padding: 8px 16px !important;
    }
}

/* ===== ENHANCED BUTTON STYLING ===== */

button:hover, .btn:hover {
    background-color: rgba(39, 110, 241, 0.1) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

button:active, .btn:active {
    transform: translateY(0) scale(0.98) !important;
    transition: transform 0.1s ease !important;
}

.drawer-menu-link:hover {
    background-color: rgba(39, 110, 241, 0.1) !important;
    color: #276ef1 !important;
    transform: translateY(-1px) !important;
}

.drawer-menu-link:active {
    transform: translateY(0) scale(0.95) !important;
}

/* ===== FORM CONTROLS TOUCH IMPROVEMENTS ===== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea,
select {
    min-height: 48px !important;
    padding: 12px 16px !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
    background: #fff !important;
}

/* ===== DROPDOWN AND SELECT IMPROVEMENTS ===== */

.dropdown-toggle,
select {
    min-height: 48px !important;
    padding: 12px 16px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    cursor: pointer !important;
}

/* ===== CHECKBOX AND RADIO IMPROVEMENTS ===== */

input[type="checkbox"],
input[type="radio"] {
    min-width: 20px !important;
    min-height: 20px !important;
    margin: 12px !important; /* Creates larger touch target around the control */
}

.checkbox-wrapper,
.radio-wrapper {
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    padding: 12px !important;
    cursor: pointer !important;
}

/* ===== MODAL AND OVERLAY TOUCH TARGETS ===== */

.modal .close,
.modal-close,
[data-dismiss="modal"] {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* Focus indicators for keyboard navigation */
*:focus {
    outline: 2px solid #276ef1 !important;
    outline-offset: 2px !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    button, .btn, .drawer-menu-link {
        border: 2px solid currentColor !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ===== DRAWER MENU ICONS AND TEXT ===== */

.drawer-menu-link i {
    font-size: 18px !important;
    margin-bottom: 2px !important;
    display: block !important;
}

.drawer-menu-link span {
    font-size: 11px !important;
    font-weight: 500 !important;
    text-align: center !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

/* ===== SCROLL BEHAVIOR IMPROVEMENTS ===== */

.drawer-content {
    /* Enhanced scrolling for mobile */
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x proximity !important;
}

.drawer-menu-item {
    scroll-snap-align: center !important;
}

/* ===== VISUAL FEEDBACK ===== */

/* Add subtle visual feedback for all interactive elements */
button:hover,
.btn:hover,
.drawer-menu-link:hover,
.bottom-nav-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

/* Active state feedback */
.drawer-menu-link:active,
.bottom-nav-item:active,
button:active,
.btn:active {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

/* ===== ENSURE NO HORIZONTAL SCROLL ISSUES ===== */

body {
    overflow-x: hidden !important;
}

.container,
.row {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* ===== DEBUGGING UTILITIES (Remove in production) ===== */

/* Uncomment to visualize touch targets
.drawer-menu-link,
.bottom-nav-item,
button,
.btn {
    border: 1px dashed red !important;
}
*/

/* ===== COMPATIBILITY FIXES ===== */

/* Ensure compatibility with existing styles */
.drawer-menu-link {
    color: inherit !important;
}

.drawer-menu-link:hover {
    text-decoration: none !important;
}

/* Fix any conflicting positioning */
.mobile-drawer * {
    box-sizing: border-box !important;
}

/* Ensure proper stacking */
.mobile-drawer {
    isolation: isolate !important;
}