/* ==========================================================================
   NHÂN LAB - MASTER RESPONSIVE SYSTEM (2026 EDITION)
   Tối ưu hóa toàn diện đa thiết bị: Desktop, Laptop, iPad/Tablet, Mobile, Small Mobile
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. ROOT & UNIVERSAL RESPONSIVE PROTECTION
   Ngăn chặn hoàn toàn tràn ngang (Horizontal Overflow) và tối ưu cảm ứng
   -------------------------------------------------------------------------- */
html, body {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

*, *::before, *::after {
    box-sizing: border-box;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

table {
    border-spacing: 0;
}

/* Touch-action and tap feedback for touchscreen devices */
@media (hover: none) {
    *:hover {
        transform: none !important;
    }
    
    a:active, 
    button:active, 
    .btn:active, 
    .header-btn:active, 
    .menu-warranty-btn:active,
    .news-card:active,
    .service-card:active,
    .job-card:active {
        transform: scale(0.98) !important;
        opacity: 0.92;
        transition: transform 0.1s ease, opacity 0.1s ease;
    }
}

/* --------------------------------------------------------------------------
   1. LAPTOP & MÀN HÌNH VỪA (992PX - 1199PX)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1199px) and (min-width: 992px) {
    .container {
        width: calc(100% - 64px) !important;
    }

    .menu {
        gap: 20px !important;
    }

    .menu a {
        font-size: 14.5px !important;
    }

    .service-grid, .workflow-grid {
        gap: 24px !important;
    }

    .news-layout {
        grid-template-columns: 1fr 280px !important;
        gap: 28px !important;
    }
}

/* --------------------------------------------------------------------------
   2. DESKTOP VIEWPORT (TRÊN 992PX) - ĐẢM BẢO MENU CHUẨN
   -------------------------------------------------------------------------- */
@media screen and (min-width: 992px) {
    .menu-toggle {
        display: none !important;
    }

    .mobile-only {
        display: none !important;
    }

    .menu {
        display: flex !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        background: transparent !important;
        transform: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        overflow: visible !important;
        flex-direction: row !important;
        align-items: center !important;
    }

    .menu .menu-warranty-btn {
        display: none !important;
    }

    .dropdown-menu {
        display: none;
    }

    .dropdown:hover .dropdown-menu {
        display: block !important;
        opacity: 1 !important;
        max-height: 500px !important;
        visibility: visible !important;
    }
}

/* --------------------------------------------------------------------------
   3. TABLET & IPAD (DƯỚI 1024PX)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1024px) {
    .container {
        width: calc(100% - 48px) !important;
    }

    section, .page-main section {
        padding: 60px 0 !important;
    }

    /* Đưa các lưới chính về 2 cột */
    .service-grid, 
    .workflow-grid, 
    .blog-grid,
    .about-values-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 24px !important;
    }

    /* Thẻ đối tác nguyên liệu */
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-auto-rows: 130px !important;
        gap: 16px !important;
    }

    /* Chi tiết sản phẩm & giới thiệu */
    .about-grid, 
    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 40px !important;
    }

    /* Tuyển dụng tablet */
    .recruitment-hero-inner {
        grid-template-columns: 1fr !important;
        gap: 36px !important;
    }

    .culture-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }

    .detail-hero {
        padding: 70px 0 !important;
    }

    .detail-content h1 {
        font-size: 42px !important;
    }

    /* Bảo hành */
    .warranty-layout {
        grid-template-columns: 1fr !important;
    }

    .warranty-sidebar {
        order: 2;
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .warranty-hotline {
        grid-column: 1 / -1 !important;
    }

    /* Tin tức */
    .news-layout {
        grid-template-columns: 1fr !important;
    }

    .news-sidebar {
        position: static !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 24px !important;
    }

    /* Footer: 2 cột trên iPad */
    .footer-inner {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 36px 24px !important;
    }
}

