/* ================================================
   1. RESET & GLOBAL STYLES - ตั้งค่าพื้นฐานทั่วไป
   ================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.logo {
    font-weight: normal;
}

.logo h1 {
    font-size: 30px;
}

/* Container พื้นฐาน */
.container,
.container-lg,
.container-md,
.container-sm,
.container-xl,
.container-xxl {
    max-width: 1380px;
    padding: 0;
    overflow: hidden;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ================================================
   2. NAVIGATION BAR - เมนูหลักส่วนบน
   ================================================ */

/* พื้นหลัง navbar */
.custom-navbar {
    background-color: rgb(243, 243, 243);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
    padding: 0.5rem;
}

/* ลิงค์ใน navbar */
.navbar-nav .nav-link {
    color: #818181 !important;
    font-weight: bolder;
    padding: 0.75rem 1.5rem !important;
    transition: all 0.3s ease;
    border-radius: 5px;
    margin: 0 0.2rem;
    font-size: 1rem;
}

/* เอฟเฟกต์ hover สำหรับลิงค์ */
.navbar-nav .nav-link:hover {
    transform: translateY(-2px);
}

/* สถานะ active ของลิงค์ */
.navbar-nav .nav-link.active {
    color: rgb(54, 54, 54) !important;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-decoration-color: rgb(121, 121, 121);
    text-underline-offset: 4px;
}

/* ปุ่มด้านขวา navbar */
.auth-buttons button {
    margin: 0 0.3rem;
    border-radius: 50%;
    padding: 0.75rem;
    font-weight: 500;
    border: 1px solid #5f5f5f;
    transition: all 0.3s ease;
    background-color: #dddddd;
    color: rgb(53, 53, 53);
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 5px #333;
}

/* เอฟเฟกต์ hover สำหรับปุ่ม */
.auth-buttons button:hover {
    background-color: #a7a7a7;
    transform: translateY(-3px);
}

/* ================================================
   3. MOBILE MENU BOTTOM - เมนูล่างสำหรับมือถือ
   ================================================ */

/* พื้นหลัง mobile menu */
#mobile-menubar {
    left: 0;
    right: 0;
    bottom: 0;
    position: fixed;
    height: 70px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 999;
    animation: slideUpMenu 0.5s ease-out;
    backdrop-filter: blur(10px);
}

/* Animation เมื่อโหลด menu */
@keyframes slideUpMenu {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

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

/* Container หลักของ menu items */
.mobile-menu-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    padding: 8px 12px;
}

/* แต่ละ item ใน menu */
.mobile-menu-item {
    flex: 1;
    text-align: center;
    position: relative;
}

/* Link ของแต่ละ menu */
.mobile-menu-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6c757d;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 8px 4px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

/* เอฟเฟกต์ hover และ active สำหรับ mobile menu */
.mobile-menu-link:hover,
.mobile-menu-link.active {
    color: #007bff;
    background: rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

/* Icon container */
.menu-icon {
    font-size: 20px;
    margin-bottom: 4px;
    transition: transform 0.3s ease;
}

/* เอฟเฟกต์ icon เมื่อ hover */
.mobile-menu-link:hover .menu-icon {
    transform: scale(1.1);
}

/* ข้อความใต้ icon */
.menu-text {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

/* เอฟเฟกต์ ripple เมื่อกด */
.mobile-menu-link::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    background: rgba(0, 123, 255, 0.3);
    border-radius: 50%;
    transition: width 0.6s, height 0.6s;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
}

.mobile-menu-link:active::before {
    width: 100px;
    height: 100px;
}

/* เอฟเฟกต์ active state */
.mobile-menu-link.active::after {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: #007bff;
    border-radius: 0 0 3px 3px;
}

.mobile-menu-link:hover {
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

/* ================================================
   4. CART BADGE - ป้ายแสดงจำนวนในตะกร้า
   ================================================ */

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    line-height: 12px;
    text-align: center;
    text-transform: uppercase;
    z-index: 10;
    border: 1px solid white;
    padding: 3px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* แสดง badge เมื่อมีสินค้า */
.cart-badge.show {
    transform: scale(1);
}

/* เอฟเฟกต์กระเพื่อม */
.cart-badge.pulse {
    animation: cartPulse 0.6s ease-out;
}

@keyframes cartPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        background: #28a745;
    }

    100% {
        transform: scale(1);
    }
}

/* เอฟเฟกต์ตะกร้าสั่น */
.mobile-menu-link:hover .fa-shopping-cart {
    animation: cartShake 0.5s ease-in-out;
}

@keyframes cartShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

/* ตะกร้าว่าง */
.cart-badge.empty {
    background: #6c757d;
    transform: scale(0);
}

/* ปรับตำแหน่ง icon container สำหรับตะกร้า */
.mobile-menu-item:nth-child(4) .menu-icon {
    position: relative;
}

/* ================================================
   5. CAROUSEL & BANNER - ส่วนสไลด์และแบนเนอร์
   ================================================ */

/* สไลด์รูป banner */
#BannerSection img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#BannerSection img:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s ease;
}

#carousel {
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
    /* เพิ่ม cursor pointer เพื่อแสดงว่าสามารถปัดได้ */
    cursor: grab;
    /* ป้องกันการเลือกข้อความเมื่อลาก */
    user-select: none;
}

