/* === navbar.css (ฉบับแก้ไข: ขยับเมนู Home, About มาทางซ้าย + แก้ Scroll Fix) === */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ตั้งค่า Font ที่ตัวแม่ (Navbar) เพื่อให้ลูกๆ สืบทอด แต่ไม่บังคับทับไอคอน */
.navbar {
    font-family: 'Poppins', sans-serif;
}

.navbar * {
    box-sizing: border-box;
}

/* === 1. Navbar State: ปกติ (โปร่งใส ลอยบนรูป) === */
.navbar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background-color: transparent;
    display: flex;
    align-items: center;
    z-index: 1000;
    transition: all 0.3s ease;
}

/* สีตัวหนังสือตอนโปร่งใส (สีขาว) */
.navbar .logo,
.navbar .nav-links>li>a,
.navbar .hamburger {
    color: #ffffff;
    transition: color 0.3s ease;
}

/* === 2. Navbar State: Sticky (เลื่อนลงมา พื้นขาว) === */
.navbar.sticky {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.5s ease forwards;
    z-index: 9999;
}

/* สีตัวหนังสือตอนพื้นขาว (สีเทาเข้ม) */
.navbar.sticky .logo,
.navbar.sticky .nav-links>li>a,
.navbar.sticky .hamburger {
    color: #333333;
}

.logo .highlight {
    color: #00bcd4;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* === 3. Layout === */
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 700;

    /* ขยับโลโก้ (อันเดิมของคุณ) */
    position: relative;
    left: -1px;
}

.logo img {
    height: 170px;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 25px;
    margin: 0;
    padding: 0;

    /* --- [ส่วนที่เพิ่มใหม่] ขยับเมนู Home, About มาซ้าย --- */
    position: relative;
    left: -40px;
}

.nav-links>li {
    height: 80px;
    display: flex;
    align-items: center;
}

.nav-links>li>a {
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
}

/* --- Hover Effect & Active State (สีฟ้า) --- */
.nav-links>li>a:hover,
.nav-links>li>a.active,
.navbar.sticky .nav-links>li>a:hover,
.navbar.sticky .nav-links>li>a.active {
    color: #00bcd4 !important;
}

/* === 4. Dropdown Menu === */
.dropdown-item {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #ffffff;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 4px 4px;
    padding: 10px 0;
    list-style: none;
}

.dropdown-item:hover .dropdown-menu {
    display: block;
    animation: fadeIn 0.3s ease;
}

.dropdown-menu li a {
    display: block;
    padding: 12px 20px;
    color: #555 !important;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid #f5f5f5;
    transition: all 0.2s;
    text-transform: none;
    white-space: nowrap;
}

.dropdown-menu li:last-child a {
    border-bottom: none;
}

.dropdown-menu li a:hover {
    background-color: #f9f9f9;
    color: #00bcd4 !important;
    padding-left: 25px;
}

/* === 5. Specific Menu Widths === */
.product-menu {
    min-width: 320px;
}

.solution-menu {
    min-width: 360px;
}

.service-menu {
    min-width: 280px;
}

.contact-menu {
    min-width: 180px;
}

/* === 6. Nested Dropdown === */
.has-submenu {
    position: relative;
}

.submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background-color: #ffffff;
    min-width: 280px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    padding: 10px 0;
    list-style: none;
    z-index: 10001;
}

.has-submenu:hover .submenu {
    display: block;
    animation: fadeInRight 0.3s ease;
}

/* ลูกศรขวา > */
.has-submenu>a {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.has-submenu>a i {
    font-size: 0.8em;
    color: #ccc;
    margin-left: 10px;
}

.has-submenu:hover>a i {
    color: #00bcd4;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* === 7. Responsive === */
.hamburger {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.hamburger:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Hide overlay on mobile (not used in top-dropdown style) */
.nav-overlay {
    display: none !important;
}

@media (max-width: 900px) {
    .nav-container {
        padding: 0 20px;
        /* เพิ่มระยะห่างจากขอบจอทั้งซ้ายและขวา */
    }

    /* --- Logo: shrink on mobile --- */
    .logo img {
        height: 60px;
    }

    .logo {
        left: 0;
        gap: 5px;
        margin-left: 10px;
        /* ขยับโลโก้ให้ห่างจากขอบซ้ายอีกนิด */
        position: static;
    }

    /* --- Nav links: dropdown from top --- */
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 80px;
        left: 0;
        width: 100%;
        background-color: #ffffff;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        gap: 0;
        padding: 8px 0 16px;
        z-index: 9998;
        /* slide-down animation */
        transform-origin: top center;
    }

    .nav-links.active {
        display: flex;
        animation: slideDown 0.25s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* --- Nav items --- */
    .nav-links>li {
        height: auto;
        display: block;
        width: 100%;
        border-bottom: 1px solid #f3f3f3;
    }

    .nav-links>li:last-child {
        border-bottom: none;
    }

    .nav-links>li>a {
        color: #222 !important;
        padding: 14px 24px;
        font-size: 0.9rem;
        font-weight: 600;
        display: flex;
        justify-content: space-between;
        align-items: center;
        transition: color 0.2s, background 0.2s;
    }

    .nav-links>li>a:hover,
    .nav-links>li>a.active {
        color: #00bcd4 !important;
        background: #f0fbfc;
    }

    /* Arrow indicator ONLY for items with actual submenu */
    .dropdown-item:has(.dropdown-menu)>a::after {
        content: '\f107';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.75rem;
        color: #bbb;
        transition: transform 0.3s;
        pointer-events: none;
    }

    .dropdown-item.open:has(.dropdown-menu)>a::after {
        transform: rotate(180deg);
        color: #00bcd4;
    }

    /* --- Dropdown menus on mobile (accordion) --- */
    .dropdown-menu,
    .submenu {
        position: static;
        box-shadow: none;
        background-color: #f8fffe;
        padding: 4px 0;
        display: none;
        width: 100%;
        min-width: 100%;
        border-left: 3px solid #00bcd4;
        margin: 0;
    }

    .dropdown-item.open>.dropdown-menu,
    .has-submenu.open>.submenu {
        display: block;
        animation: accordionOpen 0.2s ease;
    }

    @keyframes accordionOpen {
        from {
            opacity: 0;
            transform: translateY(-4px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .dropdown-menu li a {
        white-space: normal;
        padding: 11px 20px 11px 24px;
        font-size: 0.83rem;
        color: #555 !important;
        border-bottom: 1px solid #efefef;
    }

    .dropdown-menu li:last-child a {
        border-bottom: none;
    }

    .dropdown-menu li a:hover {
        color: #00bcd4 !important;
        background: #f0fbfc;
    }

    /* has-submenu arrow */
    .has-submenu:has(.submenu)>a::after {
        content: '\f107';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.75rem;
        color: #bbb;
        transition: transform 0.3s;
        margin-left: auto;
        pointer-events: none;
    }

    .has-submenu.open>a::after {
        transform: rotate(180deg);
        color: #00bcd4;
    }

    /* --- Hamburger visible --- */
    .hamburger {
        display: flex;
    }

    /* Reset any desktop offset */
    .nav-links {
        left: 0;
        right: auto;
    }
}

/* === 8. Scroll Fix & Mobile Layout Fix === */
html,
body {
    scroll-behavior: smooth;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100vw;
}

h1[id],
h2[id],
h3[id],
section[id] {
    scroll-margin-top: 100px;
}