/* Mobile Responsiveness Enhancements */

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* General adjustments */
    body, html {
        font-size: 15px;
        overflow-x: hidden; /* Prevent horizontal scrolling */
        width: 100%;
        max-width: 100vw;
        position: relative;
        margin: 0;
        padding: 0;
    }
    
    .container {
        padding-left: 15px;
        padding-right: 15px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin: 0 auto;
        overflow-x: hidden;
    }
    
    /* Fix for gallery container overflow */
    .gallery-section {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .gallery-section .container {
        padding-left: 10px;
        padding-right: 10px;
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    /* Fix for gallery grid */
    .gallery-grid {
        width: 100%;
        box-sizing: border-box;
        padding: 0 5px;
        overflow-x: hidden;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .gallery-item {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix for page banner */
    .page-banner {
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }
    
    /* Additional fixes for potential overflow elements */
    img, video {
        max-width: 100%;
        height: auto;
    }
    
    /* Fix for potential wide tables, preformatted text, etc. */
    table, pre, iframe, embed, object {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Make sure all sections and divs respect container width */
    section, div {
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    h1 {
        font-size: 28px;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 24px;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 20px;
        line-height: 1.3;
    }
    
    p {
        font-size: 15px;
        line-height: 1.5;
    }
    
    /* Improved Mobile Menu */
    .mobile-menu-btn {
        display: block;
        position: relative;
        z-index: 1000;
        background: none;
        border: none;
        cursor: pointer;
        padding: 10px;
        margin-right: -10px;
    }
    
    .mobile-menu-btn span {
        display: block;
        width: 25px;
        height: 3px;
        margin: 5px 0;
        background-color: var(--secondary-color);
        transition: all 0.3s ease;
    }
    
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }
    
    .nav-links {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: var(--light-color);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 999;
        padding: 50px 20px;
        overflow-y: auto;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-links li {
        margin: 15px 0;
        width: 100%;
        text-align: center;
    }
    
    .nav-links a {
        font-size: 18px;
        display: inline-block;
        padding: 8px 0;
        width: 100%;
    }
    
    .nav-right {
        display: none;
    }
    
    .nav-right.active {
        display: block;
        position: fixed;
        bottom: 100px;
        left: 0;
        width: 100%;
        text-align: center;
        z-index: 999;
    }
    
    .social-icons {
        justify-content: center;
        margin-top: 20px;
        display: flex;
        flex-wrap: wrap;
    }
    
    /* When menu is open, prevent body scrolling */
    body.menu-open {
        overflow: hidden;
    }
    
    /* Header adjustments */
    .header .container {
        padding: 10px 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .navbar {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .logo-container {
        display: flex;
        align-items: center;
        max-width: 100%;
        flex-shrink: 0;
        min-width: 0;
        width: auto;
    }
    
    .logo {
        max-width: 65%;
    }
    
    .logo-img {
        width: 40px;
        height: 40px;
    }
    
    .org-name {
        font-size: 16px;
        margin-left: 8px;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        max-width: 180px;
        line-height: 1.2;
    }
    
    /* Grid adjustments */
    .grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    /* Section spacing */
    section {
        padding: 40px 0;
        overflow-x: hidden;
    }
    
    .section-header {
        margin-bottom: 30px;
    }
    
    /* Hero section adjustments */
    .hero {
        height: auto;
        min-height: 100vh;
        padding: 120px 0 60px;
    }
    
    .hero-content {
        padding: 0 15px;
        text-align: center;
    }
    
    .hero-content h1 {
        font-size: 30px;
        line-height: 1.3;
    }
    
    .cta-buttons {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .cta-buttons .btn {
        width: 100%;
        max-width: 250px;
        text-align: center;
    }
    
    /* About section fixes */
    .about-image-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .impact-image {
        width: 100%;
        height: auto;
        margin-bottom: 10px;
    }
    
    .impact-image img {
        height: auto;
        aspect-ratio: 1/1;
        object-fit: cover;
    }
    
    /* Team section adjustments */
    .team-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .team-member {
        width: 100%;
    }
    
    .member-image {
        width: 100%;
        height: auto;
    }
    
    .member-info {
        padding: 10px;
    }
    
    .member-info h3 {
        font-size: 16px;
    }
    
    .member-info .position {
        font-size: 14px;
    }
    
    /* Vision section fixes */
    .vision-section {
        display: block !important; 
        padding: 40px 0;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .mobile-vision-fix {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px;
        width: 100%;
    }
    
    .vision-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px;
        width: 100%;
    }
    
    .founder-image {
        width: 100%;
        max-width: 250px;
        margin: 0 auto 20px;
    }
    
    .vision-content {
        width: 100%;
        box-sizing: border-box;
    }
    
    .vision-quote {
        font-size: 1.2rem;
        line-height: 1.4;
    }
    
    .vision-description {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    /* Gallery category tabs fixes */
    .gallery-categories {
        position: relative;
        margin-bottom: 30px;
    }
    
    .category-tabs {
        display: flex;
        padding: 10px 0;
        white-space: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        background-color: #fff;
        z-index: 10;
        justify-content: flex-start !important;
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
    }
    
    .category-tabs::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
    
    .category-tab {
        flex: 0 0 auto;
        margin: 0 5px;
        padding: 8px 15px;
        font-size: 13px;
        border-radius: 30px;
        background-color: #f5f5f5;
        color: var(--secondary-color);
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
        white-space: nowrap;
    }
    
    .category-tab.active {
        background-color: var(--primary-color);
        color: white;
    }
    
    /* Swipe instruction for gallery categories */
    .swipe-instruction {
        position: absolute;
        top: -30px;
        left: 0;
        width: 100%;
        text-align: center;
        background-color: rgba(255, 255, 255, 0.95);
        color: var(--secondary-color);
        font-size: 12px;
        padding: 5px 10px;
        border-radius: 20px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 5;
        transition: opacity 0.5s ease;
        opacity: 1;
    }
    
    .swipe-icon {
        display: flex;
        align-items: center;
        margin-right: 8px;
        animation: swipeMotion 1.5s infinite ease-in-out;
    }
    
    .swipe-icon i {
        font-size: 10px;
        margin: 0 2px;
        color: var(--primary-color);
    }
    
    @keyframes swipeMotion {
        0% { transform: translateX(-2px); }
        50% { transform: translateX(2px); }
        100% { transform: translateX(-2px); }
    }
    
    /* Remove sticky behavior on mobile */
    .category-tabs.sticky {
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        padding: 10px 15px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        animation: slideDown 0.3s ease;
    }
    
    /* Scroll indicator for category tabs */
    .scroll-indicator {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 30px;
        height: 30px;
        background-color: rgba(255, 255, 255, 0.8);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        z-index: 15;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .scroll-indicator.right {
        right: 5px;
    }
    
    .scroll-indicator i {
        color: var(--secondary-color);
        font-size: 14px;
    }
    
    .scroll-indicator:hover {
        background-color: var(--primary-color);
    }
    
    .scroll-indicator:hover i {
        color: white;
    }
    
    @keyframes slideDown {
        from { transform: translateY(-100%); }
        to { transform: translateY(0); }
    }
    
    /* Category description */
    .category-description {
        display: none;
        margin-bottom: 20px;
        padding: 15px;
        background-color: #f9f9f9;
        border-radius: 8px;
    }
    
    .category-description.active {
        display: block;
    }
    
    /* Footer Logo Fix */
    .footer-logo {
        text-align: center;
        max-width: 80px;
        margin: 0 auto 15px;
    }
    
    .footer-logo img {
        width: 100%;
        max-width: 60px;
        height: auto;
    }
    
    /* Footer spacing improvements */
    .footer .grid {
        gap: 20px;
    }
    
    .footer {
        padding: 40px 0 20px;
    }
    
    .full-org-name {
        display: inline !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        word-break: normal !important;
        word-wrap: normal !important;
    }
}

/* Small Mobile Devices */
@media (max-width: 576px) {
    /* Banner adjustments */
    .page-banner {
        padding: 30px 0;
        min-height: auto;
    }
    
    .page-banner h1 {
        font-size: 24px;
    }
    
    .page-banner p {
        font-size: 14px;
    }
    
    /* Button adjustments */
    .btn {
        padding: 8px 16px;
        font-size: 14px;
        width: 100%;
        max-width: 200px;
        text-align: center;
        margin: 5px auto;
    }
    
    /* Gallery adjustments */
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .gallery-item {
        margin-bottom: 15px;
    }
    
    .gallery-content h3 {
        font-size: 16px;
    }
    
    .gallery-content p {
        font-size: 13px;
    }
    
    /* Category tabs */
    .category-tabs {
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 8px 0;
    }
    
    .category-tab {
        font-size: 12px;
        padding: 6px 10px;
        margin: 2px 4px;
    }
    
    /* Cause cards */
    .cause-card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    /* Team section - single column for smallest screens */
    .team-row {
        grid-template-columns: 1fr;
    }
    
    .about-image-grid {
        grid-template-columns: 1fr;
    }
    
    /* Form adjustments */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group label {
        font-size: 14px;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Footer adjustments */
    .footer {
        padding: 40px 0 20px;
        text-align: center;
    }
    
    .footer h4 {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .footer-logo {
        max-width: 70px;
        margin: 0 auto 15px;
    }
    
    .footer-logo img {
        max-width: 50px;
        height: auto;
    }
    
    .footer-links ul {
        padding-left: 0;
    }
    
    .footer-contact p {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .newsletter-form input {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .footer-bottom {
        margin-top: 30px;
        padding-top: 20px;
    }
    
    .footer-bottom p {
        font-size: 12px;
    }
    
    /* Adjust grid spacing */
    .footer .grid {
        gap: 15px;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 90%;
        padding: 15px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .close-modal {
        top: 10px;
        right: 10px;
    }
    
    /* Donation adjustments */
    .amount-options {
        flex-wrap: wrap;
    }
    
    .amount-btn {
        font-size: 14px;
        padding: 8px;
        flex: 0 0 calc(50% - 10px);
    }
    
    .custom-amount-container {
        width: 100%;
        margin-top: 10px;
    }
    
    .org-name {
        font-size: 15px;
        max-width: 160px;
        white-space: normal;
        overflow: visible;
        line-height: 1.2;
    }
}

@media (max-width: 360px) {
    .org-name {
        font-size: 13px;
        max-width: 150px;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.2;
    }
    
    .logo-img {
        width: 35px;
        height: 35px;
    }
    
    .page-banner h1 {
        font-size: 22px;
    }
    
    .btn {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .hero-content h1 {
        font-size: 24px;
    }
    
    .hero-content p {
        font-size: 14px;
    }
    
    /* Fix for donation form */
    .amount-btn {
        font-size: 12px;
        padding: 6px;
    }
    
    /* Smaller category tabs for very small screens */
    .category-tab {
        font-size: 11px;
        padding: 5px 8px;
        margin: 2px;
    }
    
    /* Ultra-small screen logo fix */
    .footer-logo {
        max-width: 50px;
    }
    
    .footer-logo img {
        max-width: 40px;
    }
}
