/* ========================================
   RESPONSIVE FIXES - Mobile & Tablet Enhancements
   Additional responsive styles for optimal mobile experience
   ======================================== */

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

* {
    max-width: 100%;
}

/* Word Wrapping - Prevent Text Overflow */
h1, h2, h3, h4, h5, h6, p, li, td, th, div, span {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Long URLs and Emails */
a {
    word-break: break-word;
}

/* Responsive Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    max-width: 100%;
}

/* Touch Target Sizes for Mobile */
@media (max-width: 768px) {
    a, button, .btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Ensure clickable elements have adequate spacing */
    .nav-link {
        padding: 12px 16px;
    }
}

/* Form Elements - Better Mobile UX */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px 15px;
        width: 100%;
    }

    .form-control {
        font-size: 16px !important;
        width: 100%;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }
}

/* Grid Layouts - Responsive Stacking */
@media (max-width: 768px) {
    .row {
        flex-direction: column;
    }

    .col,
    [class*="col-"] {
        width: 100%;
        max-width: 100%;
    }
}

/* Cards & Content Boxes */
@media (max-width: 768px) {
    .card,
    .service-card,
    .blog-card,
    .portfolio-card {
        margin-bottom: 1.5rem;
    }
}

/* Modals & Popups */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .modal-content {
        border-radius: 12px;
    }
}

/* Navigation Improvements */
@media (max-width: 768px) {
    .navbar {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    .nav-menu {
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }
}

/* Hero Sections */
@media (max-width: 768px) {
    .hero,
    .page-header {
        padding: 80px 0 50px;
    }

    .hero-title,
    .page-header h1 {
        line-height: 1.2;
    }
}

/* Images & Media */
@media (max-width: 768px) {
    .hero-image,
    .about-image,
    .feature-image {
        margin: 2rem 0;
    }

    img {
        border-radius: 10px;
    }
}

/* Button Groups & Flex Containers */
@media (max-width: 576px) {
    .hero-buttons,
    .btn-group,
    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn,
    .btn-group .btn {
        width: 100%;
        margin: 0.5rem 0;
    }
}

/* Utility Classes */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }

    .mobile-visible {
        display: block !important;
    }

    .text-mobile-center {
        text-align: center !important;
    }
}

/* Spacing Adjustments */
@media (max-width: 768px) {
    section {
        padding: 50px 0;
    }

    .section-header {
        margin-bottom: 2.5rem;
    }
}

@media (max-width: 480px) {
    section {
        padding: 40px 0;
    }

    .section-header {
        margin-bottom: 2rem;
    }
}

/* Better Touch Interactions */
.btn,
a,
button {
    -webkit-tap-highlight-color: rgba(126, 217, 87, 0.2);
    -webkit-touch-callout: none;
}

/* Smooth Scrolling on Mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Fix for iOS Safari Bottom Bar */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* Landscape Orientation Fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .hero,
    .page-header {
        padding: 60px 0 40px;
    }

    .hero-title,
    .page-header h1 {
        font-size: 2rem;
    }
}

/* Fix Overflowing Content */
@media (max-width: 768px) {
    pre {
        overflow-x: auto;
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    code {
        word-break: break-all;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .footer,
    .hamburger,
    .btn,
    .social-links {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    h1 {
        font-size: 24pt;
    }

    h2 {
        font-size: 18pt;
    }
}

/* Final mobile layout polish - loaded early, so key overrides use !important */
@media (max-width: 968px) {
    .navbar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        left: 0 !important;
        z-index: 10000 !important;
        padding: 0.55rem 0 !important;
        background: rgba(255, 255, 255, 0.98) !important;
        box-shadow: 0 8px 28px rgba(20, 32, 23, 0.08) !important;
    }

    .navbar .container {
        min-height: 52px !important;
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }

    .logo svg {
        width: 150px !important;
        height: auto !important;
    }

    .hamburger {
        display: inline-flex !important;
        width: 42px !important;
        height: 42px !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        border: 1px solid rgba(74, 156, 45, 0.22) !important;
        border-radius: 14px !important;
        background: #f7fbf5 !important;
        box-shadow: 0 8px 18px rgba(20, 32, 23, 0.08) !important;
    }

    .hamburger span {
        width: 20px !important;
        height: 2px !important;
        background: #1d2d20 !important;
    }

    .nav-menu {
        position: fixed !important;
        top: 74px !important;
        right: 1rem !important;
        left: 1rem !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.35rem !important;
        width: auto !important;
        max-height: calc(100vh - 96px) !important;
        padding: 0.8rem !important;
        border: 1px solid #dce9d6 !important;
        border-radius: 22px !important;
        background:
            radial-gradient(circle at top right, rgba(126, 217, 87, 0.16), transparent 34%),
            rgba(255, 255, 255, 0.99) !important;
        box-shadow: 0 24px 70px rgba(20, 32, 23, 0.16) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(-10px) !important;
        transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease !important;
        overflow-y: auto !important;
        text-align: left !important;
        z-index: 9999 !important;
    }

    .nav-menu.active {
        left: 1rem !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }

    .nav-menu li {
        width: 100% !important;
    }

    .nav-link {
        display: flex !important;
        width: 100% !important;
        min-height: 48px !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0.85rem 1rem !important;
        border-radius: 14px !important;
        color: #18281b !important;
        font-size: 0.98rem !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        letter-spacing: -0.01em !important;
        text-align: left !important;
        white-space: nowrap !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
        hyphens: none !important;
    }

    .nav-link::after {
        display: none !important;
    }

    .nav-link:hover,
    .nav-link.active {
        background: rgba(126, 217, 87, 0.12) !important;
        color: #347d21 !important;
    }
}

@media (max-width: 768px) {
    .hero {
        padding-top: 7.8rem !important;
    }

    .page-header,
    .services-hero,
    .about-hero,
    .portfolio-hero,
    .portfolio-detail-hero,
    .blog-hero,
    .blog-detail-hero {
        padding-top: 8.4rem !important;
    }

    .about .about-text,
    .about .section-title,
    .about .about-description {
        text-align: center !important;
    }

    .about .features-list {
        max-width: 340px !important;
        margin-right: auto !important;
        margin-left: auto !important;
    }
}
