/* ========================================
   MAGNI ENTERPRISE - Responsive Styles
   Modern 2026 Design
   ======================================== */

/* Extra Large Devices - Wider Navigation (less than 1400px) */
@media (max-width: 1399.98px) {
    .nav-menu {
        gap: 0.25rem;
    }

    .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem 0.875rem;
    }
}

/* Large Devices (Desktops, less than 1200px) */
@media (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }

    .hero-visual {
        width: 40%;
        right: 2%;
    }

    .products-grid-home {
        gap: 1.5rem;
    }

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

    /* Navigation adjustments for medium-large screens */
    .nav-menu {
        gap: 0.125rem;
    }

    .nav-link {
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Large-Medium transition (less than 1100px) - Fix menu overflow */
@media (max-width: 1099.98px) {
    .nav-link {
        font-size: 0.75rem;
        padding: 0.5rem 0.625rem;
    }
}

/* Intermediate screens (1024px - 1100px) - Use mobile menu */
@media (min-width: 1024px) and (max-width: 1099.98px) {
    .nav-toggle {
        display: flex;
        z-index: 1001;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        max-width: 380px;
        height: 100vh;
        background: var(--bg-white);
        z-index: 1003;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0;
        padding: 0;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
    }

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

    .nav-menu::before {
        content: '';
        display: block;
        height: 80px;
        background: var(--bg-light);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-menu li {
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: var(--text-dark);
        font-size: 1rem;
        font-weight: 500;
        padding: 1.25rem 1.5rem;
        border-radius: 0;
    }

    .nav-link:hover,
    .nav-link.active {
        color: var(--primary-color);
    }

    body.menu-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
        background: var(--primary-color);
    }

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

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
        background: var(--primary-color);
    }
}

/* Medium Devices (Tablets, less than 1100px) - Switch to mobile menu */
@media (max-width: 1099.98px) {
    .container {
        max-width: 900px;
    }
}

@media (max-width: 991.98px) {
    .container {
        max-width: 720px;
    }

    .section {
        padding: 5rem 0;
    }

    /* Navigation - Modern Mobile Menu */
    .nav-toggle {
        display: flex;
        z-index: 1001;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        max-width: 380px;
        height: 100vh;
        background: var(--bg-white);
        z-index: 1003;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0;
        padding: 0;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
    }

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

    /* Mobile Menu Header with Logo */
    .nav-menu::before {
        content: '';
        display: block;
        height: 80px;
        background: var(--bg-light);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-menu li {
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-menu li:first-child {
        margin-top: 0;
    }

    .nav-link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: var(--text-dark);
        font-size: 1rem;
        font-weight: 500;
        padding: 1.25rem 1.5rem;
        border-radius: 0;
        background: transparent;
        transition: all 0.2s ease;
    }

    .nav-link:hover,
    .nav-link.active {
        color: var(--primary-color);
    }

    /* Mobile Menu Overlay */
    body.menu-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    body.menu-open {
        overflow: hidden;
    }

    /* Toggle Animation */
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
        background: var(--primary-color);
    }

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

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
        background: var(--primary-color);
    }

    /* Hero */
    .hero {
        min-height: auto;
        padding: 8rem 0 5rem;
    }

    .hero-content {
        max-width: 100%;
    }

    .hero-visual {
        display: none;
    }

    /* About Visual Container */
    .about-visual-container {
        height: 300px;
    }

    .about-visual-globe {
        font-size: 5rem;
    }

    /* About Grid */
    .about-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .about-image {
        order: -1;
        text-align: center;
    }

    /* Products Grid */
    .products-grid-home {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .product-category-card {
        padding: 2rem;
    }

    /* Product Detail Grid */
    .product-detail-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .product-detail-grid.reverse {
        direction: ltr;
    }

    .product-detail-image {
        order: -1;
    }

    /* About Intro */
    .about-intro-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

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

    /* Timeline */
    .timeline::before {
        left: 20px;
    }

    .timeline-item {
        flex-direction: row !important;
        text-align: left !important;
        padding-left: 60px;
    }

    .timeline-marker {
        left: 0;
        transform: none;
        width: 60px;
        font-size: 0.75rem;
    }

    .timeline-content {
        width: 100%;
    }

    /* Timeline with Images - Tablet */
    .timeline-with-images .timeline-image {
        height: 160px;
    }

    .timeline-with-images .timeline-text {
        padding: 1.25rem;
    }

    /* Values Grid */
    .values-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Contact Grid */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2.5rem;
    }

    .footer-brand {
        grid-column: span 2;
        text-align: center;
    }
}

