/* ============================================
   MOBILE RESPONSIVENESS COMPLETE OVERHAUL
   Ultra-optimized for 360px-480px devices
   FIXED: Grid cards, images, tables, text wrapping
   ============================================ */

@media (max-width: 768px) {

    .product-table thead,
    .product-table thead th {
        background: var(--gradient-primary) !important;
        color: var(--white) !important;
    }
}

/* ============================================
   CRITICAL FIXES - HORIZONTAL SCROLL PREVENTION
   ============================================ */

@media (max-width: 768px) {

    .nav-link,
    .nav-link:hover,
    .nav-link:focus,
    .nav-link:focus-visible,
    .nav-link:active,
    .nav-link.active,
    html[data-theme="dark"] body .nav-link,
    html[data-theme="dark"] body .nav-link:hover,
    html[data-theme="dark"] body .nav-link:focus,
    html[data-theme="dark"] body .nav-link:active,
    html[data-theme="dark"] body .nav-link.active {
        border-bottom: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-link:active,
    .nav-link.active,
    html[data-theme="dark"] body .nav-link:active,
    html[data-theme="dark"] body .nav-link.active {
        background: var(--primary) !important;
        color: var(--white) !important;
    }

    html body .nav-link::before,
    html body .nav-link::after {
        content: none !important;
        display: none !important;
    }
}

/* Prevent horizontal scroll on ALL viewports */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative;
}

/* Box-sizing for all elements */
*,
*::before,
*::after {
    box-sizing: border-box !important;
}

/* ============================================
   BUG FIX 1: GRID CARDS COLLAPSE ON MOBILE
   Remove word-break: break-all / overflow-wrap: anywhere
   ============================================ */

/* CRITICAL: Remove character-by-character breaking */
* {
    word-break: normal !important;
    overflow-wrap: normal !important;
}

/* Allow breaking only for very long words (safety net) */
h1,
h2,
h3,
h4,
h5,
h6,
p,
li,
span,
div,
.domain-card,
.why-card,
.service-box,
.control-item,
.pillar-item,
.hato-product-card,
.advantage-card {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    hyphens: manual !important;
    -webkit-hyphens: manual !important;
    -ms-hyphens: manual !important;
}

/* CRITICAL: Cardurile trebuie să aibă spațiu pentru text normal */
@media (max-width: 600px) {

    .why-card,
    .service-box,
    .domain-card,
    .control-item {
        padding: 20px !important;
        min-height: auto !important;
    }

    .why-card h3,
    .service-box h3,
    .domain-card h3,
    .control-item h3 {
        font-size: clamp(16px, 4vw, 20px) !important;
        line-height: 1.4 !important;
        margin-bottom: 12px !important;
        word-break: normal !important;
        white-space: normal !important;
    }

    .why-card p,
    .service-box p,
    .domain-card p {
        font-size: clamp(14px, 3.5vw, 16px) !important;
        line-height: 1.6 !important;
    }
}

/* Never break these */
.btn,
.nav-link,
.hato-product-name,
.mega-menu-item {
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    white-space: normal !important;
}

/* ============================================
   BUG FIX 2: IMAGES CONSTRAINED TO CONTAINERS
   ============================================ */

/* All images must be responsive by default */
img,
picture,
video,
svg {
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

/* Remove any fixed widths on image containers - EXCEPT logo and contact-welcome */
.hero-image-wrapper,
.hero-main-image,
.hotraco-image,
.hato-image,
.footer-logo-image {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
}

/* Logo and contact-welcome maintain ORIGINAL dimensions from styles.css */
.logo-image {
    width: 260px !important;
    height: 130px !important;
    max-width: none !important;
}

.contact-welcome-image {
    max-width: 950px !important;
    width: auto !important;
    height: auto !important;
}

/* CRITICAL: Product images pe paginile de produse - DOAR MOBIL */
@media (max-width: 1023px) {
    .product-image-col {
        max-width: 100% !important;
        width: 100% !important;
    }

    .product-image-col img,
    .product-image-col .product-image {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
    }
}

/* Product image grid responsive */
.product-image-grid {
    max-width: 100% !important;
    width: 100% !important;
}

@media (max-width: 768px) {
    .product-image-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .product-image-col {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ============================================
   BUG FIX 3: TABLES WITH HORIZONTAL SCROLL
   ============================================ */

/* Wrap ALL tables in scroll containers */
.product-table-wrapper,
.specs-table-wrapper,
.table-wrapper,
table {
    width: 100% !important;
    max-width: 100% !important;
}

/* CRITICAL: Table wrappers trebuie să aibă scroll local */
.product-table-wrapper,
.specs-table-wrapper,
.table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
    display: block !important;
}

@media (max-width: 768px) {

    /* Table wrappers get local horizontal scroll */
    .product-table-wrapper,
    .specs-table-wrapper,
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100% !important;
        margin: var(--space-lg, 16px) 0 !important;
        border-radius: 8px;
        display: block !important;
    }

    /* Tables can exceed wrapper width for scrolling */
    .product-table-wrapper table,
    .specs-table-wrapper table,
    .table-wrapper table,
    .product-table,
    .specs-table {
        min-width: 600px !important;
        /* Adjust based on column count */
        width: max-content !important;
        max-width: none !important;
        display: table !important;
    }

    /* Table cells maintain readable size */
    .product-table th,
    .product-table td,
    .specs-table th,
    .specs-table td {
        white-space: nowrap !important;
        padding: 12px 16px !important;
        min-width: 80px !important;
    }

    /* Product image grid - stack vertical pe mobil */
    .product-image-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }

    .product-image-col {
        width: 100% !important;
        max-width: 100% !important;
        order: 0 !important;
    }

    /* Prima coloană (imagine) */
    .product-image-col:first-child {
        order: 1 !important;
    }

    /* A doua coloană (tabel) */
    .product-image-col:last-child {
        order: 2 !important;
    }
}


