/* ==========================================================================
   AG Measurematics - Responsive Stylesheet
   ========================================================================== */

/* ==========================================================================
   Tablet Landscape (max-width: 1024px)
   ========================================================================== */
@media screen and (max-width: 1024px) {
    .container {
        max-width: 960px;
    }

    .hero-content {
        gap: var(--spacing-md);
    }

    .hero-text h1 {
        font-size: 2.5rem;
    }

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

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* ==========================================================================
   Tablet Portrait (max-width: 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .section-title {
        font-size: 2rem;
    }

    /* Top Bar */
    .top-bar-content {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }

    .top-bar-left {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    /* Header */
    .mobile-menu-toggle {
        display: flex;
    }

    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 400px;
        height: 100vh;
        background: var(--bg-white);
        flex-direction: column;
        align-items: flex-start;
        padding: var(--spacing-xl) var(--spacing-md);
        box-shadow: var(--shadow-lg);
        transition: var(--transition-normal);
        overflow-y: auto;
        z-index: 9999;
    }

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

    .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .nav-item {
        width: 100%;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link {
        width: 100%;
        justify-content: space-between;
        padding: 15px 10px;
    }

    .nav-actions {
        width: 100%;
        flex-direction: column;
        margin-top: var(--spacing-md);
        gap: var(--spacing-sm);
    }

    .nav-actions .btn {
        width: 100%;
    }

    /* Dropdown Menu */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: var(--bg-light);
        display: none;
        border-radius: 0;
    }

    .nav-item.dropdown-active .dropdown-menu {
        display: block;
    }

    /* Mega Menu */
    .mega-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        display: none;
    }

    .nav-item.dropdown-active .mega-menu {
        display: block;
    }

    .mega-menu-content {
        grid-template-columns: 1fr;
        padding: var(--spacing-sm);
    }

    /* 3-Level Mega Menu Mobile */
    .mega-menu-3level {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        display: none;
        border-top: none;
        max-height: none;
    }

    .nav-item.dropdown-active .mega-menu-3level {
        display: block;
    }

    .mega-menu-3level::before {
        display: none;
    }

    .mega-menu-3level-content {
        grid-template-columns: 1fr;
        gap: 0;
        min-height: auto;
        padding: 0;
    }

    .products-menu .mega-menu-3level-content {
        grid-template-columns: 1fr;
    }

    /* L2: Categories Mobile */
    .mega-menu-categories {
        background: var(--bg-light);
        border-right: none;
        padding: 0;
    }

    .category-item {
        padding: 15px 20px;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
    }

    .category-item:hover {
        padding-left: 20px;
    }

    .category-item.active {
        background: var(--bg-white);
        border-left: 3px solid var(--secondary-color);
        padding-left: 23px;
    }

    /* L3: Subcategories Mobile */
    .mega-menu-subcategories,
    .products-subcategories {
        padding: var(--spacing-sm);
        grid-column: auto;
    }

    .subcategory-list {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .subcategory-title {
        font-size: 1.125rem;
        margin-bottom: var(--spacing-sm);
    }

    .subcategory-list a {
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    /* Featured Products Mobile */
    .mega-menu-featured {
        background: var(--bg-light);
        border-left: none;
        border-top: 2px solid var(--border-color);
        padding: var(--spacing-md);
    }

    .featured-title {
        font-size: 1rem;
    }

    .featured-list a {
        font-size: 0.85rem;
        padding: 10px 12px;
    }

    .cta-item {
        font-size: 0.8rem;
        padding: 10px;
    }

    .cta-item strong {
        font-size: 0.85rem;
    }

    .phone-link {
        font-size: 0.9rem;
    }

    /* Hero */
    .hero {
        min-height: auto;
        padding: var(--spacing-xl) 0;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .hero-text h1 {
        font-size: 2rem;
    }

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

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

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

    .hero-image {
        order: -1;
    }

    /* Cards */
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: var(--spacing-md);
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .footer-bottom-content {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }

    .footer-bottom-links {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    /* Industry Cards */
    .industry-card {
        height: 250px;
    }

    /* Contact Page - Stack form and sidebar on tablets */
    .contact-layout {
        flex-direction: column !important;
        gap: 2rem !important;
    }

    .contact-layout > div,
    .contact-layout > aside {
        flex: 1 1 100% !important;
    }

    .contact-form-fields {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   Mobile (max-width: 480px)
   ========================================================================== */
@media screen and (max-width: 480px) {
    /* Container */
    .container {
        padding: 0 var(--spacing-sm);
    }

    /* Typography */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .section {
        padding: var(--spacing-lg) 0;
    }

    .section-title {
        font-size: 1.75rem;
    }

    /* Buttons */
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    /* Hero */
    .hero-text h1 {
        font-size: 1.75rem;
    }

    .hero-text p {
        font-size: 0.95rem;
    }

    /* Cards */
    .card-grid {
        grid-template-columns: 1fr;
    }

    .card-content {
        padding: var(--spacing-sm);
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .stat-number {
        font-size: 2.5rem;
    }

    .stat-label {
        font-size: 1rem;
    }

    /* Search */
    .search-form {
        flex-direction: column;
    }

    .search-submit {
        width: 100%;
    }

    /* Industry Cards */
    .industry-card {
        height: 200px;
    }

    /* Scroll to Top & WhatsApp */
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
    }

    .whatsapp-float {
        width: 50px;
        height: 50px;
        bottom: 75px;
        right: 20px;
        font-size: 1.75rem;
    }

    /* Footer */
    .footer-main {
        padding: var(--spacing-lg) 0;
    }

    .footer-column {
        padding: 0;
    }
}

/* ==========================================================================
   Mobile Menu Animation
   ========================================================================== */
@media screen and (max-width: 768px) {
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

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

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Mobile Menu Overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition-normal);
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .top-bar,
    .header,
    .footer,
    .scroll-to-top,
    .whatsapp-float,
    .nav-actions,
    .hero-controls {
        display: none !important;
    }

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

    a {
        text-decoration: underline;
    }

    .container {
        max-width: 100%;
    }
}
