﻿:root {
    /* สีธีมของ Megalok */
    --primary-color: #E60000;
    --bg-color: #0a0a0a;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --card-bg: #1a1a1a;
    --nav-bg: rgba(10, 10, 10, 0.95);
}

body {
    background: linear-gradient(to bottom, rgba(230, 0, 0, 0.28), rgba(0, 0, 0, 0.88)),
                url('../../images/bg_Megalok.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
    font-family: 'Kanit', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* -------------------------------------
          Navigation
       ------------------------------------- */
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: 15px 50px;
    border-bottom: 1px solid rgba(230, 0, 0, 0.2);
}

.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: 50px;
    max-width: 200px;
    width: auto;
    object-fit: contain;
    transition: 0.3s ease;
    display: block;
}

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

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
    align-items: center;
    padding: 0;
    margin: 0;
}

.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-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    min-width: 250px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(230, 0, 0, 0.1);
}

.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;
}

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

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

    .menu-icon {
        display: block;
        font-size: 28px;
        cursor: pointer;
        color: var(--text-main);
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--nav-bg);
        padding: 20px 0;
    }

    .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%;
    }
}

/* -------------------------------------
          Portfolio / Products
       ------------------------------------- */
main {
    flex: 1;
    padding-top: 100px;
}

.portfolio-header {
    text-align: center;
    padding: 40px 20px;
}

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

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

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

.gallery-section {
    padding: 0 20px 60px;
    max-width: 1200px;
    margin: 0 auto;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    justify-items: center;
}

.gallery-item {
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid rgba(230, 0, 0, 0.15);
    cursor: pointer;
    transition: 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 540px;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(230, 0, 0, 0.2);
    border-color: rgba(230, 0, 0, 0.5);
}

.gallery-item img {
    width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: contain;
    object-position: center;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.work-details {
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.work-details h3 {
    color: var(--primary-color);
    font-size: 20px;
    margin-bottom: 15px;
}

.work-details p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.work-tag {
    display: inline-block;
    background: rgba(230, 0, 0, 0.1);
    color: var(--primary-color);
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    margin-right: 5px;
    margin-bottom: 5px;
    border: 1px solid rgba(230, 0, 0, 0.2);
}

/* -------------------------------------
          CSS สำหรับ Popup (Modal)
       ------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 10, 0.9);
    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(230, 0, 0, 0.4);
    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: #000;
    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;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--primary-color);
}

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

.modal-body img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

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

.modal-details h3 {
    color: var(--primary-color);
    font-size: 26px;
    margin-bottom: 15px;
}

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

.order-btn {
    display: inline-block;
    background: var(--primary-color);
    color: #000;
    padding: 12px 25px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    transition: 0.3s;
}

.order-btn:hover {
    background: #fff;
    box-shadow: 0 0 20px rgba(230, 0, 0, 0.4);
    color: var(--primary-color);
}

@media (min-width: 768px) {
    .modal-body {
        flex-direction: row;
    }

    .modal-body img {
        width: 50%;
        height: auto;
        max-height: 500px;
        border-top-right-radius: 0;
        border-bottom-left-radius: 15px;
    }

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

/* -------------------------------------
          Footer
       ------------------------------------- */
footer {
    background: var(--card-bg);
    padding: 50px 20px 20px;
    border-top: 1px solid rgba(230, 0, 0, 0.1);
}

.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: #fff;
    font-weight: 300;
}

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

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

.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;
}

/* 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;
    }
}
