﻿/* =========================================================
   MeGA Genesis - Product Page Stylesheet
========================================================= */

:root {
    --primary-color: #FF5722;
    --bg-color: #0c0805;
    --text-main: #ffffff;
    --text-muted: #b8b0aa;
    --card-bg: #1a100a;
    --nav-bg: rgba(12, 8, 5, 0.95);
    --input-bg: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
}

body {
    background: linear-gradient(to bottom, rgba(99, 68, 47, 0.45), rgba(12, 8, 5, 0.72)),
        url('../images-megagensis/logo_gen.jpg') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-main);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    padding-top: 85px;
    /* เว้นระยะจาก Navbar ด้านบน */
}

/* =========================================
   1. Navigation Bar & Logo
========================================= */
header {
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 50px;
    border-bottom: 1px solid rgba(255, 87, 34, 0.1);
}

.header-left {
    height: 65px; 
    max-width: 250px; 
    width: auto;
    object-fit: contain;
    display: block; /* 👈 เพิ่มบรรทัดนี้เพื่อลบช่องว่างขอบล่าง (Baseline) */
    transition: 0.3s ease;
}

.back-to-main {
    color: var(--text-main);
    font-size: 18px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: 0.3s ease;
}

.back-to-main:hover {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

header .logo img {
    height: 65px;
    max-width: 250px;
    width: auto;
    object-fit: contain;
    transition: 0.3s ease;
}

header .logo img:hover {
    transform: scale(1.02);
}

/* Menu */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
    align-items: center;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: var(--text-main);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: 0.3s;
    padding: 10px 0;
    display: inline-block;
}

.nav-menu a:hover {
    color: var(--primary-color);
}

/* Dropdown */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 87, 34, 0.2);
}

.dropdown-content li {
    width: 100%;
    list-style: none;
}

.dropdown-content a {
    padding: 12px 20px;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-size: 15px;
}

.dropdown-content a:hover {
    background: var(--primary-color);
    color: #fff;
    padding-left: 25px;
}

.dropdown:hover .dropdown-content {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-toggle,
.menu-icon {
    display: none;
}

/* =========================================
   2. Product Content Layout
========================================= */
.product-header {
    padding: 50px 20px;
    text-align: center;
    background: linear-gradient(to bottom, rgba(255, 87, 34, 0.1), var(--bg-color));
}

.product-header h1 {
    font-size: clamp(35px, 6vw, 50px);
    font-weight: 900;
    margin-bottom: 10px;
}

.product-header h1 span {
    color: var(--primary-color);
}

.product-header p {
    color: var(--text-muted);
    font-size: 16px;
}

.product-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 80px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    align-items: center;
}

.product-image {
    width: 100%;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid rgba(255, 87, 34, 0.2);
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.product-image img {
    width: 100%;
    height: 420px;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: 0.5s;
}

.product-image:hover img {
    transform: scale(1.05);
}

.product-info h2 {
    font-size: 30px;
    margin-bottom: 20px;
    color: #fff;
}

.product-info p {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 25px;
    font-size: 16px;
}

.feature-list {
    list-style: none;
    margin-bottom: 30px;
}

.feature-list li {
    margin-bottom: 12px;
    font-size: 16px;
    color: var(--text-main);
    display: flex;
    align-items: flex-start;
}

.feature-list li::before {
    content: '✔';
    color: var(--primary-color);
    font-weight: bold;
    margin-right: 15px;
    font-size: 18px;
    margin-top: 2px;
}

.order-btn {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    padding: 15px 35px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    text-decoration: none;
    transition: 0.3s;
    text-transform: uppercase;
    box-shadow: 0 5px 15px rgba(255, 87, 34, 0.2);
}

.order-btn:hover {
    background: #fff;
    color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 87, 34, 0.4);
}

/* =========================================
   3. Product Gallery
========================================= */
.gallery-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 80px;
}

.gallery-title {
    text-align: center;
    font-size: 30px;
    margin-bottom: 40px;
    font-weight: bold;
    position: relative;
    color: #fff;
}

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

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 87, 34, 0.2);
    aspect-ratio: 1 / 1;
    cursor: pointer;
    background: var(--card-bg);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.4s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* =========================================
   4. Footer
========================================= */
footer {
    background: var(--card-bg);
    padding: 50px 20px 20px;
    border-top: 1px solid rgba(255, 87, 34, 0.2);
    margin-top: auto;
}

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

.footer-col h4 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-main);
    font-weight: bold;
    text-transform: uppercase;
}

.footer-col h4 span {
    color: var(--primary-color);
}

