/* =============================================
   DIGII DEVELOPERZ - RESPONSIVE CSS
   Mobile-First + Perfect on All Devices
============================================= */

/* ========== GLOBAL OVERFLOW FIX ========== */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw;
}

.container {
    max-width: 100%;
}

/* Fix elements that might cause horizontal overflow */
img,
video,
iframe,
embed,
object {
    max-width: 100%;
    height: auto;
}

/* Background elements - prevent overflow */
.bg-animated,
.bg-grid,
.floating-shapes,
.bg-gradient-orb {
    max-width: 100vw;
    overflow: hidden;
}

/* ========== LARGE SCREENS (1440px+) ========== */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }

    .hero-content h1 {
        font-size: 5rem;
    }

    .hero-shape-main {
        width: 480px;
        height: 480px;
    }
}

/* ========== LAPTOP / SMALL DESKTOP (1024px - 1200px) ========== */
@media (max-width: 1200px) {
    .container {
        padding: 0 2rem;
    }

    .hero .container {
        gap: 3rem;
    }

    .footer-top {
        grid-template-columns: 1.5fr 1fr 1fr 1fr;
        gap: 2rem;
    }

    .creative-grid.grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== TABLET (768px - 1024px) ========== */
@media (max-width: 1024px) {

    /* Hide cursor effects on tablet */
    .cursor,
    .cursor-follower,
    .cursor-trail-dot {
        display: none !important;
    }

    /* Navigation */
    .nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 400px;
        height: 100vh;
        background: rgba(12, 12, 18, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        justify-content: flex-start;
        padding: 100px 2rem 2rem;
        transition: var(--transition-normal);
        z-index: 999;
        border-left: 1px solid var(--dark-border);
        overflow-y: auto;
    }

    .nav.active {
        right: 0;
    }

    .nav-links {
        flex-direction: column;
        gap: 0;
        margin-bottom: 2rem;
        width: 100%;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block;
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        border-radius: var(--radius-md);
        width: 100%;
    }

    /* Dropdown - Show on click/tap */
    .nav-links .dropdown-menu {
        position: static;
        transform: none;
        width: 100%;
        opacity: 1;
        visibility: visible;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        box-shadow: none;
        border: none;
        background: rgba(99, 102, 241, 0.1);
        margin: 0;
        padding: 0;
        border-radius: var(--radius-md);
    }

    .nav-links .dropdown.active .dropdown-menu {
        max-height: 600px;
        padding: 0.5rem 0;
    }

    .nav-links .dropdown-menu a {
        padding: 0.75rem 1.5rem 0.75rem 2rem;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .nav-links .dropdown>a i {
        transition: transform 0.3s ease;
    }

    .nav-links .dropdown.active>a i {
        transform: rotate(180deg);
    }

    .menu-toggle {
        display: flex;
    }

    .nav .btn {
        width: 100%;
        margin-top: 1rem;
    }

    /* HERO - Hide image on tablet, show text first */
    .hero .container {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-content {
        order: 1;
    }

    .hero-visual {
        display: none !important;
    }

    .hero-tagline {
        margin: 0 auto 2rem;
    }

    .hero-btns {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
    }

    /* Grids */
    .creative-grid.grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .creative-grid.grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* About page grid */
    .creative-grid[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Feature Cards - Center */
    .feature-card {
        text-align: center;
        flex-direction: column;
        align-items: center;
    }

    .feature-card .icon {
        margin: 0 auto 1rem;
    }

    /* Footer */
    .footer-top {
        grid-template-columns: repeat(2, 1fr);
        gap: 3rem;
    }

    .footer-brand {
        grid-column: span 2;
        text-align: center;
    }

    .footer-brand .logo {
        justify-content: center;
    }

    .footer-social {
        justify-content: center;
    }
}

/* ========== MOBILE LANDSCAPE / SMALL TABLET (576px - 768px) ========== */
@media (max-width: 768px) {

    /* Process Timeline Mobile */
    .process-timeline {
        padding-left: 2rem;
    }

    .process-line {
        left: 0;
    }

    .process-step,
    .process-step:nth-child(odd) {
        flex-direction: column;
        text-align: left;
        gap: 1.5rem;
    }

    .process-step:nth-child(odd) .process-content {
        align-items: flex-start;
    }

    .process-icon {
        width: 70px;
        height: 70px;
        min-width: 70px;
        font-size: 1.5rem;
    }

    .process-step::before {
        display: none;
    }

    .process-content h4 {
        font-size: 1.25rem;
    }

    /* Portfolio Grid Mobile */
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-grid .portfolio-item:nth-child(4),
    .portfolio-grid .portfolio-item:nth-child(5) {
        grid-column: auto;
    }

    :root {
        font-size: 15px;
    }

    .section {
        padding: var(--space-2xl) 0;
    }

    .container {
        padding: 0 1.5rem;
    }
}

/* ========== MOBILE LANDSCAPE / SMALL TABLET CONTINUED (768px) ========== */
@media (max-width: 768px) {

    /* Hero */
    .hero {
        padding-top: 100px;
        min-height: auto;
        padding-bottom: 3rem;
    }

    .hero-content h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .hero-tagline {
        font-size: 1rem;
    }

    .hero-btns {
        flex-direction: column;
        gap: 1rem;
    }

    .hero-btns .btn {
        width: 100%;
    }

    .hero-stats {
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .hero-stat {
        flex: 1 1 40%;
        text-align: center;
    }

    .hero-stat .number {
        font-size: 2rem;
    }

    /* Hide hero visual on mobile too */
    .hero-visual {
        display: none !important;
    }

    /* Section Headers */
    .section-header h2 {
        font-size: 1.75rem;
    }

    /* Grids */
    .creative-grid.grid-2,
    .creative-grid.grid-3,
    .creative-grid.grid-4 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* About page inline styles override */
    .creative-grid[style] {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Cards - Center all cards */
    .card {
        text-align: center;
    }

    .service-card {
        padding: 2rem 1.5rem;
        text-align: center;
    }

    .service-card .icon-wrapper {
        margin: 0 auto 1rem;
    }

    .feature-card {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .feature-card .icon {
        margin: 0 auto 1rem;
    }

    .stat-card .number {
        font-size: 2.5rem;
    }

    /* Testimonials - Fix cutting issue */
    .testimonials-carousel {
        overflow: visible;
        padding: 0 1rem;
    }

    .testimonials-track {
        gap: 1rem;
    }

    .testimonial-card {
        min-width: calc(100vw - 3rem);
        max-width: calc(100vw - 3rem);
        margin: 0 auto;
        padding: 1.5rem;
    }

    .testimonial-card .content p {
        font-size: 0.95rem;
    }

    /* Clients carousel - prevent overflow */
    .clients-carousel {
        overflow: hidden;
    }

    /* CTA */
    .cta-content h2 {
        font-size: 1.5rem;
    }

    .cta-content p {
        font-size: 0.95rem;
    }

    /* Footer - Full mobile layout */
    .footer-top {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        text-align: center;
    }

    .footer-brand {
        grid-column: span 1;
        text-align: center;
    }

    .footer-brand .logo {
        display: inline-flex;
        justify-content: center;
    }

    .footer-brand p {
        text-align: center;
    }

    .footer-column {
        text-align: center;
    }

    .footer-column h4 {
        text-align: center;
    }

    .footer-column h4::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .footer-links {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .footer-links a {
        justify-content: center;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-contact {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .footer-contact li {
        justify-content: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-bottom-links {
        justify-content: center;
    }

    /* Page Header */
    .page-header {
        padding: 120px 0 50px;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    /* Buttons */
    .btn {
        padding: 0.875rem 1.75rem;
    }

    .btn-lg {
        padding: 1rem 2rem;
    }
}

/* ========== MOBILE PORTRAIT (up to 576px) ========== */
@media (max-width: 576px) {
    :root {
        font-size: 14px;
    }

    .container {
        padding: 0 1.25rem;
    }

    /* Header */
    .header {
        padding: 1rem 0;
    }

    .logo {
        font-size: 1.5rem;
    }

    /* Hero */
    .hero-content h1 {
        font-size: 2.25rem;
    }

    .hero-badge {
        font-size: 0.75rem;
        padding: 0.4rem 1rem;
    }

    .hero-shape-main {
        width: 200px;
        height: 200px;
    }

    .floating-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .hero-stats {
        padding-top: 1.5rem;
    }

    /* Cards */
    .card {
        padding: 1.5rem;
    }

    .service-card .icon-wrapper {
        width: 70px;
        height: 70px;
    }

    .service-card .icon {
        font-size: 1.5rem;
    }

    .testimonial-card {
        padding: 1.5rem;
    }

    .testimonial-card .content p {
        font-size: 1rem;
    }

    /* Forms */
    .quote-form {
        padding: 1.5rem;
    }

    .quote-form .form-row {
        grid-template-columns: 1fr;
    }

    .form-control {
        padding: 0.875rem 1.25rem;
    }

    /* WhatsApp Button */
    .whatsapp-btn {
        width: 55px;
        height: 55px;
        font-size: 1.5rem;
        bottom: 20px;
        right: 20px;
    }

    .whatsapp-btn .tooltip {
        display: none;
    }

    /* Back to Top */
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 85px;
        right: 24px;
    }

    /* Nav width on small screens */
    .nav {
        width: 85%;
    }
}

/* ========== EXTRA SMALL (up to 375px) ========== */
@media (max-width: 375px) {
    .container {
        padding: 0 1rem;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-stat .number {
        font-size: 1.75rem;
    }

    .section-header h2 {
        font-size: 1.75rem;
    }

    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* ========== LANDSCAPE ORIENTATION FIX ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 100px 0 50px;
    }

    .hero-visual {
        display: none;
    }

    .nav {
        padding-top: 80px;
        overflow-y: auto;
    }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .bg-gradient-orb,
    .floating-icon,
    .hero-shape-main,
    .cursor-trail-dot {
        animation: none !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ========== DARK MODE PREFERENCE (Already Dark) ========== */
@media (prefers-color-scheme: dark) {
    /* Already using dark theme */
}

/* ========== HIGH CONTRAST ========== */
@media (prefers-contrast: high) {
    :root {
        --dark: #000000;
        --dark-card: #0a0a0a;
        --light: #ffffff;
        --gray: #b0b0b0;
    }

    .card {
        border-width: 2px;
    }
}

/* ========== PRINT STYLES ========== */
@media print {

    .header,
    .footer,
    .whatsapp-btn,
    .back-to-top,
    .preloader,
    .bg-animated,
    .bg-grid,
    .noise-overlay,
    .floating-shapes {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .section {
        page-break-inside: avoid;
    }

    a {
        color: inherit;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {

    /* Disable hover effects on touch devices */
    .card:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }

    .service-card:hover .icon {
        transform: none;
    }

    .cursor-trail-dot {
        display: none !important;
    }
}

/* ========== SAFE AREA INSETS (iPhone X+) ========== */
@supports (padding: max(0px)) {
    .whatsapp-btn {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
    }

    .footer {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}