/* --- MODERN BLACK & WHITE THEME --- */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;700&display=swap');

/* ======================================= */
/* ======== 0. RESET & DEFAULTS ======== */
/* ======================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    /* Ensures padding and border are included in the element's total width and height */
}

body {
    margin: 0;
    font-family: var(--font-main);
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    overflow-x: clip;
    /* Prevents all horizontal scrolling */
}


/* ======================================= */
/* ======== 1. ROOT & UNIVERSAL STYLES ======== */
/* ======================================= */
:root {
    /* Color Palette */
    --bg-canvas: #000000;
    /* Pure black canvas for the body background */
    --bg-main: #121212;
    /* Near-black for main elements like cards and sidebars */
    --border-color: #2e2e2e;
    /* Subtle gray for borders and dividers */
    --text-primary: #FFFFFF;
    /* Pure white for high contrast text */
    --text-secondary: #b3b3b3;
    /* Light gray for secondary info, labels, and placeholders */
    --accent-primary: #24bad9;
    /* Vibrant blue for primary buttons, active states, and links */

    /* Typography & Layout */
    --font-main: 'Kanit', sans-serif;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --radius-md: 12px;
    --radius-lg: 16px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ================================ */
/* ======== 2. MAIN SHOP LAYOUT ======== */
/* ================================ */
.shop-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    /* Fixed sidebar, flexible main content */
    min-height: 100vh;
}

/* ================================ */
/* ======== 3. SIDEBAR STYLING ======== */
/* ================================ */
.sidebar {
    background-color: var(--bg-main);
    border-right: 1px solid var(--border-color);
    padding: 32px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Pushes footer content down */
}

.sidebar-logo {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.sidebar-logo span {
    color: var(--accent-primary);
}

.sidebar-nav h3,
.sidebar-follow h3 {
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0 0 40px 0;
}

.sidebar-nav a {
    display: block;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 1.05em;
}

.sidebar-nav a:hover {
    background-color: var(--border-color);
    color: var(--accent-primary);
}

.sidebar-nav a.active {
    background-color: var(--accent-primary);
    color: var(--text-primary);
    font-weight: 700;
}

.sidebar-follow {
    margin-top: 40px;
}

.sidebar-social-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-social-links a {
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 500;
    transition: color 0.2s;
    font-size: 1.05em;
}

.sidebar-social-links a:hover {
    background-color: transparent;
    /* No background on hover for clean look */
    color: var(--accent-primary);
}

.sidebar-social-icon {
    width: 48px;
    height: 48px;
    display: block;
    object-fit: cover;
}

.sidebar-footer a {
    color: var(--accent-primary);
    font-weight: 600;
}

/* ================================== */
/* ======== 4. MAIN CONTENT AREA ======== */
/* ================================== */
.main-content {
    padding: 40px;
    overflow-y: auto;
}

.desktop-header {
    margin-bottom: 40px;
    margin-top: 40px;
}

.desktop-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.desktop-header p {
    font-size: 1.1em;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ========================================= */
/* ======== 5. HERO SECTION & MARQUEE ======== */
/* ========================================= */
.hero-section {
    width: 100%;
}

.hero-image-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    /* MODIFIED: This ensures the container matches the cropped image ratio */
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--bg-canvas);
    position: relative;
}

.hero-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-text-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 40px;
    box-sizing: border-box;
    color: var(--text-primary);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

