/**
 * Mobile Responsiveness Fixes for Akbar Welfare Foundation
 * Fixes oversized containers and cards on mobile devices
 */

/* ========================================
   BASE RESPONSIVE UTILITIES
   ======================================== */

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

* {
    box-sizing: border-box;
}

/* Container fixes for mobile */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
}

/* ========================================
   NAVIGATION FIXES
   ======================================== */

@media (max-width: 768px) {
    .navbar {
        padding: 10px 0;
    }
    
    .nav-container {
        padding: 0 15px;
    }
    
    .logo h2 {
        font-size: 16px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
    
    .logo i {
        font-size: 18px;
    }
}

/* ========================================
   HERO SECTION FIXES
   ======================================== */

@media (max-width: 768px) {
    .hero {
        margin-top: 60px;
        min-height: 400px;
    }
    
    .carousel-item img {
        min-height: 300px;
        max-height: 500px;
        object-fit: contain;
        object-position: center;
    }
    
    .carousel-caption {
        padding: 1.5rem 2rem !important;
        bottom: 20px;
    }
    
    .hero-title {
        font-size: 20px !important;
        line-height: 1.3;
        margin-bottom: 10px;
    }
    
    .hero-subtitle {
        font-size: 14px !important;
        line-height: 1.4;
        margin-bottom: 15px;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .hero-buttons .btn {
        width: 100%;
        padding: 12px 20px !important;
        font-size: 14px !important;
    }
    
    .carousel-control {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .carousel-control.prev {
        left: 10px;
    }
    
    .carousel-control.next {
        right: 10px;
    }
    
    .carousel-indicators {
        bottom: 10px;
    }
    
    .indicator {
        width: 8px;
        height: 8px;
        margin: 0 4px;
    }
}

/* ========================================
   CARD FIXES - MAJOR MOBILE ISSUE
   ======================================== */

/* General card fixes */
.card, .event-card, .service-card, .impact-card, 
.donation-card, .volunteer-card {
    width: 100%;
    max-width: 100%;
    margin: 0 0 20px 0;
}

@media (max-width: 768px) {
    /* Card containers */
    .events-grid, .services-grid, .impact-grid,
    .team-grid, .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 0 !important;
    }
    
    /* Individual cards */
    .card, .event-card, .service-card, .impact-card {
        padding: 15px !important;
        margin: 0 0 15px 0 !important;
        border-radius: 12px;
    }
    
    /* Card images */
    .card img, .event-card img, .service-card img {
        width: 100%;
        height: auto;
        max-height: 200px;
        object-fit: cover;
        border-radius: 8px;
    }
    
    .event-image, .service-image {
        width: 100%;
        height: 200px;
        overflow: hidden;
        border-radius: 8px 8px 0 0;
    }
    
    .event-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Card content */
    .card-content, .event-content, .service-content {
        padding: 15px !important;
    }
    
    /* Card titles */
    .card h3, .event-title, .service-title {
        font-size: 18px !important;
        line-height: 1.3;
        margin-bottom: 10px;
    }
    
    /* Card descriptions */
    .card p, .event-description, .service-description {
        font-size: 14px !important;
        line-height: 1.5;
    }
    
    /* Card buttons */
    .card .btn, .event-details-btn, .service-btn {
        width: 100%;
        padding: 10px 15px !important;
        font-size: 14px !important;
        margin-top: 10px;
    }
}

/* ========================================
   STATISTICS SECTION FIXES
   ======================================== */

@media (max-width: 768px) {
    .stats-section, .impact-section {
        padding: 30px 15px !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    
    .stat-card, .impact-card {
        padding: 20px 15px !important;
        text-align: center;
    }
    
    .stat-number, .impact-number {
        font-size: 28px !important;
        margin-bottom: 5px;
    }
    
    .stat-label, .impact-label {
        font-size: 12px !important;
        line-height: 1.3;
    }
    
    .stat-icon, .impact-icon {
        font-size: 28px !important;
        margin-bottom: 10px;
    }
}

/* ========================================
   FORM FIXES
   ======================================== */

@media (max-width: 768px) {
    .form-container, .donation-form, .volunteer-form {
        padding: 20px 15px !important;
        margin: 20px 0 !important;
    }
    
    .form-group {
        margin-bottom: 15px !important;
    }
    
    .form-group label {
        font-size: 14px !important;
        margin-bottom: 5px;
    }
    
    .form-control, input, select, textarea {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border-radius: 8px;
    }
    
    textarea {
        min-height: 120px;
    }
    
    /* Radio buttons and checkboxes */
    .radio-group, .checkbox-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .radio-option, .checkbox-option {
        padding: 12px;
        font-size: 14px;
    }
    
    /* Amount selection */
    .amount-options {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .amount-btn {
        padding: 15px 10px !important;
        font-size: 16px !important;
    }
    
    /* Submit buttons */
    .form-submit, .btn-submit {
        width: 100% !important;
        padding: 15px !important;
        font-size: 16px !important;
        margin-top: 20px;
    }
}

/* ========================================
   EVENTS PAGE SPECIFIC FIXES
   ======================================== */

@media (max-width: 768px) {
    .events-hero {
        padding: 80px 15px 40px !important;
        margin-top: 60px !important;
    }
    
    .events-hero h1 {
        font-size: 24px !important;
        margin-bottom: 10px;
    }
    
    .events-hero p {
        font-size: 14px !important;
    }
    
    .events-filters {
        flex-direction: column;
        gap: 10px;
        padding: 20px 15px !important;
    }
    
    .filter-btn {
        width: 100%;
        padding: 12px !important;
        font-size: 14px !important;
    }
    
    .events-grid {
        padding: 20px 15px !important;
    }
    
    .event-card {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .event-status {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
    
    .event-date {
        font-size: 13px !important;
    }
}

/* ========================================
   DONATION PAGE FIXES
   ======================================== */

@media (max-width: 768px) {
    .donation-hero {
        padding: 80px 15px 40px !important;
        margin-top: 60px !important;
    }
    
    .donation-options {
        flex-direction: column;
    }
    
    .donation-card {
        margin-bottom: 20px;
    }
    
    .payment-methods {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .payment-method {
        padding: 15px !important;
        font-size: 14px !important;
    }
    
    .donation-summary {
        position: static !important;
        margin-top: 30px;
        padding: 20px 15px !important;
    }
}

/* ========================================
   ABOUT PAGE FIXES
   ======================================== */

@media (max-width: 768px) {
    .about-hero {
        padding: 80px 15px 40px !important;
        margin-top: 60px !important;
    }
    
    .team-grid {
        grid-template-columns: 1fr !important;
    }
    
    .team-member {
        padding: 20px !important;
    }
    
    .team-member img {
        width: 120px;
        height: 120px;
    }
    
    .mission-grid, .values-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

/* ========================================
   MODAL FIXES
   ======================================== */

@media (max-width: 768px) {
    .modal {
        padding: 10px !important;
    }
    
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto !important;
        padding: 20px 15px !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header h2 {
        font-size: 20px !important;
    }
    
    .modal-body {
        padding: 15px 0 !important;
    }
    
    .modal-close {
        width: 35px;
        height: 35px;
        font-size: 24px;
    }
    
    .modal img {
        width: 100%;
        height: auto;
        max-height: 250px;
        object-fit: cover;
    }
}

/* ========================================
   TABLE FIXES
   ======================================== */

@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    thead {
        display: none;
    }
    
    tbody, tr, td {
        display: block;
        width: 100%;
    }
    
    tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
        background: white;
    }
    
    td {
        text-align: right;
        padding: 10px;
        border: none;
        position: relative;
        padding-left: 50%;
    }
    
    td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: bold;
        text-align: left;
    }
}

/* ========================================
   FOOTER FIXES
   ======================================== */

@media (max-width: 768px) {
    footer {
        padding: 30px 15px !important;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
        text-align: center;
    }
    
    .footer-section {
        padding: 0 !important;
    }
    
    .footer-section h3 {
        font-size: 18px !important;
        margin-bottom: 15px;
    }
    
    .footer-section ul li {
        font-size: 14px !important;
        margin-bottom: 10px;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .social-links a {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding-top: 20px;
    }
}

/* ========================================
   UTILITY CLASSES FOR MOBILE
   ======================================== */

@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-show {
        display: block !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-padding {
        padding: 15px !important;
    }
    
    .mobile-margin {
        margin: 15px 0 !important;
    }
}

/* ========================================
   SECTION SPACING FIXES
   ======================================== */

@media (max-width: 768px) {
    section {
        padding: 40px 15px !important;
    }
    
    .section-title {
        font-size: 24px !important;
        margin-bottom: 15px;
    }
    
    .section-subtitle {
        font-size: 14px !important;
        margin-bottom: 25px;
    }
}

/* ========================================
   TOUCH-FRIENDLY IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Larger touch targets */
    a, button, .btn, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better link spacing */
    a {
        padding: 5px;
    }
    
    /* Prevent text selection on double tap */
    .no-select {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* ========================================
   LANDSCAPE MODE FIXES (Mobile Landscape)
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 300px;
    }
    
    .carousel-item img {
        min-height: 250px;
        max-height: 400px;
        object-fit: contain;
        object-position: center;
    }
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

/* ========================================
   SMALL MOBILE DEVICES (< 375px)
   ======================================== */

@media (max-width: 375px) {
    .container {
        padding: 0 8px;
    }
    
    .logo h2 {
        font-size: 14px !important;
        max-width: 160px;
    }
    
    .hero-title {
        font-size: 18px !important;
    }
    
    .hero-subtitle {
        font-size: 12px !important;
    }
    
    .btn {
        font-size: 13px !important;
        padding: 10px 15px !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .stat-number {
        font-size: 24px !important;
    }
}

/* ========================================
   SMALL MOBILE DEVICES (< 480px)
   ======================================== */

@media (max-width: 480px) {
    .carousel-caption {
        padding: 1rem 1.5rem !important;
        bottom: 20px;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    /* Disable heavy animations on mobile */
    .animate-on-scroll,
    .parallax,
    .complex-animation {
        animation: none !important;
        transform: none !important;
    }
    
    /* Simplify transitions */
    * {
        transition-duration: 0.2s !important;
    }
    
    /* Reduce shadows for performance */
    .card, .btn, .modal-content {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
}
