/* =============================================
   MOBILE OPTIMIZATION - COMPREHENSIVE FIX
   ============================================= */

/* === GLOBAL MOBILE FIXES === */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .container {
        padding: 0 1rem;
    }
}

/* === NAVBAR MOBILE === */
@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 0;
    }
    
    .nav-container {
        padding: 0 1rem;
        height: 60px;
    }
    
    .nav-brand {
        font-size: 1.2rem;
        gap: 0.5rem;
    }
    
    .nav-logo {
        width: 40px;
        height: 40px;
        aspect-ratio: 1;
        object-fit: contain;
        object-position: center;
    }
    
    .nav-brand-text {
        display: none;
    }
    
    .mobile-toggle {
        display: flex;
        width: 40px;
        height: 40px;
        padding: 0;
    }
    
    /* Nav menu is now handled by mobile-menu-new.css - DO NOT OVERRIDE */
    /* Removed conflicting .nav-menu CSS rules */
}

/* === HERO MOBILE === */
@media (max-width: 768px) {
    .hero-rrd {
        min-height: 70vh;
        padding: 2rem 1rem;
        margin-top: 60px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: relative;
        background: linear-gradient(135deg, #003d5c 0%, #0a5f7f 30%, #4fa8c5 70%, #7ec8dd 100%) !important;
        color: #ffffff;
        overflow: visible;
    }
    
    .hero-rrd-content {
        padding-left: 0;
        text-align: center;
        max-width: 100%;
        position: relative;
        z-index: 10;
        width: 100%;
    }
    
    .hero-rrd-subtitle {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
        color: rgba(255, 255, 255, 0.9);
        display: block;
    }
    
    .hero-rrd-title {
        font-size: 1.75rem;
        margin-bottom: 1rem;
        line-height: 1.3;
        color: #ffffff;
        display: block;
    }
    
    .hero-rrd-description {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
        line-height: 1.6;
        max-width: 100%;
        color: rgba(255, 255, 255, 0.9);
        display: block;
    }
    
    .hero-rrd-buttons {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        align-items: stretch;
    }
    
    .hero-rrd-buttons .btn {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 0.9rem;
        border-radius: 8px;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    .hero-rrd-buttons .btn-primary {
        background: #e53e3e;
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
    }
    
    .hero-rrd-buttons .btn-secondary {
        background: transparent;
        color: white;
        border: 2px solid white;
    }
    
    .hero-ribbon {
        display: none !important;
    }
    
    .ribbon-glow {
        display: none !important;
    }
    
    .grid-pattern {
        opacity: 0.15;
    }
    
    .sparkle {
        display: none !important;
    }
}

/* === RUNNING TEXT MOBILE === */
@media (max-width: 768px) {
    .running-text-section {
        padding: 0.8rem 0;
    }
    
    .running-text-wrapper {
        animation-duration: 70s !important;
    }
    
    .running-text-item {
        font-size: 0.8rem;
        padding: 0 1.5rem;
    }
    
    .running-text-item::before {
        font-size: 0.9rem;
        margin-right: 0.5rem;
    }
}

@media (max-width: 480px) {
    .running-text-wrapper {
        animation-duration: 100s !important;
    }
    
    .running-text-item {
        font-size: 0.75rem;
        padding: 0 1.25rem;
    }
}

/* === STATS MOBILE === */
@media (max-width: 768px) {
    .stats-section {
        padding: 2rem 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-item {
        padding: 1rem 0.5rem;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
}

/* === SERVICES MOBILE === */
@media (max-width: 768px) {
    .services-showcase {
        padding: 2rem 1rem;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .service-card {
        padding: 1.5rem 1rem;
    }
    
    .service-icon {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .service-card h3 {
        font-size: 1.1rem;
        margin-bottom: 0.8rem;
    }
    
    .service-card p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .service-link {
        font-size: 0.85rem;
    }
}

/* === PROJECTS MOBILE === */
@media (max-width: 768px) {
    .projects-section {
        padding: 2rem 1rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .project-card {
        padding: 0;
        overflow: hidden;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .card-image {
        width: 100%;
        height: 220px;
        margin: 0;
        border-radius: 0;
        overflow: hidden;
        position: relative;
    }
    
    .card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        display: block;
    }
    
    .project-card h3 {
        font-size: 1.1rem;
        margin: 1rem 0 0.8rem;
    }
    
    .project-card p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
        line-height: 1.6;
    }
    
    .btn-outline {
        width: 100%;
        text-align: center;
    }
}

/* === GALLERY MOBILE === */
@media (max-width: 768px) {
    .section-light {
        padding: 2rem 1rem;
    }
    
    .image-gallery {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .gallery-item {
        width: 100%;
        height: 250px;
        border-radius: 12px;
        overflow: hidden;
        position: relative;
    }
    
    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        display: block;
    }
    
    .gallery-overlay {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1rem;
        background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    }
    
    .gallery-overlay h3 {
        font-size: 0.95rem;
        color: white;
        margin: 0;
    }
}

/* === AWARDS MOBILE === */
@media (max-width: 768px) {
    .awards-section {
        padding: 2rem 1rem;
    }
    
    .awards-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .awards-image {
        border-radius: 12px;
    }
    
    .awards-text h3 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    
    .awards-text p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .awards-text h4 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .certifications-list li {
        font-size: 0.9rem;
        padding: 0.6rem 0;
    }
}

/* === CONTACT MOBILE === */
@media (max-width: 768px) {
    .contact-section {
        padding: 2rem 1rem;
    }
    
    .contact-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .contact-map {
        border-radius: 12px;
        height: 250px;
        overflow: hidden;
    }
    
    .contact-office {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .contact-office h3 {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }
    
    .contact-office p {
        font-size: 0.9rem;
        margin-bottom: 0.6rem;
    }
    
    .contact-cta .btn {
        width: 100%;
    }
}

/* === CTA MOBILE === */
@media (max-width: 768px) {
    .cta-section {
        padding: 2rem 1rem;
    }
    
    .cta-content h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .cta-content p {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }
    
    .cta-buttons {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .btn-outline-white {
        width: 100%;
    }
}

/* === FOOTER MOBILE === */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 1rem 0.5rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .footer h3 {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }
    
    .footer p {
        font-size: 0.9rem;
    }
    
    .footer ul li {
        margin-bottom: 0.5rem;
    }
    
    .footer-bottom {
        font-size: 0.8rem;
        padding: 1rem;
    }
}

/* === BACK TO TOP MOBILE === */
@media (max-width: 768px) {
    .back-to-top {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        bottom: 1rem;
        right: 1rem;
    }
}

/* === SMALL MOBILE (<480px) === */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .nav-container {
        padding: 0 0.75rem;
    }
    
    .hero-rrd {
        min-height: 65vh;
        padding: 2rem 1rem;
        display: flex !important;
        background: linear-gradient(135deg, #003d5c 0%, #0a5f7f 30%, #4fa8c5 70%, #7ec8dd 100%) !important;
    }
    
    .hero-rrd-subtitle {
        font-size: 0.7rem;
        color: rgba(255, 255, 255, 0.9);
    }
    
    .hero-rrd-title {
        font-size: 1.5rem;
        color: #ffffff;
    }
    
    .hero-rrd-description {
        font-size: 0.9rem;
        color: rgba(255, 255, 255, 0.9);
    }
    
    .hero-rrd-buttons {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .hero-rrd-buttons .btn {
        width: 100%;
        padding: 0.9rem 1.25rem;
        font-size: 0.8rem;
        min-height: 48px;
    }
    
    .hero-ribbon {
        display: none !important;
    }
    
    .ribbon-glow {
        display: none !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    .image-gallery {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }
    
    .gallery-item {
        height: 120px;
    }
    
    .section-header h2 {
        font-size: 1.3rem;
    }
    
    .section-header p {
        font-size: 0.9rem;
    }
}


/* === SECTION HEADER MOBILE === */
@media (max-width: 768px) {
    .section-header {
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }
    
    .section-subtitle {
        padding: 0.4rem 1rem;
        font-size: 0.75rem;
        margin-bottom: 0.8rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
        margin-bottom: 0.8rem;
    }
    
    .section-header p {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

/* === MEGA MENU MOBILE === */
/* Handled by mega-menu-final.css */

/* === DROPDOWN MOBILE === */
/* Handled by mega-menu-final.css */

/* === TOUCH FRIENDLY === */
@media (max-width: 768px) {
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .service-link,
    .btn-outline {
        padding: 0.8rem 1rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* === LANDSCAPE MODE === */
@media (max-height: 600px) and (orientation: landscape) {
    .hero-rrd {
        min-height: 100vh;
        padding: 1rem;
    }
    
    .navbar {
        height: 50px;
    }
    
    .nav-container {
        height: 50px;
    }
    
    /* Nav menu is handled by mobile-menu-new.css */
}

/* === PREVENT ZOOM ON INPUT === */
@media (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px;
    }
}

/* === SMOOTH SCROLLING - DISABLED (Handled by JavaScript) === */
@media (max-width: 768px) {
    html {
        scroll-behavior: auto;
    }
}

/* === PREVENT HORIZONTAL SCROLL === */
@media (max-width: 768px) {
    html {
        max-width: 100vw;
        overflow-x: clip;
    }
    
    .container {
        max-width: 100%;
    }
}


/* === CARD IMAGE FIX - UNIVERSAL === */
@media (max-width: 768px) {
    .card,
    .project-card,
    .service-card {
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .card-image,
    .awards-image,
    .contact-map {
        width: 100%;
        height: auto;
        min-height: 200px;
        max-height: 300px;
        overflow: hidden;
        border-radius: 0;
        margin: 0;
        position: relative;
        background: #f0f0f0;
    }
    
    .card-image img,
    .awards-image img,
    .contact-map img,
    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
        display: block;
        border-radius: 0;
    }
    
    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* === GRID IMPROVEMENTS === */
@media (max-width: 768px) {
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .services-grid,
    .projects-grid,
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* === SPACING IMPROVEMENTS === */
@media (max-width: 768px) {
    .section {
        padding: 2.5rem 1rem;
    }
    
    .section-light {
        padding: 2.5rem 1rem;
    }
    
    /* Better spacing between elements */
    h1, h2, h3 {
        margin-top: 0;
    }
    
    p {
        margin-bottom: 1rem;
    }
}

/* === BUTTON IMPROVEMENTS === */
@media (max-width: 768px) {
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-outline,
    .btn-outline-white {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 0.9rem;
        text-align: center;
        justify-content: center;
        border-radius: 8px;
        min-height: 50px;
        display: flex;
        align-items: center;
        box-sizing: border-box;
    }
    
    .hero-buttons,
    .hero-rrd-buttons,
    .cta-buttons {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .btn-primary {
        background: #e53e3e;
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .btn-secondary {
        background: transparent;
        color: white;
        border: 2px solid white;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .btn-primary:active {
        transform: scale(0.98);
    }
    
    .btn-secondary:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.1);
    }
}

/* === TEXT IMPROVEMENTS === */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    p {
        font-size: 0.95rem;
        line-height: 1.6;
    }
}

/* === AWARDS & CONTACT IMAGE FIX === */
@media (max-width: 768px) {
    .awards-image,
    .contact-map {
        aspect-ratio: 16 / 9;
        height: auto;
        min-height: 200px;
        max-height: 250px;
    }
    
    .awards-image img,
    .contact-map img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* === PRODUCT/SERVICE CARDS === */
@media (max-width: 768px) {
    .card {
        margin-bottom: 1.5rem;
        border-radius: 12px;
        overflow: hidden;
        background: white;
        box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    }
    
    .card-content {
        padding: 1.25rem;
    }
    
    .card h3 {
        font-size: 1.15rem;
        margin-bottom: 0.75rem;
        color: #1e3555;
    }
    
    .card p {
        font-size: 0.9rem;
        line-height: 1.6;
        color: #5c6b7a;
        margin-bottom: 1rem;
    }
}

/* === HERO IMPROVEMENTS === */
@media (max-width: 768px) {
    .hero-rrd {
        padding: 2rem 1rem;
        min-height: 70vh;
        display: flex;
        align-items: center;
    }
    
    .hero-rrd-content {
        width: 100%;
        max-width: 100%;
        text-align: center;
    }
    
    .hero-rrd-title {
        font-size: 1.75rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    .hero-rrd-title .highlight {
        display: block;
        margin-top: 0.5rem;
    }
    
    .hero-rrd-description {
        font-size: 0.95rem;
        line-height: 1.7;
        margin-bottom: 1.5rem;
    }
    
    .hero-rrd-buttons {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .hero-rrd-buttons .btn {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 0.9rem;
        min-height: 50px;
        border-radius: 8px;
    }
    
    .hero-ribbon {
        display: none;
    }
    
    .ribbon-glow {
        display: none;
    }
}

/* === SMALL MOBILE IMPROVEMENTS === */
@media (max-width: 480px) {
    .card-image,
    .gallery-item {
        height: 200px;
        min-height: 200px;
    }
    
    .awards-image,
    .contact-map {
        min-height: 180px;
        max-height: 200px;
    }
    
    .section {
        padding: 2rem 0.75rem;
    }
    
    .hero-rrd-title {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.35rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
}

/* === PERFORMANCE OPTIMIZATION === */
@media (max-width: 768px) {
    /* Disable heavy visual effects only */
    .sparkle,
    .ribbon-glow,
    .grid-pattern {
        display: none !important;
    }

    /* Simplify shadows */
    .card,
    .project-card,
    .service-card {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
}


/* === RUNNING TEXT SPEED FIX === */
@media (max-width: 1024px) {
    .running-text-wrapper {
        animation-duration: 60s !important;
    }
}

@media (max-width: 768px) {
    .running-text-wrapper {
        animation-duration: 70s !important;
    }
}

@media (max-width: 480px) {
    .running-text-wrapper {
        animation-duration: 100s !important;
    }
}

@media (max-width: 375px) {
    .running-text-wrapper {
        animation-duration: 120s !important;
    }
}

/* === RUNNING TEXT SMOOTH ANIMATION === */
.running-text-wrapper {
    will-change: transform;
    animation-timing-function: linear;
}

/* Pause on hover/touch */
.running-text-section:hover .running-text-wrapper,
.running-text-section:active .running-text-wrapper {
    animation-play-state: paused;
}