/* --------------------------------------------------------------------------
   4. CHUYỂN ĐỔI HEADER SANG MOBILE DRAWER (DƯỚI 991PX)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 991px) {
    .header-inner {
        height: 70px !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        position: relative !important;
    }

    /* Nút 3 gạch mở Menu */
    .menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        width: 28px;
        height: 20px;
        background: transparent;
        border: none;
        cursor: pointer;
        order: 1 !important;
        position: relative !important;
        z-index: 100005 !important;
        padding: 0;
    }

    .menu-toggle span {
        width: 100%;
        height: 3px;
        background-color: var(--text-dark);
        border-radius: 2px;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: block;
    }

    /* Logo căn giữa tuyệt đối */
    .logo {
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 100005 !important;
        margin: 0 !important;
    }

    .logo img {
        max-height: 40px !important;
        width: auto !important;
        display: block !important;
    }

    /* Ẩn nút bảo hành gốc trên thanh top */
    .header-inner .header-btn {
        display: none !important;
    }

    /* Khung Menu trượt Side Drawer */
    .menu {
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 78% !important;
        max-width: 320px !important;
        height: 100vh !important;
        background: var(--white) !important;
        padding: 85px 24px 30px !important;
        gap: 0 !important;
        align-items: flex-start !important;
        transform: translateX(-120%) !important;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease !important;
        z-index: 100000 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .menu.open {
        transform: translateX(0) !important;
        box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.65) !important;
    }

    /* Menu links */
    .menu a, .menu .dropdown {
        width: 100% !important;
        display: block !important;
        height: auto !important;
        padding: 14px 0 !important;
        margin: 0 !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        color: var(--text-dark) !important;
        border-bottom: 1px solid var(--border) !important;
    }

    .menu .dropdown {
        border-bottom: none !important;
        padding: 0 !important;
    }

    .menu .dropdown-toggle {
        border-bottom: 1px solid var(--border) !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .menu .dropdown-menu {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        box-shadow: none !important;
        background: var(--bg-light) !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 8px !important;
        border: none !important;
        display: block !important;
        overflow: hidden !important;
        max-height: 0 !important; 
        opacity: 0 !important;
        transition: max-height 0.35s ease-in-out, opacity 0.25s ease !important;
    }

    .menu .dropdown-menu.active-mobile {
        max-height: 400px !important; 
        opacity: 1 !important;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
        padding: 4px 0 !important;
    }

    .menu .dropdown-menu a {
        padding: 12px 20px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        color: var(--text-gray) !important;
        border-bottom: 1px solid rgba(229, 231, 235, 0.5) !important;
    }

    .menu .dropdown-menu a:last-child {
        border-bottom: none !important;
    }

    /* Nút Tra cứu bảo hành trong Menu mobile */
    .menu .menu-warranty-btn {
        display: block !important;
        width: 100% !important;
        margin-top: 24px !important;
        padding: 15px 24px !important;
        text-align: center !important;
        background: linear-gradient(135deg, var(--green-primary), var(--green-dark)) !important;
        color: var(--white) !important;
        border-radius: 999px !important;
        border-bottom: none !important;
        font-weight: 700 !important;
        font-size: 15px !important;
        box-shadow: 0 8px 24px rgba(128, 195, 66, 0.35) !important;
    }

    /* Hiệu ứng biến dấu X của nút toggle */
    .menu-toggle.active span:nth-child(1) {
        transform: translateY(8.5px) rotate(45deg) !important; 
        background-color: var(--green-primary) !important; 
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0 !important;
        transform: translateX(-16px) !important; 
    }

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

/* --------------------------------------------------------------------------
   5. ĐIỆN THOẠI DI ĐỘNG (MOBILE) - DƯỚI 768PX
   -------------------------------------------------------------------------- */
@media screen and (max-width: 768px) {
    .container {
        width: calc(100% - 32px) !important;
    }

    section, .page-main section {
        padding: 45px 0 !important;
    }

    .section-heading {
        margin-bottom: 28px !important;
        text-align: center !important;
    }

    .section-heading h2 {
        font-size: 25px !important;
        line-height: 1.3 !important;
    }

    .section-heading p {
        font-size: 14.5px !important;
    }

    .header-inner {
        height: 64px !important;
    }

    .logo img {
        max-height: 36px !important;
    }

    /* Hero Slider Trang Chủ */
    .hero-slider {
        height: 220px !important;
    }

    .hero-slide img {
        height: 220px !important;
        object-fit: cover !important;
    }

    /* Toàn bộ Lưới Dịch vụ, Quy trình, Tin tức thành 1 cột */
    .service-grid, 
    .workflow-grid, 
    .blog-grid, 
    .contact-cards, 
    .result-grid, 
    .detail-grid,
    .job-grid,
    .recruitment-features-grid,
    .perks-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .service-card, 
    .workflow-card, 
    .job-card {
        padding: 22px 20px !important;
    }

    /* Đối tác nguyên liệu - 2 cột trên Mobile */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 105px !important;
        gap: 12px !important;
    }

    .gallery-card {
        padding: 14px !important;
        border-radius: 14px !important;
    }

    /* Trang chi tiết sản phẩm */
    .detail-hero {
        padding: 45px 0 !important;
    }

    .detail-content h1 {
        font-size: 30px !important;
        text-align: center !important;
        line-height: 1.25 !important;
    }

    .detail-content p {
        font-size: 15px !important;
        text-align: center !important;
    }

    .detail-image {
        order: -1;
    }

    /* ==================================================
       TIN TỨC (NEWS PAGE) TRÊN MOBILE
       ================================================== */
    .news-hero {
        padding: 40px 0 35px !important;
    }

    .news-hero-title {
        font-size: 28px !important;
    }

    .news-hero-desc {
        font-size: 14.5px !important;
    }

    .news-hero-stats {
        flex-direction: row !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 16px !important;
    }

    .news-featured {
        margin-top: -30px !important;
    }

    .news-featured-card {
        grid-template-columns: 1fr !important;
        border-radius: 20px !important;
    }

    .news-featured-media {
        min-height: 210px !important;
        max-height: 240px !important;
    }

    .news-featured-body {
        padding: 22px 18px !important;
    }

    .news-featured-title {
        font-size: 19px !important;
        line-height: 1.35 !important;
    }

    /* Thanh công cụ: Search & Chip Filters */
    .news-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
    }

    .news-search-box {
        width: 100% !important;
    }

    /* Thanh Filter Chips trượt ngang mượt mà như Native App */
    .news-filters {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding-bottom: 6px !important;
        scrollbar-width: none !important;
        width: 100% !important;
    }

    .news-filters::-webkit-scrollbar {
        display: none !important;
    }

    .news-filter-btn {
        flex-shrink: 0 !important;
        padding: 8px 16px !important;
        font-size: 13.5px !important;
        white-space: nowrap !important;
    }

    .news-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .news-card-media {
        height: 190px !important;
    }

    .news-card-body {
        padding: 20px 18px !important;
    }

    .news-sidebar {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .news-pagination {
        gap: 6px !important;
        padding-top: 24px !important;
    }

    .news-page-btn {
        min-width: 40px !important;
        height: 40px !important;
        font-size: 13.5px !important;
        padding: 0 10px !important;
    }

    .news-cta-panel {
        flex-direction: column !important;
        padding: 28px 20px !important;
        text-align: center !important;
        border-radius: 20px !important;
    }

    .news-cta-form {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .news-cta-form input {
        width: 100% !important;
    }

    .news-cta-form button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Modal Đọc Bài Viết Chi Tiết Trên Mobile */
    .news-modal-backdrop {
        padding: 0 !important;
    }

    .news-modal-container {
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .news-modal-hero {
        height: 210px !important;
    }

    .news-modal-close {
        top: 14px !important;
        right: 14px !important;
        width: 36px !important;
        height: 36px !important;
    }

    .news-modal-header {
        padding: 20px 18px 14px !important;
    }

    .news-modal-title {
        font-size: 21px !important;
        line-height: 1.35 !important;
    }

    .news-modal-body {
        padding: 0 18px !important;
        font-size: 15px !important;
    }

    .news-modal-cta {
        margin: 24px 18px 0 !important;
        padding: 18px 16px !important;
    }

    /* ==================================================
       BẢO HÀNH (WARRANTY PAGE) TRÊN MOBILE
       ================================================== */
    .warranty-hero {
        padding: 40px 0 50px !important;
    }

    .warranty-hero h1 {
        font-size: 28px !important;
    }

    .warranty-body {
        margin-top: -24px !important;
        padding-bottom: 48px !important;
    }

    .warranty-search-card {
        padding: 22px 18px !important;
        border-radius: 20px !important;
    }

    .warranty-search-header {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 12px !important;
    }

    .warranty-form {
        flex-direction: column !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        gap: 10px !important;
    }

    .warranty-input-wrap {
        width: 100% !important;
        padding: 0 14px !important;
        border: 2px solid var(--border) !important;
        border-radius: 14px !important;
        background: var(--white) !important;
    }

    .warranty-form input {
        padding: 14px 10px !important;
        font-size: 15.5px !important;
    }

    .warranty-form button {
        width: 100% !important;
        min-height: 48px !important;
        border-radius: 14px !important;
    }

    .warranty-sidebar {
        grid-template-columns: 1fr !important;
    }

    /* ==================================================
       TUYỂN DỤNG (RECRUITMENT PAGE) TRÊN MOBILE
       ================================================== */
    .recruitment-hero {
        padding: 40px 0 32px !important;
    }

    .recruitment-hero::before {
        width: 260px !important;
        height: 260px !important;
        right: -10% !important;
        top: -10% !important;
    }

    .recruitment-hero-inner {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
        width: 100% !important;
    }

    .recruitment-hero-content {
        text-align: left !important;
        width: 100% !important;
    }

    .recruitment-hero-badge {
        font-size: 11.5px !important;
        padding: 6px 14px !important;
        margin-bottom: 16px !important;
    }

    .recruitment-hero-content h1 {
        font-size: 26px !important;
        line-height: 1.25 !important;
        margin-bottom: 14px !important;
        word-break: normal !important;
    }

    .recruitment-hero-desc {
        font-size: 14.5px !important;
        line-height: 1.55 !important;
        margin-bottom: 24px !important;
    }

    .recruitment-hero-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .recruitment-btn {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 13px 20px !important;
        font-size: 14px !important;
    }

    .recruitment-hero-card {
        padding: 20px 16px !important;
        border-radius: 16px !important;
        width: 100% !important;
    }

    .recruitment-hero-card h3 {
        font-size: 18px !important;
        margin-bottom: 12px !important;
    }

    .recruitment-quick-stats {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .culture-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        margin-top: 32px !important;
    }

    .culture-card {
        padding: 22px 18px !important;
    }

    .form-container-card {
        border-radius: 18px !important;
    }

    .form-container {
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    .form-header {
        padding: 24px 18px !important;
        border-radius: 20px 20px 0 0 !important;
    }

    .form-body {
        padding: 20px 16px !important;
        border-radius: 0 0 20px 20px !important;
        background: var(--white) !important;
    }

    .form-step-nav {
        grid-template-columns: 1fr !important;
    }

    .form-grid-4, 
    .form-grid-3, 
    .form-grid-2, 
    .form-grid-5,
    .cccd-upload-grid,
    .source-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    /* Bảng chấm điểm tay nghề kỹ thuật - Cuộn cảm ứng mượt mà */
    .skills-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 12px !important;
        margin-left: -6px !important;
        margin-right: -6px !important;
    }

    .skills-table {
        min-width: 580px !important;
        font-size: 12.5px !important;
    }

    .skills-table th, 
    .skills-table td {
        padding: 10px 8px !important;
    }

    .table-scroll-hint {
        display: flex !important;
        align-items: center;
        gap: 8px;
        background: #f0fdf4;
        color: var(--green-dark);
        border: 1px dashed var(--green-primary);
        border-radius: 10px;
        padding: 8px 12px;
        font-size: 12.5px;
        font-weight: 600;
        margin-bottom: 10px;
    }

    /* File dropzone */
    .file-dropzone {
        padding: 24px 16px !important;
    }

    /* Modal Tuyển dụng thành công UX 2026 */
    .nl-modal-container {
        width: 95% !important;
        max-height: 92vh !important;
        padding: 24px 18px 20px !important;
        border-radius: 20px !important;
    }

    .nl-modal-title {
        font-size: 22px !important;
    }

    .nl-modal-desc {
        font-size: 13.5px !important;
    }

    .nl-receipt-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Stepper lộ trình tuyển dụng */
    .nl-stepper {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .nl-step-line {
        display: none !important;
    }

    .nl-step-item {
        flex-direction: row !important;
        text-align: left !important;
        gap: 12px !important;
    }

    .nl-modal-actions {
        flex-direction: column-reverse !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .nl-modal-actions a, 
    .nl-modal-actions button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* ==================================================
       FOOTER TRÊN MOBILE (2 CỘT CÂN XỨNG CHUYÊN NGHIỆP)
       ================================================== */
    .footer-inner {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 32px 16px !important;
    }
    
    .footer-col:nth-child(1),
    .footer-col:nth-child(4) {
        grid-column: span 2 !important;
    }
    
    .footer-col { 
        text-align: left !important; 
    }

    .footer-col h4 { 
        font-size: 15px !important; 
        margin-bottom: 18px !important; 
    }

    .footer-col h4::after { 
        left: 0 !important; 
        transform: none !important; 
    }
    
    .footer-contact li { 
        flex-direction: row !important; 
        align-items: flex-start !important; 
    }

    .contact-text { 
        font-size: 13px !important; 
    }

    .footer-bottom {
        padding-top: 24px !important;
        font-size: 12.5px !important;
    }
}

/* --------------------------------------------------------------------------
   6. SMALL MOBILE (DƯỚI 480PX)
   Tối ưu hóa sâu cho điện thoại cỡ nhỏ (iPhone 12 Mini, iPhone SE, Android 390px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 480px) {
    .container {
        width: calc(100% - 24px) !important;
    }

    section, .page-main section {
        padding: 38px 0 !important;
    }

    .section-heading h2 {
        font-size: 22px !important;
    }

    .hero-slider {
        height: 190px !important;
    }

    .hero-slide img {
        height: 190px !important;
    }

    .service-card, 
    .workflow-card {
        padding: 18px 16px !important;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 95px !important;
        gap: 10px !important;
    }

    .gallery-card {
        padding: 10px !important;
    }

    .menu {
        width: 84% !important;
    }

    /* Modal tuyển dụng nhỏ hơn */
    .nl-modal-container {
        padding: 20px 14px 18px !important;
        border-radius: 18px !important;
    }

    .nl-modal-title {
        font-size: 20px !important;
    }

    .nl-receipt-card {
        padding: 12px 10px !important;
    }

    .nl-receipt-item {
        font-size: 13px !important;
    }

    .nl-hotline-bar {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    /* Tin tức */
    .news-featured-media {
        min-height: 180px !important;
    }

    .news-card-media {
        height: 170px !important;
    }

    .news-page-btn {
        min-width: 36px !important;
        height: 36px !important;
        font-size: 13px !important;
        padding: 0 8px !important;
    }
}

/* --------------------------------------------------------------------------
   7. ULTRA-COMPACT MOBILE (DƯỚI 360PX)
   Màn hình gập, điện thoại mini thế hệ cũ
   -------------------------------------------------------------------------- */
@media screen and (max-width: 360px) {
    .container {
        width: calc(100% - 16px) !important;
    }

    .section-heading h2 {
        font-size: 20px !important;
    }

    .hero-slider {
        height: 170px !important;
    }

    .hero-slide img {
        height: 170px !important;
    }

    .menu {
        width: 88% !important;
        padding: 75px 18px 24px !important;
    }

    .footer-inner {
        grid-template-columns: 1fr !important;
    }

    .footer-col:nth-child(1),
    .footer-col:nth-child(4) {
        grid-column: span 1 !important;
    }
}