/* ==========================================
   NANO ENGINEERING & SERVICE CO., LTD.
   Main Stylesheet - Standardized & Responsive
   ========================================== */

:root {
    --vibrant-blue: #007BFF;
    --dark-blue: #0056b3;
    --navy-blue: #002D62;
    --safety-orange: #FF8800;
    --safety-orange-hover: #E07700;
    --dark-grey: #2D3748;
    --light-grey: #F7FAFC;
    --border-grey: #E2E8F0;
    --footer-bg: #1A202C;
    --white: #FFFFFF;
    --font-heading: 'Kanit', sans-serif;
    --font-body: 'Sarabun', Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--dark-grey);
    background-color: var(--white);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    margin: 0;
}

/* ==========================================
   HEADER & NAVIGATION
   ========================================== */
header {
    background-color: var(--vibrant-blue);
    padding: 12px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
    gap: 15px; /* เพิ่ม gap เพื่อไม่ให้โลโก้ชนกับเมนู */
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex: 1 1 auto; /* อนุญาตให้คอนเทนเนอร์ยืดหยุ่นได้ */
    min-width: 0; /* จุดสำคัญ 1: บังคับให้ Flexbox ยอมตัดข้อความยาวๆ */
    max-width: calc(100% - 50px); /* เผื่อพื้นที่ 50px ไว้ให้ปุ่ม Hamburger เสมอ */
}

.logo-container img {
    height: 55px;
    width: auto;
    display: block;
    flex-shrink: 0 !important; /* คำสั่งเด็ดขาด: ห้ามบีบรูปภาพนี้ในทุกกรณี */
    min-width: 55px; /* จุดสำคัญ 2: ล็อกความกว้างขั้นต่ำ ป้องกันภาพถูกบีบเหลือ 0px */
    object-fit: contain; /* รักษาสัดส่วนภาพ */
    
}

.logo-title {
    color: var(--white);
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;/* ไม่ให้ขึ้นบรรทัดใหม่ */
    overflow: hidden; 
    text-overflow: ellipsis; /* หากหน้าจอแคบจนข้อความล้น จะเปลี่ยนคำท้ายเป็น ... อัตโนมัติ */
}

/* Nav Menu */
nav {
    display: flex;
    align-items: center;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 24px;
    margin: 0;
    padding: 0;
}

nav ul li a {
    color: var(--white);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: color 0.3s ease;
    padding: 6px 0;
    position: relative;
}

nav ul li a:hover,
nav ul li a.active {
    color: #FFCC00;
}

nav ul li a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #FFCC00;
}

/* Mobile Hamburger Menu Icon */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1100;
}

.hamburger span {
    width: 100%;
    height: 3px;
    background-color: var(--white);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}

/* ==========================================
   SECTIONS & LAYOUT
   ========================================== */
.section-padding {
    padding: 50px 5%;
    flex-grow: 1;
}

.bg-light {
    background-color: var(--light-grey);
}

.section-title {
    text-align: center;
    font-size: 28px;
    color: var(--vibrant-blue);
    margin-bottom: 40px;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--safety-orange);
    margin: 12px auto 0 auto;
    border-radius: 2px;
}

/* HERO SECTION */
.hero {
    background: linear-gradient(rgba(0, 45, 98, 0.75), rgba(0, 45, 98, 0.75)), 
    url('https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?auto=format&fit=crop&w=1200&q=80');
    background-size: cover;
    background-position: center;
    color: var(--white);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 20px;
    flex-grow: 1;
}

.hero h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.35;
    max-width: 900px;
}

.hero p {
    font-size: 16px;
    margin-bottom: 30px;
    max-width: 750px;
    opacity: 0.95;
}

.cta-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.cta-btn {
    background-color: var(--safety-orange);
    color: var(--white);
    border: none;
    padding: 12px 28px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(255, 136, 0, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cta-btn:hover {
    background-color: var(--safety-orange-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 136, 0, 0.4);
}

.cta-secondary {
    background-color: transparent;
    border: 2px solid var(--white);
    box-shadow: none;
}

.cta-secondary:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* ==========================================
   SERVICES GRID
   ========================================== */
.services-grid {
    display: grid;
   /* grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));*/
    gap: 25px;
    align-items: stretch;
    grid-template-columns: 1fr; /* increase row */
}

.service-card {
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    border: 1px solid var(--border-grey);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.12);
}

.service-content {
    padding: 25px;
    flex-grow: 1;
}

.service-content h3 {
    font-size: 18px;
    color: var(--vibrant-blue);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--light-grey);
    padding-bottom: 12px;
}

.service-content ul {
    padding-left: 20px;
    margin: 0;
    font-size: 14px;
    color: var(--dark-grey);
}

.service-content ul li {
    margin-bottom: 10px;
}

/* ==========================================
   PORTFOLIO CATEGORY GRID & MODAL
   ========================================== */
.category-grid {
    display: grid;
    /*grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));*/
    gap: 20px;
    width: 100%;
   grid-template-columns: 1fr; /* increase row */ 
}

.category-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-grey);
    display: flex;
    flex-direction: column;
}

.category-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 25px rgba(0, 123, 255, 0.15);
}

.category-icon-box {
    background-color: var(--light-grey);
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--vibrant-blue);
    border-bottom: 1px solid var(--border-grey);
    transition: background 0.3s, color 0.3s;
}

.category-card:hover .category-icon-box {
    color: var(--safety-orange);
    background-color: #FFF8F0;
}

.category-info {
    padding: 20px;
    text-align: center;
}

.category-info h3 {
    color: var(--dark-grey);
    font-size: 18px;
    margin-bottom: 8px;
}

