/* ===============================================
   CRITICAL MOBILE RESPONSIVENESS FIXES
   Phase 8 Mobile Enhancement
   =============================================== */

/* Force proper box-sizing and prevent overflow */
* {
    box-sizing: border-box !important;
}

html,
body {
    max-width: 100vw;
    overflow-x: hidden !important;
    position: relative;
}

/* Fix Bootstrap containers for mobile */
@media (max-width: 575.98px) {
    .container,
    .container-fluid,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .row {
        margin-left: -12px !important;
        margin-right: -12px !important;
    }
    
    [class*="col-"] {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* Fix scroll buttons positioning on mobile */
@media (max-width: 575.98px) {
    .scroll-top {
        bottom: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 1rem !important;
        z-index: 1000 !important;
    }
    
    .theme-toggle {
        bottom: 70px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 1rem !important;
        z-index: 999 !important;
    }
}

/* Fix all card types on mobile */
@media (max-width: 575.98px) {
    .service-card,
    .blog-card,
    .story-card,
    .project-card,
    .team-card,
    .testimonial-card,
    .donation-card,
    .value-card {
        padding: 1.25rem !important;
        margin-bottom: 1rem !important;
        border-radius: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .card {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
    }
}

/* Fix buttons on mobile */
@media (max-width: 575.98px) {
    .btn {
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .btn-group {
        width: 100% !important;
        flex-direction: column !important;
    }
    
    .btn-group .btn {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
}

/* Fix page headers on mobile */
@media (max-width: 575.98px) {
    .page-header {
        padding: 2rem 0 !important;
    }
    
    .page-header h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }
    
    .page-header .lead {
        font-size: 0.95rem !important;
    }
    
    .display-4 {
        font-size: 2rem !important;
    }
    
    .display-5 {
        font-size: 1.75rem !important;
    }
}

/* Fix newsletter widget on mobile */
@media (max-width: 575.98px) {
    .newsletter-widget {
        padding: 1.5rem 1rem !important;
        margin: 1.5rem 0 !important;
        border-radius: 12px !important;
    }
    
    .newsletter-widget h3 {
        font-size: 1.25rem !important;
    }
    
    .newsletter-widget p {
        font-size: 0.9rem !important;
    }
    
    .newsletter-form {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .newsletter-form input {
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
    }
    
    .newsletter-form button {
        width: 100% !important;
        padding: 0.75rem 1rem !important;
    }
}

/* Fix social share buttons on mobile */
@media (max-width: 575.98px) {
    .social-share {
        flex-direction: column !important;
        padding: 1rem !important;
        gap: 0.5rem !important;
    }
    
    .share-btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 0.65rem 1rem !important;
        font-size: 0.9rem !important;
    }
}

/* Fix FAQ section on mobile */
@media (max-width: 575.98px) {
    .faq-section {
        padding: 0 !important;
    }
    
    .faq-search input {
        padding: 0.75rem 1rem !important;
        padding-left: 2.5rem !important;
        font-size: 0.95rem !important;
    }
    
    .faq-categories {
        gap: 0.5rem !important;
    }
    
    .faq-category {
        padding: 0.4rem 1rem !important;
        font-size: 0.85rem !important;
    }
    
    .faq-item {
        margin-bottom: 0.75rem !important;
    }
    
    .faq-question {
        padding: 1rem 1.25rem !important;
        font-size: 0.95rem !important;
    }
    
    .faq-answer {
        padding: 0 1.25rem 1rem !important;
    }
}

/* Fix navbar on mobile */
@media (max-width: 991.98px) {
    .navbar {
        padding: 0.75rem 0 !important;
    }
    
    .navbar-brand {
        font-size: 1.25rem !important;
    }
    
    .navbar-collapse {
        margin-top: 1rem !important;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
    }
}

/* Fix images and media */
@media (max-width: 575.98px) {
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    iframe {
        max-width: 100% !important;
    }
    
    .img-fluid {
        width: 100% !important;
        height: auto !important;
    }
}

/* Fix tables on mobile */
@media (max-width: 575.98px) {
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Fix footer on mobile */
@media (max-width: 575.98px) {
    footer {
        padding: 2rem 0 !important;
    }
    
    footer .row > div {
        margin-bottom: 1.5rem !important;
    }
    
    footer h5 {
        font-size: 1.1rem !important;
    }
    
    footer p,
    footer a {
        font-size: 0.9rem !important;
    }
}

/* Fix hero sections on mobile */
@media (max-width: 575.98px) {
    .hero,
    .hero-section,
    [class*="hero"] {
        padding: 3rem 0 !important;
    }
    
    .hero h1,
    .hero-section h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    .hero p,
    .hero-section p {
        font-size: 1rem !important;
    }
}

/* Fix spacing on mobile */
@media (max-width: 575.98px) {
    section {
        padding: 2rem 0 !important;
    }
    
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .my-5 {
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
    }
    
    .mb-5 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-5 {
        margin-top: 1.5rem !important;
    }
}

/* Fix text sizes on mobile */
@media (max-width: 575.98px) {
    html {
        font-size: 14px !important;
    }
    
    h1 {
        font-size: 1.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
    }
    
    h5 {
        font-size: 1rem !important;
    }
    
    h6 {
        font-size: 0.95rem !important;
    }
    
    p {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
    }
    
    .lead {
        font-size: 1rem !important;
    }
}

/* Prevent horizontal scroll from any element */
@media (max-width: 575.98px) {
    * {
        max-width: 100vw !important;
    }
    
    /* Allow specific flex/grid containers to exceed if needed */
    .d-flex,
    .d-grid,
    .row,
    .container,
    .container-fluid {
        max-width: 100% !important;
    }
}

/* Fix form elements on mobile */
@media (max-width: 575.98px) {
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
        width: 100% !important;
    }
    
    .form-group {
        margin-bottom: 1rem !important;
    }
    
    label {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
    }
}

/* Fix modal on mobile */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-content {
        border-radius: 12px !important;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem !important;
    }
}

/* Fix alerts on mobile */
@media (max-width: 575.98px) {
    .alert {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Touch-friendly spacing */
@media (max-width: 575.98px) and (pointer: coarse) {
    button,
    .btn,
    a {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    .nav-link {
        min-height: 44px !important;
    }
}