.hero-text-overlay h1 {
    margin: 0 0 8px 0;
    font-size: 3em;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hero-text-overlay p {
    margin: 4px 0;
    font-size: 1.1em;
    line-height: 1.6;
    max-width: 600px;
    color: var(--text-secondary);
}

.hero-text-overlay .hero-price {
    font-weight: 700;
    color: var(--accent-primary);
    margin-top: 12px;
}

.marquee-container {
    width: 100%;
    background-color: var(--bg-main);
    padding: 12px 0;
    overflow: hidden;
    white-space: nowrap;
    border-radius: var(--radius-md);
    margin-top: 24px;
    box-sizing: border-box;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.marquee-text {
    display: inline-block;
    padding-left: 100%;
    /* Start off-screen */
    animation: scroll-left 15s linear infinite;
    margin: 0;
}

@keyframes scroll-left {
    0% {
        transform: translateX(0%);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* ======================================== */
/* ======== 6. PRODUCT GRID & CARDS ======== */
/* ======================================== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    /* Responsive grid */
    gap: 32px;
}

.product-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: none;
    /* Animation properties for Intersection Observer */
    opacity: 0;
    transform: translateY(40px);
    transition: transform 0.6s cubic-bezier(0.215, 0.610, 0.355, 1), border-color 0.2s, opacity 0.6s cubic-bezier(0.215, 0.610, 0.355, 1);
}

.product-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.product-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
}

.card-image-container {
    position: relative;
}

.card-image-container img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

.card-status {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 6px 12px;
    font-size: 0.8em;
    font-weight: 600;
    border-radius: 20px;
    z-index: 10;
}

.card-status.available {
    background-color: #28A745;
    color: white;
}

.card-status.preordered {
    background-color: #FFC107;
    color: #212529;
}

.card-status.sold {
    background-color: #DC3545;
    color: white;
}

.product-card.sold-item .card-image-container img {
    filter: grayscale(0);
    /* Visual cue for sold items */
}

.card-content {
    padding: 20px;
}

.card-content h3 {
    font-size: 1.4em;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.card-details {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 16px;
}

.card-price {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--accent-primary);
    display: flex;
    align-items: baseline;
}

.original-price {
    font-size: 0.75em;
    text-decoration: line-through;
    color: var(--text-secondary);
    font-weight: 400;
    margin-right: 8px;
}

/* =========================================== */
/* ======== 7. PRODUCT DETAIL PAGE STYLES ======== */
/* =========================================== */
.product-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) 1fr;
    /* Image gallery takes more space */
    gap: 40px;
    background-color: var(--bg-main);
    padding: 40px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.detail-info h1 {
    font-size: 3em;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.detail-info .price {
    font-size: 2em;
    color: var(--accent-primary);
    margin: 16px 0;
    font-weight: 700;
    display: flex;
    align-items: baseline;
}

.detail-info .price .original-price {
    font-size: 0.7em;
    color: var(--text-secondary);
}

.detail-info .description {
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.1em;
}

.details-list {
    list-style: none;
    padding: 0;
    margin: 32px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Two-column layout for details on all screen sizes */
    gap: 0 24px;
    border-top: 1px solid var(--border-color);
}

.details-list li {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 1em;
}

.details-list li strong {
    font-weight: 600;
    color: var(--text-primary);
}

.status-icon {
    font-weight: 700;
    font-size: 1.4em;
    line-height: 1;
}

.status-icon.check {
    color: #28A745;
    /* Green checkmark */
}

.status-icon.cross {
    color: #FA5252;
    /* Red cross */
}

.add-to-cart-button.sold-button {
    background-color: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Contact buttons for Line and Messenger */
.contact-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.contact-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    color: var(--text-primary);
    font-size: 1.2em;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    transition: filter 0.2s;
}

.contact-btn:hover {
    filter: brightness(1.1);
}

.contact-btn.line-btn {
    background-color: #00B900;
}

.contact-btn.messenger-btn {
    background-color: #0078FF;
}

/* ============================== */
/* ======== 8. PAGINATION ======== */
/* ============================== */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 48px;
}

.page-btn {
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.page-btn.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    cursor: default;
}

.page-btn.disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

