/* Mobile First Responsive Design */

/* Tablet styles */
@media screen and (max-width: 1024px) {
    .navbar {
        padding: 0.5rem 1rem;
        position: relative;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .nav-brand {
        order: 1;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        height: -webkit-calc(100vh - 70px); /* Safari */
        background-color: var(--background-color);
        display: -webkit-flex; /* Safari */
        display: flex;
        -webkit-flex-direction: column; /* Safari */
        flex-direction: column;
        -webkit-justify-content: flex-start; /* Safari */
        justify-content: flex-start;
        -webkit-align-items: center; /* Safari */
        align-items: center;
        text-align: center;
        -webkit-transition: 0.3s; /* Safari */
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
        -webkit-box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05); /* Safari */
        z-index: 999;
        padding-top: 2rem;
        gap: 1.5rem;
        -webkit-transform: translateX(0); /* Safari smooth animation */
        transform: translateX(0);
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        margin: 0;
        width: 100%;
    }

    .nav-menu a {
        display: block;
        width: 100%;
        padding: 1rem 2rem;
        font-size: 1.1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .social-icons {
        order: 3;
        gap: 0.5rem;
    }

    .nav-toggle {
        display: block;
        order: 2;
    }
    
    .social-icons a {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .social-icons a:hover {
        transform: translateY(-2px) scale(1.05);
        box-shadow: 0 6px 20px rgba(24, 119, 242, 0.3);
    }

    .social-icon {
        width: 25px;
        height: 25px;
    }

    .social-icons a:hover .social-icon {
        transform: rotate(3deg);
    }
    .nav-toggle {
        display: flex !important;
        flex-direction: column;
        cursor: pointer;
        order: 2;
        z-index: 1001;
        width: 30px;
        height: 25px;
        justify-content: space-between;
    }

    .nav-toggle span {
        width: 100%;
        height: 3px;
        background: var(--text-color);
        transition: all 0.3s ease;
        transform-origin: center;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(0, 8px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(0, -8px);
    }
    .logo {
        height: 65px;
        max-width: 280px;
    }

    .nav-toggle {
        display: none;
        z-index: 1000;
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .nav-toggle.active span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .hero-content h1,
    .page-hero h1 {
        font-size: 1.9rem;
        line-height: 1.1;
    }

    /* Smaller text for other pages on tablet */
    .page-hero h1 {
        font-size: 1.6rem;
    }

    /* Specific adjustment for home page longer title on tablet */
    #home .hero-content h1 {
        font-size: 1.9rem;
        line-height: 1.1;
    }

    .hero-content p,
    .page-hero p {
        font-size: 1rem;
    }

    /* Smaller paragraph for other pages on tablet */
    .page-hero p {
        font-size: 0.95rem;
    }

    .main-sections h2 {
        font-size: 2.2rem;
    }

    .sections-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .page-hero {
        padding: 50px 0 15px;
        min-height: 15vh;
    }

    .section-card {
        padding: 2rem 1.5rem;
    }

    .section-icon {
        font-size: 3rem;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .calculator-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }

    .reasons-grid {
        gap: 1rem;
        padding: 0 1rem;
        max-width: 900px;
    }
    
    .reason {
        max-width: 280px;
        padding: 1.5rem 0.5rem;
    }
    
    .reason-item {
        width: 100%;
        max-width: none;
        margin: 0 auto;
        box-sizing: border-box;
    }

    .reason-number {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    section {
        padding: 60px 0;
    }

    .about h2,
    .services h2,
    .contact h2 {
        font-size: 2rem;
    }
}

/* Mobile styles */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .navbar {
        padding: 0.5rem 0.8rem;
        justify-content: space-between;
        align-items: center;
    }

    .nav-brand {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .reasons-grid {
        display: -webkit-flex; /* Safari */
        display: flex;
        -webkit-flex-direction: column; /* Safari */
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        -webkit-justify-content: center; /* Safari */
        justify-content: center;
        -webkit-align-items: center; /* Safari */
        align-items: center;
        -webkit-box-sizing: border-box; /* Safari */
        box-sizing: border-box;
    }
    
    .reason {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        -webkit-box-sizing: border-box; /* Safari */
        box-sizing: border-box;
        -webkit-flex: none; /* Safari */
        flex: none;
        padding: 1.5rem 1rem;
        /* Ensure Safari renders properly */
        -webkit-transform: translateZ(0); /* Hardware acceleration */
        transform: translateZ(0);
    }
    
    /* Ensure no overflow on mobile */
    body {
        overflow-x: hidden;
    }
    
    .container {
        max-width: 100%;
        box-sizing: border-box;
    }

    .nav-brand h1 {
        font-size: 1.2rem;
    }

    .logo {
        height: 40px;
        max-width: 180px;
    }

    .company-name {
        font-size: 1.2rem;
    }

    .social-icons {
        display: none; /* Hide on mobile to save space */
    }

    .nav-toggle {
        display: flex !important;
    }

    .nav-menu {
        position: fixed;
        top: 65px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 65px);
        background-color: var(--background-color);
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        text-align: center;
        transition: left 0.3s ease;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        padding-top: 2rem;
        gap: 0;
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        margin: 0;
        width: 100%;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .nav-menu a {
        display: block;
        width: 100%;
        padding: 1.2rem 2rem;
        font-size: 1.1rem;
        color: var(--text-color);
        text-decoration: none;
        transition: background-color 0.3s ease;
    }

    .nav-menu a:hover,
    .nav-menu a.active {
        background-color: var(--light-background);
        color: var(--primary-color);
    }

    .hero {
        padding: 80px 0 50px;
        min-height: 30vh;
    }

    .page-hero {
        padding: 45px 0 10px;
        min-height: 12vh;
    }

    .hero-content h1,
    .page-hero h1 {
        font-size: 1.5rem;
        line-height: 1.1;
    }

    /* Smaller text for other pages on mobile */
    .page-hero h1 {
        font-size: 1.3rem;
    }

    .hero-content p,
    .page-hero p {
        font-size: 1rem;
        line-height: 1.4;
    }

    /* Smaller paragraph for other pages on mobile */
    .page-hero p {
        font-size: 0.9rem;
    }

    /* Contact page mobile optimizations */
    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .contact-method {
        padding: 1.5rem;
        text-align: center;
    }

    .contact-form.enhanced {
        padding: 1.5rem;
        margin: 0 -5px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

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

    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        border-radius: 8px;
    }

    .btn {
        width: 100%;
        padding: 15px;
        font-size: 1rem;
        border-radius: 8px;
        touch-action: manipulation; /* Better touch response */
    }

    .contact-guarantee {
        padding: 1.5rem;
        margin: 0 -5px;
    }

    .map-placeholder {
        padding: 1.5rem;
        margin: 0 -5px;
        text-align: center;
    }

    /* Portfolio mobile optimizations */
    .filter-buttons {
        flex-direction: column;
        gap: 0.8rem;
    }

    .filter-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Service cards mobile optimizations */
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    .sections-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    .section-card {
        max-width: 100%;
    }

    /* Why us section mobile optimization */
    .reasons-grid {
        display: -webkit-flex; /* Safari */
        display: flex;
        -webkit-flex-direction: column; /* Safari */
        flex-direction: column;
        gap: 1.5rem;
        -webkit-align-items: center; /* Safari */
        align-items: center;
        width: 100%;
        -webkit-justify-content: center; /* Safari */
        justify-content: center;
        -webkit-box-sizing: border-box; /* Safari */
        box-sizing: border-box;
    }

    .reason {
        width: 100%;
        max-width: 350px;
        padding: 2rem 1.5rem;
        margin: 0 auto !important;
        -webkit-box-sizing: border-box; /* Safari */
        box-sizing: border-box !important;
        -webkit-flex: none; /* Safari */
        flex: none !important;
    }

    .reason-number {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin: 0 auto 1rem auto;
    }

    .page-hero {
        padding: 80px 0 50px;
        min-height: 30vh;
    }

    /* Ensure home page hero matches other pages on mobile */
    #home.hero,
    #home .hero {
        padding: 80px 0 50px;
        min-height: 30vh;
    }

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

    .hero-content p,
    .page-hero p {
        font-size: 1rem;
    }

    .main-sections {
        padding: 60px 0;
    }

    .main-sections h2 {
        font-size: 1.8rem;
    }

    .sections-intro {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .section-card {
        padding: 1.5rem;
    }

    .section-icon {
        font-size: 2.5rem;
    }

    .section-card h3 {
        font-size: 1.4rem;
    }

    .why-us {
        padding: 60px 0;
    }

    .why-us h2 {
        font-size: 2rem;
    }

    .reasons-grid {
        grid-template-columns: 1fr;
    }

    .reason {
        padding: 1.5rem 1rem;
    }

    .reason-number {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .btn {
        padding: 10px 25px;
        font-size: 0.9rem;
    }

    .btn-back-home {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    .service-card h3 {
        font-size: 1.3rem;
    }

    section {
        padding: 40px 0;
    }

    .about h2,
    .services h2,
    .contact h2 {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    .contact-form input,
    .contact-form textarea {
        padding: 10px;
        font-size: 0.9rem;
    }

    .footer {
        padding: 2rem 0 1.5rem;
    }

    .footer-content {
        gap: 1rem;
    }
}

/* Mobile styles */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .navbar {
        padding: 0.8rem 1rem;
    }

    .nav-brand h1 {
        font-size: 1.5rem;
    }

    .hero {
        padding-top: 70px;
    }

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

    .hero-content p,
    .page-hero p {
        font-size: 1rem;
    }

    .main-sections {
        padding: 60px 0;
    }

    .main-sections h2 {
        font-size: 1.8rem;
    }

    .sections-intro {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .section-card {
        padding: 1.5rem;
    }

    .section-icon {
        font-size: 2.5rem;
    }

    .section-card h3 {
        font-size: 1.4rem;
    }

    .why-us {
        padding: 60px 0;
    }

    .why-us h2 {
        font-size: 2rem;
    }

    .reasons-grid {
        grid-template-columns: 1fr;
    }

    .reason {
        padding: 1.5rem 1rem;
    }

    .reason-number {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .btn {
        padding: 10px 25px;
        font-size: 0.9rem;
    }

    .btn-back-home {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    .service-card h3 {
        font-size: 1.3rem;
    }

    section {
        padding: 40px 0;
    }

    .about h2,
    .services h2,
    .contact h2 {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    .contact-form input,
    .contact-form textarea {
        padding: 10px;
        font-size: 0.9rem;
    }

    .footer {
        padding: 2rem 0 1.5rem;
    }

    .footer-content {
        gap: 1rem;
    }
}

/* Large screens */
@media screen and (min-width: 1200px) {
    .hero-content h1,
    .page-hero h1 {
        font-size: 2.7rem;
        line-height: 1.1;
    }

    /* Smaller text for other pages on large screens */
    .page-hero h1 {
        font-size: 2.2rem;
    }

    .hero-content p,
    .page-hero p {
        font-size: 1.2rem;
    }

    /* Smaller paragraph for other pages on large screens */
    .page-hero p {
        font-size: 1.1rem;
    }

    .main-sections h2 {
        font-size: 3.5rem;
    }

    .sections-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .reasons-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        align-items: center;
    }
}

/* Print styles */
@media print {
    .header,
    .nav-toggle,
    .btn {
        display: none;
    }

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

    .hero {
        background: none;
        color: var(--text-color);
        min-height: auto;
        padding: 20pt 0;
    }

    .page-hero {
        background: none;
        color: var(--text-color);
        padding: 20pt 0;
    }

    section {
        page-break-inside: avoid;
        padding: 20pt 0;
    }

    .footer {
        background: none;
        color: var(--text-color);
        border-top: 1pt solid var(--text-color);
    }
}

/* Mobile styles */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .navbar {
        padding: 0.8rem 1rem;
    }

    .nav-brand h1 {
        font-size: 1.5rem;
    }

    .hero {
        padding: 70px 0 50px;
        min-height: 30vh;
    }

    /* Ensure home page hero matches other pages */
    #home.hero,
    #home .hero {
        padding: 70px 0 50px;
        min-height: 30vh;
    }

    .hero-content h1 {
        font-size: 1.5rem;
        line-height: 1.1;
    }

    /* Specific adjustment for home page longer title */
    #home .hero-content h1 {
        font-size: 1.5rem;
        line-height: 1.1;
    }

    .hero-content p {
        font-size: 1rem;
    }

    .btn {
        padding: 10px 25px;
        font-size: 0.9rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    .service-card h3 {
        font-size: 1.3rem;
    }

    section {
        padding: 40px 0;
    }

    .about h2,
    .services h2,
    .contact h2 {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    .contact-form input,
    .contact-form textarea {
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* Large screens */
@media screen and (min-width: 1200px) {
    .hero-content h1 {
        font-size: 4rem;
    }

    .hero-content p {
        font-size: 1.4rem;
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Print styles */
@media print {
    .header,
    .nav-toggle,
    .btn {
        display: none;
    }

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

    .hero {
        background: none;
        color: var(--text-color);
        min-height: auto;
        padding: 20pt 0;
    }

    section {
        page-break-inside: avoid;
        padding: 20pt 0;
    }
}

/* Safari and iOS specific fixes */
@supports (-webkit-appearance: none) {
    /* Fix Safari flexbox issues */
    .reasons-grid {
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
    }
    
    /* Fix Safari viewport issues */
    body {
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Fix Safari touch target sizes */
    .btn, .nav-menu a, .hamburger {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Fix Safari input zoom */
    input, textarea, select {
        font-size: 16px;
    }
    
    /* Fix Safari safe area for mobile */
    @media screen and (max-width: 480px) {
        body {
            padding-left: env(safe-area-inset-left);
            padding-right: env(safe-area-inset-right);
        }
        
        .navbar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
    }
}