/* modules/shopfront.css
 * Shared shopfront UI (product card grid/list + carousel + add-to-cart controls).
 *
 * Owner: this file.
 * Sources: moved from pages/main.css, pages/customer.css, pages/all_products.css, pages/gbuy_list.css.
 *
 * Loaded automatically by templates/header.php for page keys:
 * - main, customer, all_products, gbuy_list
 */


/* ---- migrated from static/css/style.css (product + carousel) ---- */
/*------------------ 商品樣式 ------------------*/

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
    /*
    max-width: 200px;
    */
}

.product {
    background-color: #dbebfd;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: box-shadow 0.3s ease;

}

.product p {
    margin-top: 5px;
    margin-bottom: 5px;
    text-align: left;

}

.product-title {
    font-weight: bold;
    font-size: 1.2rem;
    color: #126196;
    margin-bottom: 0.3rem;
}

.product-meta {
    font-size: 0.85rem;
    color: #444;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
}

.product-meta span {
    display: flex;
    min-width: 100%;
    margin: auto;
}

.product-price {
    color: #c39100;
    font-weight: bold;
    font-size: 1.0rem;
}

.product-content {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px dashed #999999;
}

.product:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.product img {
    width: 100%;
    max-width: 100px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.product img,
.carousel-slide img {
    /* 
  width: 100%;
  height: auto;
  */
    object-fit: cover;
    aspect-ratio: 1 / 1;
    /* 或改為 4 / 3、3 / 2 視需求 */
    max-width: 50%;
    border-radius: 8px;
    cursor: pointer;
}

.product img:hover {
    transform: scale(1.5);
    transition: transform 0.3s ease-in-out;
}

.product-title {
    line-height: 1.2;
    /* 行距較小 */
    margin-bottom: 0.5em;
    /* 底部間距可視需求調整 */
}

.product-title h3,
.product-title .product-code {
    margin: 0;
    /* 移除預設外距 */
    display: block;
    /* 確保換行 */
}

/* addtocart setting */
.addtocart {
    background-color: #146ca7;
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 1em;
    border-radius: 5px;
    cursor: pointer;
    width: auto;
    height: 40px;
    margin-top: 10px;
}

.addtocart:hover {
    background-color: #0b3f61;
    transition: background-color 0.3s ease;
}

.addtocart-dis {
    background-color: #aaa;
    color: rgb(192, 0, 0);
    border: none;
    padding: 5px 20px;
    font-size: 1em;
    border-radius: 5px;
    width: auto;
    height: 40px;
    margin-top: 10px;
}


.addtocart-input {
    margin: 10px 5px;
    width: 70px;
    font-size: 15px;
    padding: 10px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 6px;

}

.carousel {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 900px;
    margin: auto;
}

.carousel-slides {
    display: flex;
    transition: transform 0.5s ease-in-out;
    width: 100%;
}

.carousel-slide {
    flex-shrink: 0;
    width: 100%;
    text-align: center;
}

.carousel-slide img {
    width: 250px;
    border-radius: 8px;
}

.carousel-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    /* 微透明黑底 */
    color: #fff;
    border: 0px solid rgba(255, 255, 255, 0.5);
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
    user-select: none;
    backdrop-filter: blur(4px);
    /* 毛玻璃背景效果 */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.carousel-button:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-50%) scale(1.1);
    /* 微縮放效果 */
}

.carousel-button.prev {
    left: 5px;
    /* 拉出一點點邊框外 */
}

.carousel-button.next {
    right: 5px;
}

/* =============== 商品列表（前台） =============== */
@media (max-width: 768px) {
  .product-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .product {
    display: flex;
    flex-direction: row;
    border: 1px solid #ccc;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    padding-top: 10px;
  }

  .carousel {
    width: 100%;
    position: relative;
    overflow: hidden;
  }

  .carousel-slides {
    display: flex;
  }

  .carousel-slide {
    margin: auto;
  }

  .carousel-slide img {
    object-fit: scale-down;
    overflow: hidden;
    transform: scale(1.5);
    padding: 0 0px;
  }

  .carousel-slide img:hover {
    transform: scale(1.8);
    transition: transform 0.3s ease-in-out;
  }

  .carousel-button.prev {
    left: -5px;
  }

  .carousel-button.next {
    right: -5px;
  }

  /* 提升手機點擊面積 */
  .addtocart,
  .addtocart-dis {
    padding: 10px 12px;
    font-size: 1em;
  }
}
