/* --- CSS Reset & Global --- */
:root {
    --primary-color: #003366; /* สีน้ำเงินเข้ม */
    --secondary-color: #ff6600; /* สีส้ม */
    --light-bg: #f4f4f4;
    --text-color: #333;
    --white: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Kanit', sans-serif; color: var(--text-color); line-height: 1.6; background-color: var(--white); }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; height: auto; } /* ป้องกันรูปภาพล้นจอ */

.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }

/* --- Header --- */
header {
    background: var(--white);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}
.nav-wrapper { display: flex; justify-content: space-between; align-items: center; height: 70px; }
.logo { font-size: 1.5rem; font-weight: 600; color: var(--primary-color); letter-spacing: 1px; }
.nav-links { display: flex; gap: 20px; }
.nav-links a { font-weight: 500; transition: color 0.3s; font-size: 1rem; }
.nav-links a:hover { color: var(--secondary-color); }
.menu-toggle { display: none; font-size: 1.5rem; cursor: pointer; color: var(--primary-color); }

/* --- Hero Section --- */
#home {
    background: url('https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80') no-repeat center center/cover;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--white);
    position: relative;
    padding-top: 70px; /* Offset for fixed header */
}
.hero-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 51, 102, 0.85);
    z-index: 1;
}
.hero-content { position: relative; z-index: 2; width: 100%; padding: 0 20px; }
#home h1 { font-size: 3rem; margin-bottom: 20px; line-height: 1.2; }
#home p { font-size: 1.2rem; margin-bottom: 30px; max-width: 700px; margin-left: auto; margin-right: auto; opacity: 0.9; }
.btn {
    background: var(--secondary-color);
    color: var(--white);
    padding: 12px 35px;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-block;
    border: none;
    cursor: pointer;
}
.btn:hover { background: #e65c00; transform: scale(1.05); }

/* --- Common Section Styles --- */
.section-padding { padding: 100px 0; } /* ใช้คลาสกลางเพื่อลดการเขียนซ้ำ */
.section-title { text-align: center; margin-bottom: 60px; }
.section-title h2 { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 15px; }
.section-title p { color: #666; font-size: 1.1rem; max-width: 600px; margin: 0 auto; }

/* --- Services Section --- */
#services { background: var(--light-bg); }
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}
.service-card {
    background: var(--white);
    padding: 40px 30px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
    text-align: center;
    border-bottom: 5px solid transparent;
}
.service-card:hover { transform: translateY(-10px); border-bottom: 5px solid var(--secondary-color); }
.service-icon { font-size: 3.5rem; color: var(--secondary-color); margin-bottom: 25px; }
.service-card h3 { font-size: 1.5rem; margin-bottom: 15px; color: var(--primary-color); }
.service-list { text-align: left; margin-top: 20px; padding-left: 20px; list-style: circle; color: #555; }
.service-list li { margin-bottom: 8px; }

/* --- Portfolio Section --- */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}
 /* เพิ่มการตั้งค่าของ portfolio-item */

/* .portfolio-item {
    min-height: 200px; 
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
} */
/* .portfolio-item:hover { 
        background: #ccc;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat; } */

    /* สไตล์ของกล่องหลัก */
.portfolio-item {
    min-height: 200px; 
    display: flex;
    flex-direction: column; /* จัดรูปให้อยู่บน ข้อความอยู่ล่าง */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden; /* สำคัญ! เพื่อไม่ให้รูปที่ซูมล้นออกมานอกกล่อง */
    background-color: #fff; /* หรือสีพื้นหลังที่ต้องการ */
    transition: background-color 0.3s ease; /* animation เวลาเปลี่ยนสีพื้นหลัง */
    border: 1px solid #eee; /* ใส่ขอบเล็กน้อย (ตัวเลือกเสริม) */
}

/* สไตล์เมื่อ Hover ที่กล่อง */
.portfolio-item:hover { 
    background-color: #f0f0f0; /* เปลี่ยนสีพื้นหลังเล็กน้อย */
}

/* กล่องหุ้มรูปภาพ */
.portfolio-image-wrapper {
    width: 100%;
    height: 220px; /* เพิ่มความสูงให้ดูเต็มตาขึ้น */
    overflow: hidden; /* สำคัญ: เพื่อให้เวลาซูม รูปไม่ล้นออกมานอกกรอบ */
    border-radius: 8px 8px 0 0; /* โค้งมนเฉพาะด้านบนให้เข้ากับดีไซน์ */
}

/* ตัวรูปภาพ - บังคับให้ขยายเต็มพื้นที่ */
.portfolio-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* ขยายรูปให้เต็มกล่อง (รูปจะถูกตัดขอบเล็กน้อยเพื่อให้เต็มพอดี) */
    transition: transform 0.4s ease; /* ตั้งค่าความเร็วก่อนซูม */
    display: block;
}

/* เมื่อเอาเมาส์ไปชี้ที่กล่อง ให้รูปข้างในซูมเข้า */
.portfolio-item:hover .portfolio-image-wrapper img {
    transform: scale(1.1); /* ซูมเข้าไป 10% */
}