.category-info p {
    font-size: 13px;
    color: #718096;
}

/* GALLERY MODAL */
.gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: 2000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-header {
    color: var(--white);
    text-align: center;
    margin-bottom: 15px;
    z-index: 2100;
}

.modal-header h3 {
    font-size: 22px;
    color: #FFCC00;
    margin-bottom: 4px;
}

.modal-counter {
    font-size: 14px;
    opacity: 0.8;
}

.modal-viewport {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-img {
    max-width: 90%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}

.modal-caption {
    color: var(--white);
    font-size: 15px;
    text-align: center;
    margin-top: 15px;
    max-width: 800px;
    line-height: 1.5;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 6px;
    border-left: 4px solid var(--safety-orange);
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--white);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2100;
}

.nav-arrow:hover {
    background-color: var(--safety-orange);
}

.arrow-left { left: 0; }
.arrow-right { right: 0; }

.exit-gallery-btn {
    margin-top: 20px;
    background-color: var(--safety-orange);
    color: var(--white);
    border: none;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-heading);
}

.exit-gallery-btn:hover {
    background-color: var(--safety-orange-hover);
}

/* ==========================================
   CONTACT PAGE & FORM
   ========================================== */
.contact-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px;
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--border-grey);
}

.contact-info-box h3 {
    color: var(--vibrant-blue);
    font-size: 22px;
    margin-bottom: 15px;
}

.contact-info-box p {
    font-size: 15px;
    margin-bottom: 25px;
    color: #4A5568;
}

.contact-btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-size: 15px;
    transition: all 0.3s ease;
    width: 100%;
}

.call-btn { background-color: #28A745; color: var(--white); }
.call-btn:hover { background-color: #218838; }

.map-btn { background-color: var(--vibrant-blue); color: var(--white); }
.map-btn:hover { background-color: var(--dark-blue); }

.streetview-btn { background-color: #4A5568; color: var(--white); }
.streetview-btn:hover { background-color: #2D3748; }

.contact-form-box h4 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--dark-grey);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #4A5568;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #CBD5E0;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--vibrant-blue);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.submit-btn {
    width: 100%;
    background-color: var(--safety-orange);
    color: var(--white);
    border: none;
    padding: 13px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.submit-btn:hover {
    background-color: var(--safety-orange-hover);
}

/* Anti-Spam Honeypot Field */
.honeypot-field {
    display: none !important;
    visibility: hidden !important;
}

/* ==========================================
   FOOTER
   ========================================== */
footer {
    background-color: var(--footer-bg);
    color: #A0AEC0;
    padding: 35px 5% 15px 5%;
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-info h3 {
    font-size: 16px;
    color: var(--white);
    margin-bottom: 12px;
    border-left: 3px solid var(--safety-orange);
    padding-left: 10px;
}

.footer-info p {
    font-size: 13px;
    margin: 0;
    line-height: 1.6;
}

.footer-bottom {
    text-align: center;
    border-top: 1px solid #2D3748;
    padding-top: 15px;
    margin-top: 25px;
    font-size: 12px;
}

/* ==========================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================== */
@media (max-width: 992px) {
    header {
        padding: 12px 4%;
    }
    
    .hero h1 {
        font-size: 26px;
    }
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
/* สำหรับ Tablet (แนวนอน) และ Desktop บังคับโชว์ 4 กล่อง ในแถวเดียวเสมอ -เพิ่ม */
@media (min-width: 1024px) {
    .services-grid, .category-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* เปลี่ยนจาก 768px เป็น 1024px เพื่อให้ครอบคลุม Tablet และ Dex Mode หน้าต่างเล็ก */
@media (max-width: 1024px) {
    .hamburger {
        display: flex;
    }
    
/* สำหรับหน้าจอมือถือแนวตั้ง (Mobile) */
@media (max-width: 576px) {
    .logo-container {
        gap: 8px;
    }
    
    .logo-container img {
        height: 40px; /* ย่อโลโก้ลงเล็กน้อย */
        min-width: 40px; /* ลดขนาดขั้นต่ำลงบนมือถือ แต่ยังล็อกไม่ให้เป็น 0px */
    }

    .logo-title {
        font-size: 14px; /* ย่อตัวหนังสือเพื่อไม่ให้ล้นจอ */
    }
}    
    
    nav ul {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background-color: var(--vibrant-blue);
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 40px;
        gap: 25px;
        transition: left 0.3s ease;
        box-shadow: 0 10px 15px rgba(0,0,0,0.2);
        z-index: 1050; /* <-- เพิ่มบรรทัดนี้ เพื่อดันให้เมนูอยู่เลเยอร์บนสุดเสมอ */
    }
    
    /* สำหรับหน้าจอมือถือแนวตั้ง (Mobile) */
@media (max-width: 576px) {
    .logo-container {
        gap: 8px;
    }
    
    .logo-container img {
        height: 40px; /* ย่อโลโก้ลงเล็กน้อย */
    }

    .logo-title {
        font-size: 14px; /* ย่อตัวหนังสือเพื่อไม่ให้ล้นจอ */
    }
}

    nav ul.active {
        left: 0;
    }

    nav ul li a {
        font-size: 18px;
    }

    .hero {
        padding: 50px 20px;
    }

    .hero h1 {
        font-size: 22px;
    }

    .hero p {
        font-size: 14px;
    }

    .section-padding {
        padding: 35px 4%;
    }

    .contact-container {
        padding: 20px;
        gap: 30px;
    }

    .modal-viewport {
        height: 50vh;
    }

    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}
}