/* ============================================
   MOBILE RESPONSIVE SUPPORT - AVIZOO TECH
   Inspired by Tailwind-like breakpoint system
   ============================================ */

/* BREAKPOINTS SYSTEM
   - Mobile-first approach
   - sm: 640px (small devices)
   - md: 768px (tablets)
   - lg: 1024px (laptops)
   - xl: 1280px (desktops)
   - 2xl: 1536px (large screens)
*/

/* ============================================
   BASE MOBILE STYLES (< 640px)
   ============================================ */

/* CRITICAL: Prevent horizontal scroll on all devices */
html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    position: relative;
}

* {
    box-sizing: border-box;
}

/* CRITICAL: All images must be responsive */
img,
picture,
video,
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Product images specific */
.product-image-container img,
.product-image-col img {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

/* CRITICAL: All tables must be scrollable horizontally, not the body */
.table-wrapper,
.product-table-wrapper,
.specs-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: var(--space-lg) 0;
    display: block;
}

.table-wrapper table,
.product-table-wrapper table,
.specs-table-wrapper table {
    min-width: 100%;
    width: max-content;
}

/* Safety: prevent table overflow on mobile */
@media (max-width: 768px) {
    /* Product image grid becomes vertical stack */
    .product-image-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .product-image-col {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* If table is not wrapped, add scroll */
    table:not(.product-table-wrapper table):not(.specs-table-wrapper table):not(.table-wrapper table) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Tables inside wrappers can be wider */
    .product-table-wrapper table,
    .specs-table-wrapper table,
    .table-wrapper table {
        min-width: 600px; /* Minimum width for tables to maintain readability */
        width: auto;
        display: table;
    }
}

/* Prevent any element from causing horizontal scroll */
* {
    max-width: 100%;
}

/* Allow containers and specific elements to use full width */
.container,
body,
html,
main,
section,
header,
footer,
nav {
    max-width: none;
}

/* Tables and their wrappers for controlled scrolling */
.table-wrapper,
.product-table-wrapper,
.specs-table-wrapper {
    max-width: 100%;
}

.table-wrapper *,
.product-table-wrapper *,
.specs-table-wrapper * {
    max-width: none;
}

/* Mobile Typography */
@media (max-width: 639px) {
    h1 {
        font-size: 32px !important;
        line-height: 1.1 !important;
    }
    
    h2 {
        font-size: 28px !important;
        line-height: 1.2 !important;
    }
    
    h3 {
        font-size: 24px !important;
        line-height: 1.25 !important;
    }
    
    h4 {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }
    
    h5 {
        font-size: 18px !important;
    }
    
    h6 {
        font-size: 16px !important;
    }
    
    body {
        font-size: 15px;
    }
}

/* ============================================
   HEADER & NAVIGATION - MOBILE
   ============================================ */

@media (max-width: 900px) {
    .header {
        padding: var(--space-sm) 0;
    }
    
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Logo - Mobile */
    .logo {
        padding: var(--space-xs);
    }
    
    .logo-image {
        height: 40px;
        width: auto;
    }
    
    /* Mobile Nav Toggle Button */
    .nav-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 28px;
        height: 22px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 10001;
        position: relative;
    }
    
    .nav-toggle span {
        width: 100%;
        height: 3px;
        background: var(--text);
        border-radius: 3px;
        transition: all 300ms var(--ease-smooth);
        transform-origin: center;
    }
    
    .nav-toggle.is-open span:nth-child(1) {
        transform: translateY(9.5px) rotate(45deg);
    }
    
    .nav-toggle.is-open span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    
    .nav-toggle.is-open span:nth-child(3) {
        transform: translateY(-9.5px) rotate(-45deg);
    }
    
    /* Mobile Navigation Menu */
    .nav {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        max-width: 340px;
        height: 100vh;
        background: var(--bg-elevated);
        backdrop-filter: blur(24px);
        border-left: 1px solid var(--border);
        padding: 80px var(--space-lg) var(--space-lg);
        transform: translateX(100%);
        opacity: 0;
        transition: transform 400ms var(--ease-expo), opacity 400ms var(--ease-smooth);
        z-index: 10000;
        overflow-y: auto;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
    }
    
    .nav.is-open {
        transform: translateX(0);
        opacity: 1;
    }
    
    /* Nav Links - Mobile */
    .nav-link {
        width: 100%;
        text-align: left;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
        color: var(--text);
        font-size: var(--text-base);
        transition: all 300ms var(--ease-smooth);
        display: block;
        text-decoration: none;
    }
    
    .nav-link:hover,
    .nav-link.active {
        background: var(--primary);
        color: var(--white);
        transform: translateX(4px);
    }
    
    /* Theme & Lang Toggle - Mobile */
    .theme-toggle,
    .lang-toggle {
        width: 100%;
        margin-top: var(--space-sm);
        padding: var(--space-sm);
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        justify-content: center;
    }
    
    /* Mega Menu - Mobile */
    .mega-menu-wrapper {
        width: 100%;
    }
    
    .mega-menu {
        position: static;
        width: 100%;
        background: var(--bg-alt);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-top: var(--space-sm);
        padding: var(--space-md);
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 500ms var(--ease-expo), opacity 400ms var(--ease-smooth), margin-top 400ms var(--ease-smooth);
    }
    
    .mega-menu-wrapper.is-open .mega-menu {
        max-height: 600px;
        opacity: 1;
        margin-top: var(--space-md);
    }
    
    .mega-menu-content {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .mega-menu-level {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
        width: 100%;
    }
    
    .mega-menu-level-2,
    .mega-menu-level-3 {
        display: none;
        margin-left: var(--space-md);
        padding-left: var(--space-md);
        border-left: 2px solid var(--primary);
    }
    
    .mega-menu-level-2.active,
    .mega-menu-level-3.active {
        display: flex;
        animation: slideDown 400ms var(--ease-expo);
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .mega-menu-item {
        padding: var(--space-sm);
        font-size: var(--text-sm);
    }
    
    .mega-menu-arrow {
        font-size: 14px;
    }
}

/* ============================================
   HERO SECTION - MOBILE
   ============================================ */

@media (max-width: 639px) {
    .hero {
        padding: 100px var(--space-md) var(--space-2xl);
        min-height: auto;
    }
    
    .hero-content {
        text-align: center;
        padding: 0;
    }
    
    .hero-title {
        font-size: 36px !important;
        margin-bottom: var(--space-md);
    }
    
    .hero-subtitle {
        font-size: 16px !important;
        margin-bottom: var(--space-lg);
    }
    
    .hero-pillars {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
        margin-top: var(--space-lg);
    }
    
    .pillar-item {
        flex-direction: column;
        gap: var(--space-sm);
        padding: var(--space-md);
    }
    
    .pillar-icon {
        width: 48px;
        height: 48px;
    }
    
    .pillar-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .pillar-text {
        font-size: 14px;
    }
}

@media (min-width: 640px) and (max-width: 767px) {
    .hero {
        padding: 120px var(--space-lg) var(--space-3xl);
    }
    
    .hero-title {
        font-size: 48px !important;
    }
    
    .hero-pillars {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hero {
        padding: 140px var(--space-xl) var(--space-4xl);
    }
    
    .hero-pillars {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   SECTIONS - MOBILE PADDING
   ============================================ */

@media (max-width: 639px) {
    .section-padding {
        padding: var(--space-3xl) var(--space-md);
    }
    
    .section-padding-small {
        padding: var(--space-2xl) var(--space-md);
    }
    
    .container {
        padding: 0 var(--space-md);
    }
    
    .section-title {
        font-size: 32px !important;
        margin-bottom: var(--space-lg);
        text-align: center;
    }
    
    .section-subtitle {
        font-size: 16px !important;
        margin-bottom: var(--space-xl);
        text-align: center;
    }
}

@media (min-width: 640px) and (max-width: 767px) {
    .section-padding {
        padding: var(--space-4xl) var(--space-lg);
    }
    
    .container {
        padding: 0 var(--space-lg);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .section-padding {
        padding: var(--space-5xl) var(--space-xl);
    }
}

/* ============================================
   GRIDS - RESPONSIVE
   3 columns (>1024px), 2 columns (601-1024px), 1 column (<600px)
   ============================================ */

/* Mobile (<600px) - Single Column */
@media (max-width: 600px) {
    .domains-grid,
    .products-preview,
    .why-cards,
    .services-grid,
    .partners-content,
    .partners-grid,
    .control-areas,
    .advantages-grid,
    .advantages-grid-auto,
    .systems-grid,
    .hato-products,
    .hato-benefits-grid,
    .integration-features,
    .product-features,
    .product-features-grid,
    .silo-features-grid,
    .applications-list {
        grid-template-columns: 1fr !important;
        gap: var(--space-md) !important;
    }
    
    /* CRITICAL: Toate cardurile ocupă întreaga lățime pe telefon */
    .why-card,
    .service-box,
    .domain-card,
    .product-preview-card,
    .advantage-card,
    .control-item,
    .hato-product-card,
    .partner-box {
        grid-column: 1 / -1 !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    
    /* Hero pillars use 2 columns even on mobile */
    .hero-pillars {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-sm) !important;
    }
}

/* Tablet (601px-1024px) - Two 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,
    .integration-features,
    .product-features-grid,
    .silo-features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-lg) !important;
    }
    
    /* Cardurile ocupă 1 coloană pe tabletă */
    .why-card,
    .service-box,
    .domain-card,
    .advantage-card {
        grid-column: span 1 !important;
    }
    
    .hero-pillars {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .control-areas {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Desktop (>1024px) - Keep original grid definitions */

/* ============================================
   CARDS - MOBILE
   ============================================ */

@media (max-width: 639px) {
    .domain-card,
    .product-preview-card,
    .why-card,
    .service-box,
    .partner-box,
    .advantage-card {
        padding: var(--space-lg);
    }
    
    .domain-icon,
    .contact-item-icon,
    .feature-icon,
    .pillar-icon,
    .why-icon,
    .service-icon {
        width: 56px;
        height: 56px;
    }
    
    .domain-title,
    .product-preview-title {
        font-size: 20px !important;
        margin-top: var(--space-md);
    }
    
    .domain-list,
    .product-preview-desc {
        font-size: 14px;
        line-height: 1.6;
    }
}

/* ============================================
   BUTTONS - MOBILE
   ============================================ */

@media (max-width: 639px) {
    .btn {
        width: 100%;
        padding: var(--space-md) var(--space-lg);
        font-size: var(--text-base);
        text-align: center;
        display: block;
    }
    
    .hero-cta {
        flex-direction: column;
        gap: var(--space-md);
        width: 100%;
    }
    
    .hero-cta .btn {
        width: 100%;
    }
}

/* ============================================
   IMAGES & MEDIA - MOBILE
   ============================================ */

@media (max-width: 639px) {
    .hero-image-wrapper,
    .product-image-container,
    .hero-main-image {
        border-radius: var(--radius-lg);
    }
    
    img {
        width: 100%;
        height: auto;
        display: block;
    }
}

/* ============================================
   FOOTER - MOBILE
   ============================================ */

@media (max-width: 767px) {
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: var(--space-xl);
        text-align: center;
    }
    
    .footer-column {
        align-items: center;
    }
    
    .footer-links {
        align-items: center;
    }
    
    .footer-logo-image {
        height: 40px;
    }
}

/* ============================================
   CONTACT PAGE - MOBILE
   ============================================ */

@media (max-width: 767px) {
    .contact-main {
        grid-template-columns: 1fr !important;
        gap: var(--space-2xl);
    }
    
    .contact-info {
        padding: var(--space-xl) var(--space-lg);
    }
    
    .contact-form-container {
        padding: var(--space-xl) var(--space-lg);
    }
    
    .contact-item {
        flex-direction: row;
        align-items: flex-start;
        gap: var(--space-md);
    }
    
    .contact-item-icon {
        flex-shrink: 0;
    }
}

/* ============================================
   FORMS - MOBILE
   ============================================ */

@media (max-width: 639px) {
    .form-row {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .form-group {
        width: 100%;
    }
    
    input,
    textarea,
    select {
        width: 100%;
        padding: var(--space-md);
        font-size: var(--text-base);
    }
    
    textarea {
        min-height: 150px;
    }
}

/* ============================================
   PRODUCT PAGES - MOBILE
   ============================================ */

@media (max-width: 767px) {
    .product-hero {
        grid-template-columns: 1fr !important;
        gap: var(--space-xl);
    }
    
    .product-content {
        order: 2;
    }
    
    .product-image-container {
        order: 1;
    }
    
    .product-features-grid,
    .advantages-grid,
    .systems-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }
    
    .product-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .product-table {
        min-width: 500px;
    }
}

/* ============================================
   AUTOMATION PAGE - MOBILE
   ============================================ */

@media (max-width: 767px) {
    .hotraco-hero,
    .hato-hero {
        grid-template-columns: 1fr !important;
        gap: var(--space-xl);
    }
    
    .hotraco-advantages,
    .hato-benefits {
        padding: var(--space-xl) var(--space-md);
    }
    
    .advantages-grid-auto,
    .hato-benefits-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }
    
    .control-areas {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }
    
    .partner-logos-section {
        padding: var(--space-xl) var(--space-md);
    }
}

/* ============================================
   ABOUT PAGE - MOBILE
   ============================================ */

@media (max-width: 767px) {
    .about-intro {
        padding: var(--space-3xl) var(--space-md);
    }
    
    .about-content {
        grid-template-columns: 1fr !important;
        gap: var(--space-xl);
    }
    
    .why-us,
    .services-overview,
    .partners-full {
        padding: var(--space-3xl) 0;
    }
    
    .why-cards,
    .services-grid,
    .partners-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }
}

/* ============================================
   UTILITIES - MOBILE
   ============================================ */

/* Hide on mobile */
@media (max-width: 767px) {
    .hidden-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Text alignment */
@media (max-width: 767px) {
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-text-left {
        text-align: left !important;
    }
}

/* Spacing utilities */
@media (max-width: 639px) {
    .mobile-mt-sm { margin-top: var(--space-sm) !important; }
    .mobile-mt-md { margin-top: var(--space-md) !important; }
    .mobile-mt-lg { margin-top: var(--space-lg) !important; }
    .mobile-mb-sm { margin-bottom: var(--space-sm) !important; }
    .mobile-mb-md { margin-bottom: var(--space-md) !important; }
    .mobile-mb-lg { margin-bottom: var(--space-lg) !important; }
    .mobile-px-sm { padding-left: var(--space-sm) !important; padding-right: var(--space-sm) !important; }
    .mobile-px-md { padding-left: var(--space-md) !important; padding-right: var(--space-md) !important; }
    .mobile-py-sm { padding-top: var(--space-sm) !important; padding-bottom: var(--space-sm) !important; }
    .mobile-py-md { padding-top: var(--space-md) !important; padding-bottom: var(--space-md) !important; }
}

/* ============================================
   TOUCH OPTIMIZATIONS
   ============================================ */

@media (max-width: 1023px) {
    /* Larger touch targets */
    button,
    a,
    .nav-link,
    .btn,
    .nav-toggle {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .domain-card:hover,
    .product-preview-card:hover,
    .why-card:hover {
        transform: none;
    }
    
    /* Smoother scrolling on touch */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   LANDSCAPE MOBILE - SPECIAL CASES
   ============================================ */

@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        padding: 80px var(--space-md) var(--space-xl);
        min-height: auto;
    }
    
    .hero-pillars {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-sm);
    }
    
    .pillar-item {
        padding: var(--space-sm);
    }
}

/* ============================================
   SAFE AREA INSETS (for notched devices)
   ============================================ */

@supports (padding: max(0px)) {
    .header,
    .nav,
    .footer {
        padding-left: max(var(--space-md), env(safe-area-inset-left));
        padding-right: max(var(--space-md), env(safe-area-inset-right));
    }
    
    .nav {
        padding-top: max(80px, env(safe-area-inset-top) + 60px);
        padding-bottom: max(var(--space-lg), env(safe-area-inset-bottom));
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

@media (max-width: 767px) {
    /* Reduce animation complexity on mobile */
    * {
        animation-duration: 300ms !important;
        transition-duration: 300ms !important;
    }
    
    /* Disable parallax and complex effects on low-end devices */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}


/* ============================================