/* =============================== */
/* ======== 9. SITE FOOTER ======== */
/* =============================== */
.site-footer {
    grid-column: 1 / -1;
    /* Ensure footer spans full width in grid layout */
    background-color: var(--bg-main);
    color: var(--text-secondary);
    padding: 60px 40px;
    border-top: 1px solid var(--border-color);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    /* Info on left, map on right */
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-info {
    display: flex;
    flex-direction: column;
}

.footer-logo {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.footer-description {
    font-size: 1em;
    margin: 0 0 24px 0;
}

.footer-contact {
    margin-bottom: 24px;
    line-height: 1.8;
}

.footer-contact span {
    display: block;
}

.social-links {
    display: flex;
    gap: 16px;
    margin-top: auto;
    /* Pushes social links to the bottom of the flex container */
}

.social-links a {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.social-links a img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.social-links a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(36, 186, 217, 0.25);
    /* Subtle glow effect using the new accent color */
}

.footer-map iframe {
    width: 100%;
    height: 100%;
    min-height: 250px;
    border: 0;
    border-radius: var(--radius-lg);
}

/* =============================================== */
/* ======== 10. GALLERY SLIDER (HOMEPAGE) ======== */
/* =============================================== */
.gallery-section {
    margin: 60px 0;
}

.gallery-section h2 {
    text-align: center;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 40px;
}

.gallery-slider {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.gallery-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
}

.gallery-slide {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 16 / 9;
    /* Maintain a widescreen aspect ratio */
}

.gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    font-size: 3rem;
    padding: 0 20px;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.gallery-arrow:hover {
    color: white;
}

.gallery-arrow.prev {
    left: 0;
}

.gallery-arrow.next {
    right: 0;
}

/* ================================================== */
/* ======== 11. PRODUCT DETAIL GALLERY (MODERN) ======== */
/* ================================================== */
.product-gallery-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%; /* Ensure it doesn't exceed container width */
    max-width: 100%; /* Prevent overflow */
    min-width: 0; /* Allow shrinking */
}

.main-image-wrapper {
    width: 100%;
    aspect-ratio: 4 / 3; /* More reasonable aspect ratio */
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    background-color: var(--bg-canvas);
    min-width: 0; /* Allow shrinking */
}

.main-image-wrapper .gallery-track {
    height: 100%;
    width: 100%;
    display: flex; /* Ensure proper flex layout */
}

.main-image-wrapper .gallery-slide {
    flex: 0 0 100%; /* Prevent shrinking and ensure full width */
    height: 100%;
    width: 100%;
}

.main-image-wrapper .gallery-slide img {
    width: 100%;
    height: 100%;
    /* --- MODIFICATION START --- */
    object-fit: cover; /* Default behavior: fill the container, cropping if necessary. */
    /* --- MODIFICATION END --- */
}

/* --- MODIFICATION START --- */
/* This new rule is applied by JavaScript to tall (portrait) images. */
/* It overrides the default `cover` behavior to show the full image. */
.main-image-wrapper .gallery-slide img.portrait-image {
    object-fit: contain;
}
/* --- MODIFICATION END --- */

.thumbnail-wrapper {
    width: 100%;
    max-width: 100%; /* Prevent overflow */
    overflow: hidden;
}

.thumbnail-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    /* Allows horizontal scrolling of thumbnails */
    scrollbar-width: none;
    /* Hide scrollbar for Firefox */
    padding: 4px 0; /* Add some padding for better touch targets */
}