/* Small Devices (Landscape phones, less than 768px) */
@media (max-width: 767.98px) {
    /* Prevent horizontal overflow - CRITICAL */
    html {
        overflow-x: hidden !important;
        max-width: 100vw;
        font-size: 15px;
    }

    body {
        overflow-x: hidden !important;
        max-width: 100vw;
        position: relative;
    }

    .container {
        max-width: 100%;
        padding: 0 1.5rem;
        overflow: hidden;
    }

    /* Header fix for mobile */
    .header {
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }

    .nav {
        width: 100%;
        padding: 0;
    }

    /* Hide hero shapes that cause overflow */
    .hero-shapes,
    .hero-shapes .shape,
    .shape {
        display: none !important;
    }

    /* Stats banner - prevent overflow */
    .stats-banner {
        overflow: hidden;
        max-width: 100vw;
    }

    .stats-banner::before {
        max-width: 100%;
    }

    /* Stats grid on mobile - 2 columns */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        width: 100%;
    }

    .stat-item {
        width: 100%;
        overflow: hidden;
    }

    .stat-item .stat-number {
        font-size: 1.75rem;
        word-break: break-word;
    }

    .stat-item .stat-label {
        font-size: 0.6875rem;
        letter-spacing: 0.03em;
    }

    /* Feature highlights - single column */
    .feature-highlights {
        grid-template-columns: 1fr;
    }

    .feature-highlight-item {
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .feature-highlight-item:last-child {
        border-bottom: none;
    }

    .feature-highlight-item i {
        font-size: 2rem;
    }

    .feature-highlight-item h4 {
        font-size: 1rem;
    }

    .feature-highlight-item p {
        font-size: 0.875rem;
    }

    /* Partners logos mobile */
    .partners-logos {
        gap: 1.5rem !important;
    }

    .partners-logos img {
        height: 28px !important;
    }

    /* About section mobile */
    .about-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .about-image {
        order: -1;
    }

    .about-stats-inline {
        flex-wrap: wrap;
        gap: 1.5rem;
        justify-content: space-between;
    }

    .stat-inline {
        flex: 0 0 calc(33.333% - 1rem);
        text-align: center;
    }

    .stat-inline .stat-number,
    .stat-inline .stat-text {
        font-size: 1.5rem;
    }

    .stat-inline .stat-label {
        font-size: 0.75rem;
    }

    /* About team image */
    .about-team-image {
        border-radius: 16px;
        max-height: 300px;
        object-fit: cover;
        width: 100%;
    }

    /* Products grid mobile */
    .products-grid-home {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .product-category-card {
        padding: 1.5rem;
    }

    .card-svg-icon img {
        height: 48px;
    }

    .card-features {
        margin: 1rem 0;
    }

    .card-features li {
        font-size: 0.875rem;
        padding: 0.375rem 0;
    }

    .section {
        padding: 4rem 0;
    }

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

    /* Hamburger menu - Clean minimal design */
    .nav-toggle {
        width: 44px;
        height: 44px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 6px;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
        z-index: 1001;
        padding: 0;
    }

    .nav-toggle:hover {
        transform: scale(1.05);
    }

    .nav-toggle:active {
        transform: scale(0.95);
    }

    .nav-toggle span {
        width: 26px;
        height: 2.5px;
        background: #fff;
        border-radius: 2px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform-origin: center;
    }

    /* Hamburger to X animation */
    .nav-toggle.active span:nth-child(1) {
        transform: translateY(8.5px) rotate(45deg);
        background: var(--primary-color);
    }

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

    .nav-toggle.active span:nth-child(3) {
        transform: translateY(-8.5px) rotate(-45deg);
        background: var(--primary-color);
    }

    /* Light header hamburger */
    .header-light .nav-toggle span {
        background: var(--text-dark);
    }

    .header-light .nav-toggle.active span {
        background: var(--primary-color);
    }

    /* Scrolled header hamburger */
    .header.scrolled .nav-toggle span {
        background: var(--text-dark);
    }

    .header.scrolled .nav-toggle.active span {
        background: var(--primary-color);
    }

    /* Hero */
    .hero {
        padding: 7rem 0 4rem;
    }

    .hero-title {
        font-size: clamp(2rem, 8vw, 2.75rem);
    }

    .hero-description {
        font-size: 1.1rem;
    }

    .hero-buttons {
        flex-direction: column;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    /* About Intro Stats */
    .about-intro-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .stat-card .stat-number {
        font-size: 1.75rem;
    }

    /* Values Grid */
    .values-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .value-item {
        padding: 1rem;
    }

    .value-item i {
        font-size: 1.75rem;
    }

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

    .contact-info-card,
    .contact-form-card {
        padding: 1.5rem;
    }

    /* Eco Badges */
    .eco-badges {
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .eco-badge i {
        font-size: 1.5rem;
    }

    /* Footer - 2 columns on mobile */
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        text-align: left;
    }

    .footer-brand {
        grid-column: span 2;
        text-align: center;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 0.5rem;
    }

    .footer-links {
        text-align: left;
    }

    .footer-links h4 {
        font-size: 0.8125rem;
        margin-bottom: 1rem;
    }

    .footer-links ul {
        gap: 0.5rem;
    }

    .footer-links a {
        font-size: 0.875rem;
    }

    .footer-bottom {
        padding: 1.5rem 0;
        text-align: center;
    }
}

/* Extra Small Devices (Portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    html {
        font-size: 14px;
    }

    .container {
        padding: 0 1.25rem;
        overflow-x: hidden;
    }

    /* Hide animated shapes */
    .hero-shapes,
    .shape {
        display: none !important;
    }

    /* Stats grid smaller */
    .stats-banner {
        padding: 2.5rem 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-item .stat-number {
        font-size: 1.75rem;
    }

    .stat-item .stat-label {
        font-size: 0.6875rem;
    }

    .section {
        padding: 3.5rem 0;
    }

    /* Header */
    .logo-img {
        height: 36px;
    }

    .header {
        padding: 1rem 0;
    }

    /* Hero */
    .hero {
        padding: 6rem 0 3rem;
    }

    .hero-badge {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }

    .hero-title {
        font-size: 1.875rem;
        line-height: 1.15;
    }

    .hero-description {
        font-size: 1rem;
    }

    /* Page Headers */
    .page-header {
        padding: 7rem 0 2.5rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .page-header p {
        font-size: 1rem;
    }

    /* Buttons */
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Product Cards */
    .product-category-card {
        padding: 1.5rem;
    }

    .card-icon {
        width: 56px;
        height: 56px;
    }

    .card-icon i {
        font-size: 1.5rem;
    }

    /* Brand Logo */
    .brand-logo {
        height: 48px;
    }

    /* Image Placeholder */
    .image-placeholder {
        height: 280px;
    }

    .image-placeholder i {
        font-size: 4rem;
    }

    /* Timeline */
    .timeline-marker {
        width: 50px;
        font-size: 0.7rem;
        height: 32px;
    }

    .timeline-item {
        padding-left: 50px;
    }

    /* Timeline with Images - Mobile */
    .timeline-with-images .timeline-image {
        height: 140px;
    }

    .timeline-with-images .timeline-text {
        padding: 1rem;
    }

    .timeline-with-images .timeline-text h3 {
        font-size: 1rem;
    }

    .timeline-with-images .timeline-text p {
        font-size: 0.875rem;
    }

    /* Contact Form */
    .contact-info-card,
    .contact-form-card {
        padding: 1.25rem;
    }

    .contact-icon {
        width: 40px;
        height: 40px;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 0.875rem 1rem;
    }

    /* Footer - keep 2 columns */
    .footer {
        padding-top: 3rem;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem;
    }

    .footer-brand {
        grid-column: span 2;
    }

    .footer-brand .logo-img {
        height: 32px;
    }

    .footer-links h4 {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .footer-links a {
        font-size: 0.8125rem;
    }

    /* Back to Top */
    .back-to-top {
        width: 44px;
        height: 44px;
        bottom: 1.5rem;
        right: 1.5rem;
        font-size: 0.9rem;
    }

    /* Legal Content */
    .legal-section h2 {
        font-size: 1.25rem;
    }

    .legal-section h3 {
        font-size: 1rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }

    .product-category-card:hover {
        transform: none;
    }

    .nav-link:hover::after {
        transform: none;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-detail-image img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 5rem 0 3rem;
    }

    .nav-menu {
        padding-top: 60px;
    }

    .nav-link {
        padding: 0.875rem 1.5rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .back-to-top,
    .nav-toggle,
    .btn,
    .cta {
        display: none !important;
    }

    .hero,
    .page-header {
        min-height: auto;
        padding: 2rem 0;
        background: none !important;
        color: #000;
    }

    .hero-title,
    .hero-description,
    .page-header h1,
    .page-header p {
        color: #000 !important;
    }

    .section {
        padding: 2rem 0;
        page-break-inside: avoid;
    }

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

    a {
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .shape {
        animation: none;
    }

    [data-aos] {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ===== Mobile Centering & Alignment Fixes ===== */
@media (max-width: 991.98px) {
    .product-category-card {
        align-items: center;
        text-align: center;
    }

    .card-svg-icon {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .paper-hero-icon {
        justify-content: center;
    }

    .page-header-icon {
        justify-content: center;
    }
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-brand .logo {
    display: inline-flex;
    justify-content: center;
}

@media (max-width: 767.98px) {
    .partners-logos {
        justify-content: center !important;
    }
}