/* ============================================
   GRID CARDS - RESPONSIVE BREAKPOINTS WITH BETTER SPACING
   3 columns (>1024px), 2 columns (601-1024px), 1 column (<600px)
   ============================================ */

/* Mobile (<600px) - ALL GRIDS TO 1 COLUMN WITH GENEROUS SPACING */
@media (max-width: 600px) {

    /* CRITICAL: Force toate gridurile la 1 coloană pe telefon */
    .domains-grid,
    .products-preview,
    .why-cards,
    .services-grid,
    .control-areas,
    .advantages-grid,
    .advantages-grid-auto,
    .systems-grid,
    .hato-products,
    .hato-benefits-grid,
    .partners-content,
    .partner-logos,
    .integration-features,
    .product-features,
    .product-features-grid,
    .applications-list,
    .silo-features-grid,
    .panel-gallery,
    .detail-images-grid,
    .detail-images-grid-uniform,
    .product-gallery,
    .category-grid,
    .partners-grid,
    .contact-grid,
    .contact-grid-new,
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
        /* Increased from 16px for better breathing room */
        display: grid !important;
        padding: 0 !important;
        /* Remove any extra padding that squeezes content */
    }

    /* CRITICAL: Toate cardurile trebuie să ocupe toată lățimea pe telefon */
    .why-card,
    .service-box,
    .domain-card,
    .product-preview-card,
    .advantage-card,
    .advantage-item,
    .control-item,
    .hato-product-card {
        grid-column: 1 / -1 !important;
        /* Ocupă toată lățimea */
        min-width: 0 !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        /* Extra space after each card */
    }

    /* EXTRA FIX: advantages-grid specific - forțează 1 coloană */
    .advantages-grid {
        grid-template-columns: 1fr !important;
        display: grid !important;
        gap: 24px !important;
    }

    .advantages-grid .advantage-item {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    /* Hero pillars - 2 columns on mobile with better spacing */
    .hero-pillars {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
        /* Increased from 12px */
    }
}