.footer-col p {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 15px;
    margin-bottom: 15px;
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 12px;
}

.footer-col ul a {
    color: var(--text-muted);
    text-decoration: none;
    transition: 0.3s;
    display: inline-block;
}

.footer-col ul a:hover {
    color: var(--primary-color);
    transform: translateX(5px);
}

.social-links a {
    display: inline-block;
    margin-right: 10px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    width: 40px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    border-radius: 5px;
    transition: 0.3s;
    text-decoration: none;
}

.social-links a:hover {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 87, 34, 0.3);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 14px;
}

/* =========================================
   5. Responsive (Mobile & Tablet)
========================================= */
@media (max-width: 900px) {
    .product-container {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 10px 20px;
    }

    .menu-icon {
        display: block;
        font-size: 28px;
        cursor: pointer;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--nav-bg);
        padding: 20px 0;
        border-bottom: 1px solid rgba(255, 87, 34, 0.2);
    }

    .menu-toggle:checked~.nav-menu {
        display: flex;
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(255, 255, 255, 0.02);
        display: none;
        padding-left: 20px;
        width: 100%;
    }

    .dropdown:hover .dropdown-content {
        display: block;
    }

    header .logo img {
        height: 45px;
    }

    .product-header h1 {
        font-size: 30px;
    }
}

/* จัด Layout ส่วนหัวให้คลีน */
.portfolio-header {
    padding: 60px 20px 40px;
    text-align: center;
}

.portfolio-header h1 {
    font-size: clamp(35px, 6vw, 45px);
    margin-bottom: 10px;
    color: #fff;
    font-weight: 900;
}

.portfolio-header h1 span {
    color: var(--primary-color);
}

.portfolio-header p {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 20px;
}

/* ปรับกล่องผลงานให้มีพื้นที่ใส่ข้อความด้านล่าง */
.gallery-item {
    aspect-ratio: auto !important;
    /* ยกเลิกการบังคับเป็นสี่เหลี่ยมจัตุรัส */
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    text-align: left;
    transition: 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.gallery-item img {
    width: 100%;
    height: 260px !important;
    object-fit: cover;
    object-position: center;
    display: block;
    border-bottom: 1px solid rgba(255, 87, 34, 0.2);
}

/* ส่วนข้อความรายละเอียดผลงาน */
.work-details {
    padding: 20px;
}

.work-details h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 8px;
}

.work-details p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

.work-tag {
    display: inline-block;
    background: rgba(255, 87, 34, 0.1);
    color: var(--primary-color);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 10px;
}

/* -------------------------------------
           CSS สำหรับ Popup (Modal)
        ------------------------------------- */
.gallery-item {
    cursor: pointer;
    /* ทำให้เมาส์เป็นรูปมือเวลากด */
}

.modal-overlay {
    display: none;
    /* ซ่อนไว้ก่อน */
    position: fixed;
    z-index: 2000;
    /* ให้อยู่บนสุด */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    /* พื้นหลังดำโปร่งแสง */
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-container {
    background-color: var(--card-bg);
    border: 1px solid rgba(255, 87, 34, 0.3);
    border-radius: 15px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-50px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-overlay.show .modal-container {
    transform: translateY(0);
}

.close-btn {
    color: #fff;
    background: var(--primary-color);
    width: 40px;
    height: 40px;
    line-height: 38px;
    text-align: center;
    border-radius: 50%;
    font-size: 28px;
    position: absolute;
    top: 15px;
    right: 15px;
    cursor: pointer;
    transition: 0.3s;
    z-index: 10;
}

.close-btn:hover {
    background: #fff;
    color: var(--primary-color);
    transform: scale(1.1);
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.modal-media {
    position: relative;
    width: 100%;
    background: #120d09;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    overflow: hidden;
}

.modal-body img {
    width: 100%;
    height: 420px;
    object-fit: contain;
    display: block;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.12));
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    background: rgba(12, 8, 5, 0.7);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.25s ease;
    z-index: 2;
}

.modal-nav:hover {
    background: var(--primary-color);
}

.modal-prev {
    left: 16px;
}

.modal-next {
    right: 16px;
}

.modal-counter {
    position: absolute;
    left: 16px;
    bottom: 16px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(12, 8, 5, 0.72);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.modal-details {
    padding: 40px 30px;
}

.modal-details h3 {
    color: #fff;
    font-size: 28px;
    margin-bottom: 15px;
}

.modal-details p {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 25px;
}

/* รองรับหน้าจอคอมพิวเตอร์ (ให้รูปอยู่ซ้าย ข้อความอยู่ขวา) */
@media (min-width: 768px) {
    .modal-body {
        flex-direction: row;
    }

    .modal-media {
        width: 50%;
        border-top-right-radius: 0;
        border-bottom-left-radius: 15px;
    }

    .modal-body img {
        height: 100%;
        min-height: 500px;
        border-top-right-radius: 0;
        border-bottom-left-radius: 15px;
    }

    .modal-details {
        width: 50%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* Skeleton Loading */
body.is-loading {
    overflow: hidden;
}

body.is-loading > *:not(.skeleton-loader) {
    visibility: hidden;
}

body.page-ready > *:not(.skeleton-loader) {
    visibility: visible;
}

.skeleton-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    background: #0f1417;
    transition: opacity 0.35s ease;
}

body.is-loading .skeleton-loader {
    opacity: 1;
    pointer-events: auto;
}

body.page-ready .skeleton-loader {
    opacity: 0;
}

.sk-topbar,
.sk-thumb,
.sk-line,
.sk-tags,
.sk-dot {
    position: relative;
    overflow: hidden;
    background: #1c2429;
    border-radius: 10px;
}

.sk-shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.18) 50%, rgba(255,255,255,0) 100%);
    animation: skeleton-shimmer 1.25s infinite;
}

