/* === โครงสร้างหลัก === */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 0;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    padding-top: 80px;
    /* Space for navbar */
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 40px;
    margin: 30px auto 60px auto;
    /* Center horizontally, space for footer */
}

.product-detail {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
    gap: 30px;
}

.product-image {
    width: 100%;
    max-width: 480px;
}

.product-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.product-details {
    flex: 1;
    min-width: 300px;
}

.product-details h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #1e3c72;
    font-weight: 700;
    line-height: 1.2;
}

.product-details p {
    font-size: 1.1em;
    color: #555;
    line-height: 1.8;
    margin-bottom: 20px;
}

.product-details p strong {
    color: #1e3c72;
    font-weight: 600;
}

/* Button Group */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 30px;
}

.product-details .btn {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    padding: 14px 28px;
    text-decoration: none;
    border-radius: 12px !important;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.3);
    overflow: hidden;
}

.product-details .btn:hover {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 60, 114, 0.4);
}

.product-details .btn i {
    font-size: 1.1em;
}

/* === สินค้าที่เกี่ยวข้อง === */
.related-products {
    margin-top: 60px;
    width: 100%;
}

.related-products h2 {
    font-size: 1.5em;
    color: #1e3c72;
    margin-bottom: 25px;
    font-weight: 700;
    text-align: center;
}

/* Scroll wrapper with buttons */
.related-scroll-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

/* Scroll container */
.related-scroll-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 15px 5px;
    flex: 1;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.related-scroll-container::-webkit-scrollbar {
    display: none;
}

/* Related product card */
.related-card {
    flex: 0 0 auto;
    width: 200px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
}

.related-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border-color: #1e3c72;
}

.related-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.related-card img,
.related-card video {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.related-card-title {
    font-size: 0.95em;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
}

/* === การ์ดสินค้า === */
.related-product-card {
    flex: 0 0 auto;
    width: 260px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.related-product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.related-product-card h3 {
    font-size: 1.1em;
    margin-top: 10px;
    color: #333;
}

.related-product-card .btn {
    margin-top: 10px;
    background-color: #ff6600;
    color: #fff;
    padding: 10px;
    text-decoration: none;
    border-radius: 5px;
    font-size: 1em;
    display: inline-block;
}

.related-product-card .btn:hover {
    background-color: #e55b00;
}

.related-product-card:hover {
    transform: translateY(-5px);
}

/* === Scroll buttons === */
.scroll-button {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.scroll-button:hover {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(30, 60, 114, 0.4);
}

.scroll-button:active {
    transform: scale(0.95);
}

/* === แกลเลอรีภาพ === */
.product-image-gallery {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.main-image {
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.thumbnail-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-width: 400px;
}

.thumbnail,
.thumbnail video {
    width: 100%;
    height: 70px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 5px;
    transition: border-color 0.2s;
}

.thumbnail:hover,
.thumbnail video:hover {
    border-color: #ff6600;
}

/* === Responsive สำหรับ Tablet (จอ 768px ขึ้นไป) === */
@media (max-width: 1024px) {
    .container {
        padding: 30px 25px;
        margin: 20px auto 50px auto;
    }

    .product-detail {
        flex-direction: column;
        align-items: center;
    }

    .product-image {
        max-width: 100%;
    }

    .product-details {
        width: 100%;
    }

    .product-details h1 {
        font-size: 2.2em;
    }

    .btn-group {
        justify-content: center;
    }

    .thumbnail-container {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    .scroll-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .related-card {
        width: 180px;
    }
}

/* === Responsive สำหรับ Mobile (จอเล็กกว่า 768px) === */
@media (max-width: 767px) {
    body {
        padding-top: 70px;
    }

    .container {
        padding: 20px 15px;
        margin: 15px auto 40px auto;
        border-radius: 8px;
    }

    .product-details h1 {
        font-size: 1.8em;
    }

    .product-details p {
        font-size: 1em;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .product-details .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.95em;
        padding: 12px 20px;
    }

    .related-products h2 {
        font-size: 1.5em;
    }

    .related-card {
        width: 160px;
    }

    .related-card img,
    .related-card video {
        height: 120px;
    }

    .thumbnail-container {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    }

    .main-image {
        max-width: 100%;
    }

    .scroll-button {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}