/* Tablet (601px - 1024px) - 2 COLUMNS */
@media (min-width: 601px) and (max-width: 1024px) {

    .domains-grid,
    .products-preview,
    .why-cards,
    .services-grid,
    .advantages-grid,
    .advantages-grid-auto,
    .systems-grid,
    .hato-products,
    .hato-benefits-grid,
    .partners-content,
    .integration-features,
    .product-features,
    .product-features-grid,
    .silo-features-grid,
    .panel-gallery,
    .detail-images-grid,
    .detail-images-grid-uniform,
    .product-gallery,
    .category-grid,
    .partners-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-lg, 24px) !important;
    }

    /* CRITICAL: Cardurile ocupă 1 coloană fiecare pe tabletă */
    .why-card,
    .service-box,
    .domain-card,
    .advantage-card,
    .control-item {
        grid-column: span 1 !important;
    }

    /* Some grids stay at 1 column even on tablet */
    .contact-grid,
    .contact-grid-new,
    .footer-content {
        grid-template-columns: 1fr !important;
    }

    /* Hero pillars - 4 columns on tablet */
    .hero-pillars {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    /* Control areas - 4 columns on tablet */
    .control-areas {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Desktop (>1024px) - 3+ COLUMNS (defaults from main CSS apply) */
@media (min-width: 1025px) {

    /* Asigură că gridurile folosesc numărul corect de coloane pe desktop */
    .domains-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
    }

    .why-cards {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    .why-card {
        grid-column: span 2 !important;
    }

    .services-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    .service-box {
        grid-column: span 2 !important;
    }

    .control-areas {
        grid-template-columns: repeat(8, 1fr) !important;
    }

    .advantages-grid-auto {
        grid-template-columns: repeat(8, 1fr) !important;
    }

    .hato-products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ============================================
   1. TYPOGRAPHY SCALING - FLUID & RESPONSIVE
   ============================================ */

/* Base font size adjustment for mobile */
@media (max-width: 480px) {
    html {
        font-size: 14px;
        /* Reduce base from 16px to 14px */
    }
}

/* Hero titles - dramatically smaller on mobile */
@media (max-width: 480px) {

    .hero-title,
    .page-title {
        font-size: clamp(24px, 7vw, 32px) !important;
        line-height: 1.2;
        letter-spacing: -0.02em;
    }

    .hero-subtitle,
    .page-subtitle {
        font-size: clamp(14px, 4vw, 16px) !important;
        line-height: 1.5;
    }
}

/* Section titles - proportionally scaled */
@media (max-width: 480px) {

    .section-title,
    h2 {
        font-size: clamp(20px, 6vw, 26px) !important;
        line-height: 1.3;
    }

    .section-desc {
        font-size: clamp(13px, 3.5vw, 15px) !important;
        line-height: 1.6;
    }
}

/* Card titles - much smaller */
@media (max-width: 480px) {

    .domain-card h3,
    .why-card h3,
    .service-box h3,
    .control-item h3,
    .pillar-item h3,
    .hato-product-card h3,
    .advantage-card h3 {
        font-size: clamp(14px, 4vw, 16px) !important;
        line-height: 1.4;
        word-wrap: break-word;
        hyphens: auto;
    }
}

/* Paragraphs and body text */
@media (max-width: 480px) {

    p,
    .card p,
    .domain-card p,
    .why-card p,
    .service-box p {
        font-size: clamp(12px, 3.5vw, 14px) !important;
        line-height: 1.6;
    }
}

/* Buttons - larger tap targets */
@media (max-width: 480px) {

    .btn,
    .btn-primary {
        font-size: 14px !important;
        padding: 12px 20px !important;
        min-height: 44px;
        /* Touch-friendly */
    }
}

/* ============================================
   CRITICAL FIX: BUTTON SCALE ISSUE ON CLICK
   Disable hover scale effect on touch devices
   Use only active state for feedback
   ============================================ */

/* Disable scale on hover for ALL devices to prevent flash */
.btn-primary:hover,
.btn:hover,
.btn-secondary:hover {
    /* Remove scale that causes the flash effect on click */
}

/* Add subtle scale feedback only on active state */
.btn-primary:active,
.btn:active,
.btn-secondary:active {
    transform: scale(0.98) !important;
    transition: transform 100ms ease !important;
}

/* Mobile and touch devices specific - completely disable hover scale */
@media (hover: none) and (pointer: coarse) {

    /* This targets touch devices specifically */
    .btn-primary:hover,
    .btn:hover,
    .btn-secondary:hover,
    .subnav-link:hover,
    a.btn:hover,
    button:hover {
        transform: none !important;
    }

    /* Only apply transform on active (actual press) */
    .btn-primary:active,
    .btn:active,
    .btn-secondary:active,
    .subnav-link:active,
    a.btn:active,
    button:active {
        transform: scale(0.98) !important;
        transition: transform 100ms ease !important;
    }

    /* Prevent any element from scaling on hover on touch devices */
    .domain-card:hover,
    .why-card:hover,
    .service-box:hover,
    .product-preview-card:hover,
    .pillar-item:hover {
        transform: translateY(-12px) !important;
        /* Keep vertical movement, remove scale */
    }
}

/* ============================================
   2. CARD LAYOUT & SPACING - MORE BREATHING ROOM
   ============================================ */

/* IMPROVED: More generous spacing for better mobile UX */
@media (max-width: 480px) {

    .domain-card,
    .why-card,
    .service-box,
    .contact-item,
    .feature-item,
    .hato-product-card,
    .advantage-card,
    .control-item,
    .pillar-item {
        padding: 20px !important;
        /* Increased from 12px */
        gap: 16px !important;
        /* More space between elements */
        margin-bottom: 16px !important;
        /* Space between cards */
    }

    /* Extra space for text content inside cards */
    .domain-card p,
    .why-card p,
    .service-box p,
    .advantage-card p,
    .control-item p {
        margin-top: 12px !important;
        line-height: 1.7 !important;
        /* Better readability */
    }

    /* Titles need breathing room */
    .domain-card h3,
    .why-card h3,
    .service-box h3,
    .advantage-card h3,
    .control-item h3 {
        margin-bottom: 12px !important;
    }
}

/* Grid adjustments - single column on tiny screens with MORE SPACING */
@media (max-width: 414px) {

    .domains-grid,
    .why-cards,
    .services-grid,
    .control-areas-grid,
    .pillars-grid,
    .hato-products-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        /* Increased from 12px */
    }
}

/* Two columns for 360-414px where it makes sense - with better spacing */
@media (max-width: 480px) {

    .advantages-grid,
    .systems-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 16px !important;
        /* Increased from 8px */
    }

    /* But single column if cards have too much text */
    .partner-logos-section,
    .integration-features {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* Ensure cards have enough width */
@media (max-width: 480px) {

    .domain-card,
    .why-card,
    .hato-product-card {
        min-width: 0 !important;
        /* Allow flex-shrink */
        width: 100% !important;
    }
}

/* ============================================
   3. CONTAINER & SPACING REDUCTION - BETTER BREATHING ROOM
   ============================================ */

/* Container padding - more comfortable */
@media (max-width: 480px) {
    .container {
        padding: 0 20px !important;
        /* Increased from 12px */
    }
}

/* Section padding - more generous */
@media (max-width: 480px) {

    .section-padding,
    section {
        padding: 40px 0 !important;
        /* Increased from 24px */
        margin-bottom: 20px !important;
        /* Space between sections */
    }

    .hero,
    .page-header {
        padding: 60px 0 40px !important;
        /* More breathing room */
        min-height: auto !important;
    }
}

/* Reduce gaps everywhere - BUT MORE GENEROUS THAN BEFORE */
@media (max-width: 480px) {
    :root {
        --space-xs: 6px;
        /* Increased from 4px */
        --space-sm: 12px;
        /* Increased from 8px */
        --space-md: 20px;
        /* Increased from 12px */
        --space-lg: 28px;
        /* Increased from 16px */
        --space-xl: 36px;
        /* Increased from 24px */
        --space-2xl: 48px;
        /* Increased from 32px */
        --space-3xl: 60px;
        /* Increased from 40px */
        --space-4xl: 72px;
        /* Increased from 48px */
        --space-5xl: 96px;
        /* Increased from 64px */
    }
}

/* ============================================
   4. NAVIGATION - HAMBURGER MENU
   ============================================ */

/* Hide desktop nav, show hamburger */
@media (max-width: 768px) {
    .nav {
        position: fixed;
        top: 70px;
        /* Below header */
        left: -100%;
        width: 280px;
        height: calc(100vh - 70px);
        background: var(--bg-elevated);
        border-right: 1px solid var(--border);
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 20px;
        overflow-y: auto;
        transition: left 0.3s ease;
        z-index: 9998;
    }

    .nav.is-open {
        left: 0;
    }

    .nav-link {
        width: 100%;
        padding: 12px 16px !important;
        border-bottom: 1px solid var(--border);
        font-size: 16px !important;
    }

    /* CRITICAL: Ensure nav links are visible in dark mode on mobile */
    [data-theme="dark"] .nav {
        background: #0a0a0a !important;
        border-right: 1px solid #1a1a1a !important;
    }

    [data-theme="dark"] .nav-link {
        color: #ffffff !important;
        border-bottom: 1px solid #1a1a1a !important;
    }

    [data-theme="dark"] .nav-link:hover {
        color: var(--primary) !important;
        background: rgba(76, 175, 53, 0.1) !important;
    }

    [data-theme="dark"] .nav-link.active {
        color: var(--primary) !important;
        background: rgba(76, 175, 53, 0.15) !important;
    }

    /* Show hamburger button - JOOPA INSPIRED DESIGN WITH SVG ICONS */
    .nav-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        transition: opacity 0.3s ease;

        /* CRITICAL: Fixed positioning - ALWAYS stays in the same spot */
        position: fixed;
        right: 20px;
        top: 20px;
        z-index: 10002;
    }

    .nav-toggle:hover {
        opacity: 0.8;
    }

    .nav-toggle:active {
        opacity: 0.6;
    }

    /* SVG icons styling */
    .nav-toggle svg {
        width: 26px;
        height: 26px;
        transition: all 0.3s ease;
    }

    .nav-toggle .nav-toggle-logo {
        width: 26px;
        height: 26px;
        object-fit: contain;
    }

    /* Menu icon visible by default, close icon hidden */
    .nav-toggle .menu-icon {
        display: block;
    }

    .nav-toggle .close-icon {
        display: none;
    }

    /* When open, swap icons */
    .nav-toggle.is-open .menu-icon {
        display: none;
    }

    .nav-toggle.is-open .close-icon {
        display: block !important;
    }

    /* Icon color adapts to theme and scroll state */
    .nav-toggle svg {
        stroke: var(--text);
    }

    /* Scrolled state */
    .header.scrolled .nav-toggle svg {
        stroke: var(--ink-800, #1c1611);
    }

    /* Dark mode */
    [data-theme="dark"] .nav-toggle svg {
        stroke: var(--primary);
    }

    [data-theme="dark"] .header.scrolled .nav-toggle svg {
        stroke: var(--primary);
    }

    /* Remove old span-based hamburger styles */
    .nav-toggle span {
        display: none !important;
    }

    /* Make sure header-content is position relative for absolute positioning context */
    .header-content {
        position: relative;
    }

    /* Theme and lang toggle in mobile */
    .theme-toggle,
    .lang-toggle {
        position: relative;
        margin: 8px 0;
    }
}

/* ============================================
   5. SPECIFIC COMPONENTS FIX - WITH BETTER SPACING
   ============================================ */

/* Control Items - Fix text breaking AND add spacing */
@media (max-width: 480px) {
    .control-item {
        padding: 16px !important;
        /* Increased from 10px */
        margin-bottom: 12px !important;
    }

    .control-item h3 {
        font-size: 13px !important;
        font-weight: 600;
        word-break: keep-all;
        white-space: normal;
        hyphens: manual;
        margin-bottom: 8px !important;
    }

    /* Specific fixes for problematic words */
    .control-item h3::after {
        content: '';
        display: inline-block;
        width: 0;
    }

    .control-item p {
        line-height: 1.6 !important;
    }
}

/* HATO Product Cards - Corax, Pulsa, etc - with better spacing */
@media (max-width: 480px) {
    .hato-product-card {
        padding: 20px !important;
        /* Increased from 12px */
        min-height: auto !important;
        margin-bottom: 16px !important;
    }

    .hato-product-name {
        font-size: 16px !important;
        padding: 8px 16px !important;
        /* More padding */
        margin-bottom: 12px !important;
    }

    .hato-product-card p {
        font-size: 12px !important;
        line-height: 1.6;
        margin-top: 12px !important;
    }
}

/* Hero content spacing - MORE GENEROUS */
@media (max-width: 480px) {
    .hero-content {
        gap: 24px !important;
        /* Increased from 16px */
        text-align: center;
        padding: 0 8px !important;
    }

    .hero-buttons {
        flex-direction: column !important;
        gap: 16px !important;
        /* Increased from 12px */
        width: 100%;
        margin-top: 8px !important;
    }

    .hero-buttons .btn {
        width: 100% !important;
    }
}

/* Footer - stack columns with better spacing */
@media (max-width: 480px) {
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        /* Increased from 24px */
    }

    .footer-column {
        text-align: center;
        padding: 20px 0 !important;
    }

    .footer-links {
        margin-top: 12px !important;
    }

    .footer-link {
        padding: 8px 0 !important;
    }
}

/* Contact form - more spacing */
@media (max-width: 480px) {
    .contact-grid-new {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        /* Increased from 24px */
    }

    .contact-form-container,
    .contact-info {
        padding: 24px !important;
        /* Increased from 16px */
    }

    .form-group {
        margin-bottom: 20px !important;
    }

    .contact-item {
        padding: 16px 0 !important;
        margin-bottom: 12px !important;
    }
}

/* Images - ensure they scale with margin */
@media (max-width: 480px) {

    .product-image,
    .hero-image,
    .contact-welcome-image {
        max-width: 100% !important;
        height: auto !important;
        margin-bottom: 20px !important;
    }
}

/* Product pages - better spacing */
@media (max-width: 480px) {
    .product-section {
        padding: 32px 0 !important;
        margin-bottom: 24px !important;
    }

    .product-title {
        margin-bottom: 20px !important;
    }

    .product-description {
        margin-bottom: 24px !important;
        line-height: 1.7 !important;
    }

    .product-features-grid,
    .product-specs {
        margin-top: 24px !important;
    }
}

/* Lists - better spacing */
@media (max-width: 480px) {

    ul,
    ol {
        padding-left: 24px !important;
        margin-bottom: 20px !important;
    }

    li {
        margin-bottom: 12px !important;
        line-height: 1.6 !important;
    }
}

/* Headings - spacing after */
@media (max-width: 480px) {

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        margin-bottom: 16px !important;
        margin-top: 24px !important;
    }

    h1:first-child,
    h2:first-child,
    h3:first-child {
        margin-top: 0 !important;
    }
}

/* Paragraphs - better spacing */
@media (max-width: 480px) {
    p {
        margin-bottom: 16px !important;
        line-height: 1.7 !important;
    }
}

/* ============================================
   6. WORD BREAKING & HYPHENATION
   ============================================ */

@media (max-width: 480px) {

    /* Enable hyphenation for Romanian text */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p,
    li,
    span,
    div {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        -webkit-hyphens: auto;
        -ms-hyphens: auto;
    }

    /* But prevent breaking in specific cases */
    .hato-product-name,
    .nav-link,
    .btn {
        hyphens: manual;
        word-break: keep-all;
    }
}

/* ============================================
   7. MEGA MENU MOBILE
   ============================================ */

@media (max-width: 768px) {
    .mega-menu-wrapper {
        width: 100%;
    }

    .mega-menu {
        position: static !important;
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .mega-menu-content {
        flex-direction: column !important;
    }

    .mega-menu-level {
        width: 100% !important;
        padding: 8px 0 !important;
    }

    .mega-menu-item {
        font-size: 14px !important;
        padding: 10px 12px !important;
    }
}

/* ============================================
   8. UTILITY CLASSES
   ============================================ */

/* Hide on mobile */
@media (max-width: 480px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 480px) {
    .show-mobile {
        display: block !important;
    }
}

/* Reduce motion for performance on older phones */
@media (max-width: 480px) and (prefers-reduced-motion: no-preference) {
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.2s !important;
    }
}

/* ============================================
   9. PERFORMANCE OPTIMIZATIONS
   ============================================ */

@media (max-width: 480px) {

    /* Disable expensive effects on mobile */
    *::before,
    *::after {
        animation: none !important;
    }

    /* Simplify shadows */
    .domain-card,
    .why-card,
    .service-box {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }

    .domain-card:hover,
    .why-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        transform: none !important;
        /* Disable transform for performance */
    }
}