.thumbnail-track::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for Chrome/Safari */
.thumbnail-item {
    flex: 0 0 80px;
    /* Fixed width for thumbnails */
    height: 80px;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s ease-in-out;
    opacity: 0.6;
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-item.active {
    border-color: var(--accent-primary);
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(36, 186, 217, 0.5);
}

/* ===================================== */
/* ======== 12. RESPONSIVE DESIGN ======== */
/* ===================================== */
.mobile-header,
.mobile-menu-button {
    display: none;
    /* Hidden by default */
}

/* Tablet-specific grid adjustment */
@media (min-width: 768px) and (max-width: 1199px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* General mobile styles */
@media (max-width: 1024px) {
    .shop-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 200;
        height: 100%;
        transition: left 0.3s ease-in-out;
        box-shadow: var(--shadow-md);
        width: 280px;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        padding: 24px;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        flex-direction: row-reverse; /* MODIFICATION: Swap logo and menu button */
    }

    .desktop-header {
        margin-top: 32px;
        margin-bottom: 32px;
        text-align: center;
    }

    .desktop-header h1 {
        font-size: 1.8em;
    }

    .desktop-header p {
        font-size: 1em;
    }

    .mobile-logo {
        font-size: 1.5em;
        font-weight: 700;
        color: var(--text-primary);
    }

    .mobile-logo span {
        color: var(--accent-primary);
    }

    .mobile-menu-button {
        display: flex; /* MODIFICATION: Use flex for alignment */
        align-items: center; /* MODIFICATION: Vertically align icon and text */
        gap: 8px; /* MODIFICATION: Space between icon and text */
        font-size: 1rem; /* MODIFICATION: Adjust font size */
        background: none;
        color: var(--text-primary);
        border: 1px solid var(--border-color); /* MODIFICATION: Add border */
        border-radius: 8px; /* MODIFICATION: Add border radius */
        cursor: pointer;
        padding: 8px 12px; /* MODIFICATION: Add padding */
        animation: pulse-glow 2.5s infinite; /* MODIFICATION: Add animation */
    }

    .hero-text-overlay {
        padding: 24px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 50%, rgba(0, 0, 0, 0) 100%);
    }

    .hero-text-overlay h1 {
        font-size: 2em;
    }

    .hero-text-overlay p {
        font-size: 0.9em;
    }

    .product-detail-grid {
        grid-template-columns: 1fr;
        /* Stack gallery and info on mobile */
        padding: 24px;
        gap: 24px;
        min-width: 0; /* Allow grid to shrink */
        width: 100%;
        max-width: 100%; /* Prevent overflow */
        box-sizing: border-box;
    }

    .product-gallery-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        /* Remove fixed aspect ratio on mobile for better flexibility */
    }

    .main-image-wrapper {
        aspect-ratio: 16 / 10; /* Slightly taller ratio for mobile */
        width: 100%;
        max-width: 100%;
    }

    /* Keep thumbnails are properly sized on mobile */
    .thumbnail-item {
        flex: 0 0 60px; /* Smaller thumbnails on mobile */
        height: 60px;
    }

    .contact-buttons-container {
        gap: 12px;
    }

    .contact-btn {
        padding: 14px;
        font-size: 1.1em;
    }

    .detail-info h1 {
        font-size: 2.2em;
    }

    .detail-info .price {
        font-size: 1.8em;
    }
}

/* Additional fix for very small screens */
@media (max-width: 480px) {
    .main-content {
        padding: 16px;
    }

    .product-detail-grid {
        padding: 16px;
        gap: 16px;
    }

    .main-image-wrapper {
        aspect-ratio: 1 / 1; /* Square ratio for very small screens */
    }

    .thumbnail-item {
        flex: 0 0 50px; /* Even smaller thumbnails */
        height: 50px;
    }

    .detail-info h1 {
        font-size: 1.8em;
    }

    .detail-info .price {
        font-size: 1.5em;
    }

    .site-footer {
        padding: 40px 24px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        /* Stack info and map on mobile */
        text-align: center;
    }

    .footer-info,
    .social-links {
        align-items: center;
        justify-content: center;
    }
}

/* ============================== */
/* ======== 13. ANIMATIONS ======== */
/* ============================== */
/* Initial state for elements to be animated */
.fade-in-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.215, 0.610, 0.355, 1), transform 0.8s cubic-bezier(0.215, 0.610, 0.355, 1);
}

/* Final state, applied by Intersection Observer */
.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
}

/* MODIFICATION: New keyframe animation for the menu button */
@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(36, 186, 217, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(36, 186, 217, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(36, 186, 217, 0);
    }
}