.sk-wrap,
.sk-canvas {
    width: min(1200px, 94vw);
    margin: 92px auto 0;
}

.sk-wrap {
    display: grid;
    gap: 20px;
}

.sk-topbar {
    height: 76px;
    border-radius: 0;
}

.sk-line {
    height: 14px;
    margin-bottom: 10px;
}

.sk-title {
    height: 42px;
    width: min(520px, 72%);
}

.sk-mid {
    width: 76%;
}

.sk-short {
    width: 58%;
}

.sk-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
}

.sk-panel {
    background: #151d21;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 16px;
}

.sk-product-head,
.sk-product-grid,
.sk-about-hero,
.sk-about-main,
.sk-about-values-head,
.sk-about-values-grid,
.sk-section,
.sk-hero,
.sk-grid,
.sk-split,
.sk-map {
    display: none;
}

/* Product skeleton: portfolio header + gallery cards */
body.skeleton-product .sk-product-head,
body.skeleton-product .sk-product-grid {
    display: grid;
}

body.skeleton-product .sk-product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.sk-pcard {
    background: #151d21;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 12px;
}

.sk-pcard .sk-thumb {
    margin-bottom: 10px;
}

.sk-tags {
    height: 28px;
    width: 46%;
    border-radius: 999px;
    margin-top: 8px;
}

/* About skeleton: hero + split content + values cards */
body.skeleton-about .sk-about-hero,
body.skeleton-about .sk-about-main,
body.skeleton-about .sk-about-values-head,
body.skeleton-about .sk-about-values-grid {
    display: grid;
}

body.skeleton-about .sk-about-main {
    grid-template-columns: 1.15fr 1fr;
    gap: 16px;
}

.sk-portrait {
    aspect-ratio: 4 / 5;
}

body.skeleton-about .sk-about-values-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.sk-vcard {
    background: #151d21;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 14px;
}

.sk-dot {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    margin-bottom: 12px;
}

/* Keep existing fallback template (home/contact currently uses sk-section) */
body.skeleton-home .sk-hero,
body.skeleton-home .sk-grid,
body.skeleton-contact .sk-hero,
body.skeleton-contact .sk-split,
body.skeleton-contact .sk-map {
    display: grid;
}

body.skeleton-home .sk-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

body.skeleton-home .sk-card:nth-child(n+4) {
    display: none;
}

body.skeleton-contact .sk-split {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.sk-mapbox {
    aspect-ratio: 16 / 5;
}

@keyframes skeleton-shimmer {
    to { transform: translateX(100%); }
}

@media (max-width: 1024px) {
    body.skeleton-product .sk-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .sk-wrap,
    .sk-canvas {
        margin-top: 84px;
        gap: 14px;
    }

    .sk-title {
        height: 34px;
        width: 84%;
    }

    .sk-line {
        height: 12px;
    }

    body.skeleton-product .sk-product-grid,
    body.skeleton-about .sk-about-values-grid,
    body.skeleton-home .sk-grid {
        grid-template-columns: 1fr !important;
    }

    body.skeleton-about .sk-about-main,
    body.skeleton-contact .sk-split {
        grid-template-columns: 1fr !important;
    }

    .sk-pcard:nth-child(n+5) {
        display: none;
    }

    .sk-mapbox {
        aspect-ratio: 16 / 7;
    }
}