/* ============================================
   10. ACCESSIBILITY - TOUCH TARGETS
   ============================================ */

@media (max-width: 480px) {

    /* Minimum 44x44px touch targets */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================
   11. HERO TITLE FLICKER FIX - MOBILE (ALL MODES)
   ============================================ */

/* CRITICAL: Disable ALL animations on .hero-title for mobile to prevent flicker */
@media (max-width: 768px) {
    .hero-title {
        /* Remove animated gradient background */
        background: linear-gradient(135deg, #0d0d0d 0%, #2a6b15 70%, #4caf35 100%) !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        background-clip: text !important;
        background-size: 100% 100% !important;
        /* Static, no animation */

        /* Disable ALL animations */
        animation: none !important;

        /* Remove text-shadow that causes flicker */
        text-shadow: none !important;

        /* Disable will-change to prevent repaints */
        will-change: auto !important;

        /* Static transform for crisp rendering */
        transform: none !important;
        backface-visibility: hidden !important;
        -webkit-font-smoothing: antialiased !important;
    }

    /* Dark mode - simpler white text, no glow */
    [data-theme="dark"] .hero-title {
        background: #ffffff !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        background-clip: text !important;
        text-shadow: none !important;
        animation: none !important;
    }

    /* Disable text-shadow animations on ALL titles in dark mode */
    [data-theme="dark"] h1,
    [data-theme="dark"] h2,
    [data-theme="dark"] h3,
    [data-theme="dark"] h4,
    [data-theme="dark"] .section-title,
    [data-theme="dark"] .page-title,
    [data-theme="dark"] .contact-info-title,
    [data-theme="dark"] .diagram-title {
        text-shadow: none !important;
        color: #ffffff !important;
    }
}


/* ============================================
   12. GLOBAL MOBILE SPACING IMPROVEMENTS - ONLY MOBILE
   ============================================ */

/* CRITICAL: Prevent header overlap with content */
@media (max-width: 768px) {
    body {
        padding-top: 70px !important;
        /* Height of fixed header */
    }

    main {
        margin-top: 0 !important;
    }

    .hero {
        padding-top: 60px !important;
        /* Extra space from header */
    }
}

/* Add consistent spacing throughout ALL mobile pages */
@media (max-width: 768px) {

    /* All major sections get breathing room */
    section,
    .section,
    .product-section,
    .hero-section,
    .content-section {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
        margin-bottom: 24px !important;
    }

    /* Container gets comfortable side padding */
    .container {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* All content blocks get spacing */
    .content-block,
    .text-block,
    .info-block {
        margin-bottom: 24px !important;
        padding: 20px !important;
    }

    /* Tables get spacing */
    .product-table-wrapper,
    .specs-table-wrapper,
    .table-wrapper {
        margin: 24px 0 !important;
    }

    /* Images get spacing */
    .product-image-grid,
    .image-grid,
    .gallery {
        margin: 24px 0 !important;
        gap: 20px !important;
    }

    /* Feature lists get spacing */
    .features-list,
    .specs-list,
    .applications-list {
        gap: 20px !important;
        margin: 24px 0 !important;
    }

    /* Buttons get tap-friendly spacing */
    .btn,
    button,
    .button {
        margin: 8px 0 !important;
        padding: 14px 24px !important;
    }

    /* Form elements get spacing */
    .form-group,
    .input-group {
        margin-bottom: 20px !important;
    }

    input,
    textarea,
    select {
        padding: 14px !important;
        margin-bottom: 8px !important;
    }

    /* Navigation items */
    .nav-link {
        padding: 14px 20px !important;
        margin-bottom: 4px !important;
    }

    /* Mega menu */
    .mega-menu-item {
        padding: 12px 16px !important;
        margin-bottom: 4px !important;
    }
}

/* Extra spacing for very small devices */
@media (max-width: 400px) {
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    section,
    .section {
        padding-top: 32px !important;
        padding-bottom: 32px !important;
    }
}


/* ============================================
   IMAGE ZOOM/LIGHTBOX - MOBILE ONLY
   ============================================ */

/* Only on mobile devices */
@media (max-width: 768px) {

    /* Make product images clickable/tappable */
    .product-image,
    .product-image-col img,
    .hero-main-image,
    .product-featured-image img,
    .detail-images-grid img,
    .panel-gallery img,
    .product-gallery img {
        cursor: pointer;
        transition: transform 0.2s ease;
    }

    /* Subtle tap feedback */
    .product-image:active,
    .product-image-col img:active,
    .hero-main-image:active,
    .product-featured-image img:active {
        transform: scale(0.98);
    }

    /* Lightbox overlay */
    .image-lightbox {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.95);
        z-index: 99999;
        padding: 20px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .image-lightbox.active {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    /* Zoomed image */
    .image-lightbox img {
        max-width: 100%;
        max-height: 90vh;
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 8px;
    }

    /* Close button */
    .image-lightbox-close {
        position: fixed;
        top: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        background: rgba(255, 255, 255, 0.9);
        border: none;
        border-radius: 50%;
        font-size: 24px;
        font-weight: bold;
        color: #000;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 100000;
    }

    .image-lightbox-close:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.8);
    }

    /* Dark mode lightbox */
    [data-theme="dark"] .image-lightbox {
        background: rgba(0, 0, 0, 0.98);
    }

    [data-theme="dark"] .image-lightbox-close {
        background: rgba(76, 175, 53, 0.9);
        color: #000;
    }
}

/* Desktop - disable lightbox functionality */
@media (min-width: 769px) {
    .image-lightbox {
        display: none !important;
    }
}


/* FIX: Product image pentru ventilator-centrifugal - restore original size on DESKTOP ONLY */
@media (min-width: 1024px) {

    .product-image-col .product-image,
    img.product-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
    }
}

/* One consistent mobile icon across pages: legacy favicon/span markup is
   replaced by script.js with these SVGs, so no page can show a stray glyph. */
@media (max-width: 1023px) {
    .nav-toggle {
        position: relative !important;
        flex-direction: row !important;
        gap: 0 !important;
    }

    .nav-toggle>.menu-icon,
    .nav-toggle>.close-icon {
        display: block !important;
        width: 26px !important;
        height: 26px !important;
        margin: 0 !important;
        stroke: currentColor !important;
    }

    .nav-toggle>.close-icon,
    .nav-toggle.is-open>.menu-icon {
        display: none !important;
    }

    .nav-toggle.is-open>.close-icon {
        display: block !important;
    }

    .nav-toggle::before,
    .nav-toggle::after {
        content: none !important;
        display: none !important;
    }
}

/* ============================================
   MOBILE EXPERIENCE — FINAL CONSOLIDATED LAYER
   Based on the responsive system used in Joopa:
   one navigation breakpoint, progressive grids and
   predictable touch-first dimensions.
   ============================================ */
@media (max-width: 1023px) {
    :root {
        --mobile-header-height: 72px;
        --mobile-gutter: clamp(16px, 5vw, 24px);
    }

    html {
        overflow-x: clip !important;
        scroll-padding-top: var(--mobile-header-height);
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        overflow-x: clip !important;
        min-width: 0;
    }

    body.mobile-menu-open {
        position: fixed;
        top: var(--mobile-scroll-y, 0);
        width: 100%;
        overflow: hidden !important;
    }

    .container {
        width: 100%;
        max-width: none !important;
        padding-inline: var(--mobile-gutter) !important;
    }

    img,
    picture,
    video,
    iframe,
    svg {
        max-inline-size: 100%;
    }

    .header-content {
        min-height: var(--mobile-header-height);
        flex-wrap: nowrap;
        gap: 12px;
    }

    .logo {
        min-width: 0;
    }

    .logo-image {
        width: auto !important;
        height: clamp(44px, 12vw, 58px) !important;
        max-width: min(55vw, 220px) !important;
        object-fit: contain;
    }

    .nav-toggle,
    button.nav-toggle {
        display: inline-flex !important;
        flex: 0 0 48px;
        align-items: center;
        justify-content: center;
        width: 48px !important;
        height: 48px !important;
        min-height: 48px;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 12px;
        touch-action: manipulation;
    }

    /* Some legacy pages still use three empty spans for the toggle. Give those
       buttons the same clear menu/close affordance as the SVG-based headers. */
    .nav-toggle>span {
        display: none !important;
    }

    .nav-toggle::before {
        content: '☰';
        color: var(--text, #1f2937);
        font-size: 27px;
        font-weight: 600;
        line-height: 1;
    }

    .nav-toggle.is-open::before {
        content: '×';
        font-size: 34px;
        font-weight: 400;
    }

    .nav-toggle:has(.menu-icon)::before {
        content: none;
    }

    .nav {
        position: fixed !important;
        top: var(--mobile-header-height) !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        width: auto !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 16px var(--mobile-gutter) calc(24px + env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        background: var(--bg, var(--white)) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateX(100%);
        transition: transform 240ms ease, opacity 240ms ease, visibility 240ms ease;
        z-index: 1000 !important;
    }

    .nav.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
    }

    .nav-link {
        display: flex;
        align-items: center;
        min-height: 48px;
        margin: 0 !important;
        padding: 12px 14px !important;
        border-radius: 10px;
        font-size: 16px;
        line-height: 1.35;
    }

    .nav-link:hover,
    .nav-link:focus-visible {
        transform: none;
        background: color-mix(in srgb, var(--primary) 10%, transparent);
    }

    .mega-menu-wrapper {
        display: block;
        width: 100%;
    }

    .mega-menu-wrapper:hover:not(.is-open) .mega-menu {
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
    }

    .mega-menu,
    .mega-menu-wrapper.is-open .mega-menu {
        position: static !important;
        display: none;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 8px 0 0 !important;
        overflow: visible !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
    }

    .mega-menu-wrapper.is-open .mega-menu {
        display: block;
    }

    .mega-menu::before {
        display: none !important;
    }

    .mega-menu .container,
    .mega-menu-level {
        padding: 0 !important;
    }

    .mega-menu-content {
        gap: 0 !important;
    }

    .mega-menu-level-2,
    .mega-menu-level-3 {
        min-width: 0 !important;
        margin: 0 0 0 12px;
        padding: 4px 0 4px 12px !important;
        border-left: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
    }

    .mega-menu-item,
    .mega-menu-product {
        width: 100%;
        min-height: 48px;
        margin: 0 !important;
        padding: 12px !important;
        white-space: normal !important;
        text-align: left;
    }

    .mega-menu-product {
        padding-left: 28px !important;
    }

    .mega-menu-product::before {
        left: 12px;
        opacity: 1;
        transform: none;
    }

    .page-header {
        margin-top: var(--mobile-header-height);
        padding-block: clamp(40px, 8vw, 56px);
    }

    .page-title {
        font-size: clamp(30px, 8vw, 44px) !important;
        line-height: 1.1 !important;
    }

    .page-subtitle,
    .product-intro {
        font-size: clamp(16px, 4vw, 18px);
        line-height: 1.6;
    }

    .section-padding {
        padding-block: clamp(48px, 9vw, 72px) !important;
    }

    .product-image-grid,
    .product-hero-grid,
    .product-features,
    .product-features-grid,
    .product-specs-section,
    .contact-grid,
    .contact-grid-new {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .product-image-col,
    .product-image-container,
    .product-table-wrapper,
    .product-specs-table,
    .table-scroll-wrapper,
    .feature-item,
    .category-card,
    .advantage-item,
    .requirement-item,
    .model-card {
        min-width: 0;
    }

    .product-image-container {
        width: 100% !important;
        max-width: none !important;
    }

    .product-image-col img,
    .product-image-col .product-image {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain;
    }

    .product-specs-section {
        gap: clamp(28px, 6vw, 40px) !important;
        margin-block: clamp(32px, 7vw, 48px) !important;
    }

    .product-main-image {
        width: 100%;
    }

    .product-main-image img {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .table-wrapper,
    .product-table-wrapper,
    .specs-table-wrapper,
    .table-scroll-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
    }

    .product-table-wrapper>table,
    .specs-table-wrapper>table,
    .table-wrapper>table,
    .table-scroll-wrapper>table,
    .product-specs-table>.table-scroll-wrapper>table {
        min-width: 640px !important;
        width: max-content !important;
        max-width: none !important;
    }

    .product-table th,
    .product-table td,
    .specs-table th,
    .specs-table td {
        white-space: nowrap;
    }

    .product-specs-table th,
    .product-specs-table td {
        white-space: nowrap;
    }

    input,
    select,
    textarea,
    button,
    .btn {
        min-height: 44px;
        touch-action: manipulation;
    }

    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 639px) {

    .domains-grid,
    .products-preview,
    .why-cards,
    .services-grid,
    .control-areas,
    .advantages-grid,
    .advantages-grid-auto,
    .requirements-grid,
    .models-grid,
    .systems-grid,
    .hato-products,
    .related-products-grid,
    .footer-content {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .product-description,
    .installation-requirements,
    .advantage-item,
    .requirement-item,
    .model-card {
        padding: clamp(18px, 5vw, 24px) !important;
    }

    .product-table-wrapper {
        margin-inline: 0 !important;
    }
}

@media (min-width: 640px) and (max-width: 1023px) {

    .domains-grid,
    .products-preview,
    .why-cards,
    .services-grid,
    .control-areas,
    .advantages-grid,
    .advantages-grid-auto,
    .requirements-grid,
    .models-grid,
    .systems-grid,
    .hato-products,
    .related-products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Desktop override for the cooling-pad image. This stylesheet loads after
   styles.css and neutralizes legacy !important image sizing rules. */
@media (min-width: 1025px) {
    #panouri-evaporative .product-image-container {
        width: 100% !important;
        max-width: 900px !important;
        margin: 0 auto !important;
        overflow: hidden !important;
    }

    #panouri-evaporative .product-image-container img.product-image {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
        display: block !important;
    }
}

/* CRITICAL: Navigation toggle hidden on desktop - ABSOLUTE HIDING */
@media (min-width: 1024px) {

    .nav-toggle,
    button.nav-toggle,
    .nav-toggle.lg\:hidden,
    .header .nav-toggle,
    .header-content .nav-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Hide SVG icons inside nav-toggle on desktop */
    .nav-toggle svg,
    .nav-toggle .menu-icon,
    .nav-toggle .close-icon {
        display: none !important;
        visibility: hidden !important;
    }
}

/* Final mobile-toggle guard: use the favicon, never a three-bar hamburger. */
@media (max-width: 1023px) {
    .nav-toggle {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        transform: none !important;
        flex-direction: row !important;
        gap: 0 !important;
    }

    .nav-toggle>.menu-icon {
        display: block !important;
        width: 26px !important;
        height: 26px !important;
        margin: 0 !important;
        object-fit: contain !important;
    }

    .nav-toggle>.close-icon {
        width: 28px !important;
        height: 28px !important;
        margin: 0 !important;
        color: var(--text, #1f2937);
        font-size: 30px !important;
        font-weight: 300;
        line-height: 24px !important;
        text-align: center;
    }

    .nav-toggle>.close-icon,
    .nav-toggle.is-open>.menu-icon {
        display: none !important;
    }

    .nav-toggle.is-open>.close-icon {
        display: block !important;
    }

    .nav-toggle::before,
    .nav-toggle::after {
        content: none !important;
        display: none !important;
    }
}

/* Keep single-word labels intact inside cards; legacy overflow-wrap was splitting words character by character. */
.pillar-text,
.domain-card .domain-title,
.service-box h3,
.why-card h3,
.advantage-card h3,
.control-item h3 {
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
}

.pillar-text {
    white-space: nowrap;
}