/* ปรับแต่งส่วนของข้อความข้างล่างรูป */
.portfolio-item span {
    display: block;
    padding: 15px;
    text-align: center;
    font-weight: bold;
    color: #333;
}
/* ส่วนของ .client-logos เดิม ปรับปรุงเล็กน้อย */
.client-logos {
    display: flex;
    justify-content: center;
    gap: 40px; /* เพิ่มช่องว่างเล็กน้อยเพื่อให้ดูไม่อึดอัด */
    flex-wrap: wrap;
    margin-top: 80px;
    margin-bottom: 80px;
    opacity: 0.7; /* เพิ่มความชัดเล็กน้อย */
    align-items: center; /* สำคัญ! จัดให้โลโก้ทั้งหมดอยู่กึ่งกลางตามแนวตั้ง */
}

/* กล่องหุ้มโลโก้ */
.client-logo-box {
    display: flex;
    flex-direction: column; /* จัดรูปให้อยู่บน ข้อความอยู่ล่าง */
    align-items: center; /* จัดรูปและข้อความให้อยู่กึ่งกลางตามแนวนอน */
    text-align: center;
}

/* 🔥 ส่วนสำคัญ: กำหนดขนาดโลโก้ */
.client-logo-img {
    max-width: 150px; /* กำหนดความกว้างสูงสุดของโลโก้ ไม่ให้ใหญ่เกินไป */
    max-height: 100px; /* กำหนดความสูงสูงสุด ไม่ให้โลโก้แนวยาวสูงเกินไป */
    width: auto; /* รักษาอัตราส่วนรูปภาพ (Aspect Ratio) */
    height: auto; /* รักษาอัตราส่วนรูปภาพ (Aspect Ratio) */

    transition: filter 0.3s ease; /* animation เวลาเปลี่ยน */
}

/* (ถ้าเลือกกรณีที่ 2) จัดสไตล์ชื่อลูกค้าใต้รูป */
.client-name {
    margin-top: 10px; /* เว้นระยะจากรูปภาพ */
    font-size: 0.9rem; /* ปรับขนาดข้อความให้เล็กลง ดูเป็นระเบียบ */
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
}

/* --- Contact & Team Section --- */
#contact { background: var(--primary-color); color: var(--white); }
#contact .section-title h2 { color: var(--white); }
#contact .section-title p { color: #ccc; }

.contact-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: flex-start;
}

/* Team Info */
.team-info h3 { margin-bottom: 20px; color: var(--secondary-color); font-size: 1.4rem; }
.team-info ul li { margin-bottom: 15px; display: flex; align-items: center; gap: 15px; font-size: 1.1rem; }
.team-info ul li i { width: 25px; text-align: center; color: var(--secondary-color); }
.map-placeholder {
    background: rgba(255,255,255,0.1);
    height: 200px;
    border-radius: 8px;
    display:flex;
    align-items:center;
    justify-content:center;
    color: #aaa;
    border: 1px dashed #aaa;
    margin-top: 20px;
}

/* Contact Form */
.contact-form-wrapper { background: var(--white); padding: 40px; border-radius: 10px; color: var(--text-color); }
.form-group { margin-bottom: 20px; }
.contact-form input, .contact-form select, .contact-form textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
    background: #f9f9f9;
    transition: border-color 0.3s;
}
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus {
    outline: none; border-color: var(--secondary-color); background: var(--white);
}
.btn-submit {
    width: 100%;
    padding: 15px;
    background: var(--secondary-color);
    color: var(--white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: background 0.3s;
}
.btn-submit:hover { background: #e65c00; }

/* Footer */
footer { background: #002244; color: #8899a6; text-align: center; padding: 30px 20px; font-size: 0.9rem; }

/* =========================================
   Mobile Responsive (ขนาดหน้าจอเล็กกว่า 768px)
   ========================================= */
@media (max-width: 768px) {
    /* ปรับเมนูนำทาง */
    .menu-toggle { display: block; }
    .nav-links {
        position: absolute;
        top: 70px; left: 0; width: 100%;
        background: var(--white);
        flex-direction: column;
        align-items: center;
        padding: 20px 0;
        gap: 20px;
        box-shadow: 0 5px 5px rgba(0,0,0,0.1);
        display: none; /* ซ่อนไว้ก่อน ต้องใช้ JS สลับ class .active */
    }
    .nav-links.active { display: flex; }
    
    /* ปรับขนาดฟอนต์บนมือถือ */
    #home h1 { font-size: 2.2rem; }
    #home p { font-size: 1rem; }
    .section-title h2 { font-size: 2rem; }
    .section-title p { font-size: 1rem; }

    /* ลด Padding ของ Section ไม่ให้เปลืองพื้นที่บนจอมือถือ */
    .section-padding { padding: 60px 0; }
    .section-title { margin-bottom: 40px; }

    /* ปรับ Layout ให้เรียงซ้อนกันแนวตั้ง */
    .contact-container { grid-template-columns: 1fr; gap: 40px; }
    
    /* ปรับความกว้างของฟอร์มและการ์ดบนมือถือ */
    .contact-form-wrapper { padding: 25px 20px; }
    .service-card { padding: 30px 20px; }
    
    /* ปรับ Logo ลูกค้าตอนล่าง */
    .client-logos { margin-top: 50px;  gap: 20px; }
    .client-logo-box { font-size: 1.2rem;  }
}

/* =========================================
   Tablet Responsive (ขนาดหน้าจอ 769px - 1024px)
   ========================================= */
@media (max-width: 1024px) {
    .contact-container { gap: 30px; }
    .contact-form-wrapper { padding: 30px; }
}