/* MOBILE FIXES - Remove all tap highlights and blue cursors */

/* Universal tap highlight removal with maximum specificity */
html *, html *:before, html *:after,
body *, body *:before, body *:after {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -khtml-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Target all interactive elements specifically */
a, a:visited, a:hover, a:active, a:focus,
button, button:visited, button:hover, button:active, button:focus,
input, input:visited, input:hover, input:active, input:focus,
select, select:visited, select:hover, select:active, select:focus,
textarea, textarea:visited, textarea:hover, textarea:active, textarea:focus,
[role="button"], [role="button"]:visited, [role="button"]:hover, [role="button"]:active, [role="button"]:focus,
[tabindex], [tabindex]:visited, [tabindex]:hover, [tabindex]:active, [tabindex]:focus,
.btn, .btn:visited, .btn:hover, .btn:active, .btn:focus,
.nav-link, .nav-link:visited, .nav-link:hover, .nav-link:active, .nav-link:focus,
.navbar-toggler, .navbar-toggler:visited, .navbar-toggler:hover, .navbar-toggler:active, .navbar-toggler:focus,
.navbar-brand, .navbar-brand:visited, .navbar-brand:hover, .navbar-brand:active, .navbar-brand:focus {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

/* Bootstrap specific overrides */
.navbar *, .navbar-nav *, .navbar-brand *, .navbar-toggler *,
.btn *, .btn-primary *, .btn-secondary *, .btn-outline *,
.dropdown *, .dropdown-menu *, .dropdown-item *,
.form-control *, .form-select *, .form-check *,
.card *, .list-group *, .list-group-item * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
}

/* Ensure modals remain clickable with ULTRA-HIGH specificity */
/* Override the global html *, body * rules with even higher specificity */
html body div.modal *, html body div.modal-dialog *, html body div.modal-content *, 
html body div.modal-header *, html body div.modal-body *, html body div.modal-footer *,
html body div.modal .btn *, html body div.modal .close *, html body div.modal button *,
html body div.modal div.modal-dialog *, html body div.modal div.modal-content *, 
html body div.modal div.modal-header *, html body div.modal div.modal-body *, 
html body div.modal div.modal-footer *,
html body div.modal div.modal-dialog .btn *, html body div.modal div.modal-dialog .close *, 
html body div.modal div.modal-dialog button *,
html body div.modal div.modal-dialog a *, html body div.modal div.modal-dialog .card *,
html body .modal *, html body .modal-dialog *, html body .modal-content *, 
html body .modal-header *, html body .modal-body *, html body .modal-footer *,
html body .modal .btn *, html body .modal .close *, html body .modal button *,
html body .modal a *, html body .modal .card * {
    -webkit-user-select: auto !important;
    -khtml-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
    user-select: auto !important;
    pointer-events: auto !important;
    -webkit-touch-callout: auto !important;
    cursor: pointer !important;
}

/* All other mobile fixes remain, but modal rules are managed by dashboard.css */

/* Specific fixes for modal input elements */
.modal input, .modal textarea, .modal select,
div.modal input, div.modal textarea, div.modal select {
    -webkit-user-select: text !important;
    -khtml-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    pointer-events: auto !important;
    -webkit-touch-callout: auto !important;
}

/* Mobile specific overrides */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
        -webkit-tap-highlight-color: transparent !important;
        -webkit-touch-callout: none !important;
    }
    
    *:focus, *:active, *:hover {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
        -webkit-focus-ring-color: transparent !important;
    }
    
    /* Fix problematic main margin-top on mobile and tablet */
    main {
        margin-top: 0 !important;
    }
    
    /* Ensure modals work on mobile with ULTRA-HIGH specificity */
    html body .modal, html body .modal-dialog, html body .modal-content,
    html body div.modal, html body div.modal-dialog, html body div.modal-content,
    html body .modal *, html body .modal-dialog *, html body .modal-content *,
    html body div.modal *, html body div.modal-dialog *, html body div.modal-content *,
    html body .modal button, html body .modal .btn, html body .modal .close, html body .modal a,
    html body div.modal button, html body div.modal .btn, html body div.modal .close, html body div.modal a,
    html body div.modal div.modal-dialog *, html body div.modal div.modal-content *,
    html body div.modal div.modal-header *, html body div.modal div.modal-body *,
    html body div.modal div.modal-footer *, html body div.modal .card * {
        -webkit-user-select: auto !important;
        -moz-user-select: auto !important;
        -ms-user-select: auto !important;
        user-select: auto !important;
        pointer-events: auto !important;
        -webkit-touch-callout: auto !important;
        cursor: pointer !important;
    }
    
    .modal-backdrop {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        pointer-events: auto !important;
    }
}

/* Additional tablet fix */
@media (max-width: 991.98px) {
    main {
        margin-top: 0 !important;
    }
}

/* Specific fix for the reported 575px breakpoint */
@media (max-width: 575px) {
    main {
        margin-top: 0 !important;
    }
}

/* Allow text selection only where needed */
p, span, div, h1, h2, h3, h4, h5, h6, 
input[type="text"], input[type="email"], input[type="password"],
textarea, [contenteditable="true"] {
    -webkit-user-select: text !important;
    -khtml-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Completely disable touch feedback on iOS */
@supports (-webkit-touch-callout: none) {
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
        -webkit-touch-callout: none !important;
    }
}