/* เปลี่ยน cursor เมื่อกำลังปัด */
#carousel:active {
    cursor: grabbing;
}

/* สไตล์ indicators ของ carousel */
#carousel .carousel-indicators [data-bs-target] {
    box-sizing: content-box;
    flex: 0 1 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    margin-right: 10px;
    margin-left: 10px;
    text-indent: -999px;
    cursor: pointer;
    background-color: var(--bs-carousel-indicator-active-bg);
    background-clip: padding-box;
    border: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-radius: 50%;
    opacity: .5;
    transition: opacity .6s ease;
}

#carousel .carousel-indicators [data-bs-target].active {
    background-color: aquamarine;
}

/* ================================================
   6. PRODUCT SECTIONS - ส่วนแสดงสินค้า
   ================================================ */

/* Countdown timer */
.countdown-box {
    min-width: 50px;
    cursor: context-menu;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.countdown-number {
    font-size: 18px;
    line-height: 1;
}

.countdown-label {
    font-size: 10px;
    line-height: 1;
}

/* การ์ดสินค้า */
.product-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card:hover {
    transform: translateY(-3px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* ให้ card มีความสูงเท่ากัน */
.product-slide-item .card,
.product-grid-desktop .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-slide-item .card-body,
.product-grid-desktop .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* กำหนดความสูงคงที่สำหรับชื่อสินค้า */
.product-slide-item .card-body h6,
.product-grid-desktop .card-body h6 {
    font-size: 12px;
    line-height: 1.3;
    height: 48px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    margin-bottom: auto;
}

/* ส่วนราคาและปุ่ม */
.product-slide-item .price-section,
.product-grid-desktop .price-section {
    margin-top: auto;
}

.product-slide-item .button-section,
.product-grid-desktop .button-section {
    margin-top: 8px;
}

/* ================================================
   7. PRODUCT SLIDER MOBILE - สไลด์สินค้าสำหรับมือถือ
   ================================================ */

.product-slider-container {
    position: relative;
    overflow: hidden;
}

.product-slider-wrapper {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.product-slider-wrapper::-webkit-scrollbar {
    display: none;
}

.product-slide-track {
    display: flex;
    gap: 15px;
    transition: transform 0.3s ease;
    padding: 10px 5px;
}

.product-slide-item {
    flex: 0 0 calc(50% - 7.5px);
    max-width: calc(50% - 7.5px);
}

/* ปุ่มลูกศรสำหรับสไลด์ */
.product-slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.product-slider-btn:hover:not(.disabled) {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.product-slider-btn.disabled {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) scale(0.8);
}

.product-slider-btn.prev {
    left: 5px;
}

.product-slider-btn.next {
    right: 5px;
}

/* จุดบอกตำแหน่ง slide */
.product-slider-dots {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    margin-top: 15px !important;
    width: 100% !important;
    text-align: center !important;
}

.product-slider-dot {
    display: inline-block !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: #ccc !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.product-slider-dot.active {
    background: #007bff !important;
    transform: scale(1.2) !important;
}

/* ================================================
   8. FAVORITE BUTTONS - ปุ่มหัวใจรายการโปรด
   ================================================ */
.btn-favorite {
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* default */
.btn-favorite .bi-heart {
  font-size: 28px;
}

.btn-favorite .bi-heart-fill {
  display: none;
  font-size: 28px;
}

/* active */
.btn-favorite.active .bi-heart {
  display: none;
}

.btn-favorite.active .bi-heart-fill {
  display: inline;
  color: #dc3545;
}

/* animation */
.btn-favorite.animate {
  animation: pop 0.3s ease;
}

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}




/* ================================================
   9. FOOTER - ส่วนท้ายเว็บไซต์
   ================================================ */

footer {
    margin-top: .5rem;
    margin-bottom: 0;
}

footer ul {
    padding: 0;
    margin: 0;
}

footer ul li {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ================================================
   10. RESPONSIVE DESIGN - การตอบสนองหน้าจอ
   ================================================ */

/* หน้าจอมือถือ */
@media (max-width: 991.98px) {

    /* Navbar responsive */
    .auth-buttons {
        margin-top: 1rem;
        text-align: center;
    }

    .navbar-nav .nav-link {
        text-align: center;
        margin: 0.2rem 0;
    }

    /* ซ่อน carousel indicators */
    #carousel .carousel-indicators {
        display: none !important;
    }

    /* Footer spacing สำหรับ mobile menu */
    footer {
        margin-bottom: 80px;
    }

    /* ซ่อน desktop grid แสดง mobile slider */
    .product-grid-desktop {
        display: none !important;
    }

    /* ซ่อน slider controls และ dots */
    .product-slider-container,
    .product-slider-btn,
    .product-slider-dots {
        display: block;
    }
}

/* หน้าจอใหญ่ */
@media (min-width: 992px) {

    /* ซ่อน mobile slider แสดง desktop grid */
    .product-slider-mobile {
        display: none !important;
    }

    .product-slider-container,
    .product-slider-btn,
    .product-slider-dots {
        display: none !important;
    }
}

/* หน้าจอเล็กมาก */
@media (max-width: 375px) {
    .menu-text {
        font-size: 10px;
    }

    .menu-icon {
        font-size: 18px;
    }

    #mobile-menubar {
        height: 65px;
    }
}