/* ========================================================
   CART & CHECKOUT CSS (cart.html & checkout.html)
   ======================================================== */

.cart-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 25px;
  margin: 25px 0 50px;
  align-items: start;
}

.cart-table-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#cart-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.cart-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 600px;
}

.cart-table th {
  padding: 12px 10px;
  border-bottom: 2px solid #f1f5f9;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.cart-table th.th-product {
  text-align: left;
  padding-left: 0;
  width: 44%;
}
.cart-table th.th-price {
  text-align: center;
  width: 18%;
}
.cart-table th.th-qty {
  text-align: center;
  width: 18%;
}
.cart-table th.th-total {
  text-align: right;
  width: 16%;
}
.cart-table th.th-action {
  width: 4%;
  padding-right: 0;
}

.cart-table td {
  padding: 18px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.cart-table td.col-product {
  padding-left: 0;
}

.cart-table td.col-price {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: #1e293b;
  white-space: nowrap;
}

.cart-table td.col-qty {
  text-align: center;
}

.cart-table td.col-total {
  text-align: right;
  font-weight: 800;
  font-size: 15px;
  color: var(--primary-color, #f35478);
  white-space: nowrap;
}

.cart-table td.col-action {
  text-align: center;
  padding-right: 0;
}

/* Product Info Cell */
.cart-item-cell {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cart-item-thumb {
  width: 76px;
  height: 76px;
  min-width: 76px;
  max-width: 76px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 4px;
  background: #ffffff;
  object-fit: contain;
  flex-shrink: 0;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  text-decoration: none;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  transition: color 0.15s ease;
}

.cart-item-title:hover {
  color: var(--primary-color, #f35478);
}

.cart-item-variant {
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 2px;
}

/* Quantity Controller */
.cart-table .quantity-controller {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cart-table .btn-qty {
  width: 30px;
  height: 30px;
  background: #f8fafc;
  border: none;
  color: #475569;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.cart-table .btn-qty:hover {
  background: #f1f5f9;
  color: var(--primary-color, #f35478);
}

.cart-table .input-qty {
  width: 38px;
  height: 30px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
  border: none;
  border-left: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  background: #ffffff;
  outline: none;
  padding: 0;
}

/* Remove Button */
.btn-cart-remove {
  width: 28px;
  height: 28px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-cart-remove:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #ef4444;
}

/* Cart Footer Actions */
.cart-table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-cart-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-cart-back:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-cart-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #ef4444;
  background: #ffffff;
  border: 1px solid #fecaca;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cart-clear:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Order Summary Box & Items */
.order-summary-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  height: fit-content;
}

.summary-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  padding-bottom: 12px;
  border-bottom: 1.5px solid #f1f5f9;
  margin-bottom: 16px;
}

/* Mini Order Items List */
.mini-order-items {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 4px;
}

.mini-order-items::-webkit-scrollbar {
  width: 4px;
}

.mini-order-items::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.mini-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.mini-item-row:last-child {
  border-bottom: none;
}

.mini-item-thumb-wrapper {
  position: relative;
  width: 58px;
  height: 58px;
  min-width: 58px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mini-item-thumb {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 5px;
}

.mini-item-qty {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--primary-color, #e11d48);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 2;
}

.mini-item-info {
  flex: 1;
  min-width: 0;
}

.mini-item-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 3px 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini-item-price {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.mini-item-total {
  font-weight: 700;
  font-size: 13.5px;
  color: #1e293b;
  white-space: nowrap;
}

/* Voucher Code Box */
.voucher-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.voucher-box input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s ease;
}

.voucher-box input:focus {
  border-color: var(--primary-color, #2563eb);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.btn-apply-voucher {
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.btn-apply-voucher:hover {
  background: #1e293b;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: #555;
  margin-bottom: 12px;
}

.summary-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 800;
  color: var(--price-color);
  border-top: 1.5px dashed #eee;
  padding-top: 14px;
  margin-top: 14px;
  margin-bottom: 20px;
}

/* Checkout Form Layout */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 30px;
  margin: 25px 0 50px;
}

.form-group-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.form-title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-title i {
  color: var(--primary-color);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.form-field input, .form-field select, .form-field textarea {
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  background: #fafbfc;
  font-size: 13.5px;
  color: #333;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--primary-color);
  background: #fff;
}

/* Payment Method Selection */
.payment-methods-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.payment-method-option {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s ease;
  background: #ffffff;
}

.payment-method-option:hover {
  border-color: #cbd5e1;
  background: #fafbfc;
}

.payment-method-option.active {
  border-color: var(--primary-color, #2563eb);
  background: #f0f7ff;
  box-shadow: 0 0 0 1px var(--primary-color, #2563eb);
}

.payment-method-option input[type="radio"] {
  accent-color: var(--primary-color, #2563eb);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.payment-option-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.payment-icon-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.payment-text strong {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  display: block;
  margin-bottom: 2px;
}

.payment-text p {
  font-size: 12.5px;
  color: #64748b;
  margin: 0;
  line-height: 1.35;
}

.sepay-qr-preview-box {
  background: #fff;
  border: 1px solid #ffd8e2;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 14px;
  text-align: center;
}

.sepay-qr-code {
  width: 180px;
  height: 180px;
  margin: 12px auto;
  border: 1px solid #eee;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: #fff;
}

.sepay-qr-code img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sepay-bank-details {
  background: #fdf2f4;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  color: #444;
  text-align: left;
  line-height: 1.6;
}

.sepay-bank-details strong {
  color: #111;
}

@media (max-width: 992px) {
  .cart-layout, .checkout-layout {
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 15px 0 35px;
  }
}

/* ========================================================
   RESPONSIVE CHO TRANG GIỎ HÀNG (MOBILE & TABLET <= 768px)
   Chuyển bảng table truyền thống sang dạng Card Item hiện đại
   ======================================================== */
@media (max-width: 768px) {
  .cart-table-card {
    padding: 16px;
    border-radius: 12px;
  }

  .cart-table-card h2#cart-title {
    font-size: 16px !important;
    margin-bottom: 14px !important;
  }

  /* Ẩn tiêu đề thead trên mobile */
  .cart-table thead {
    display: none;
  }

  .cart-table,
  .cart-table tbody,
  .cart-table tr,
  .cart-table td {
    display: block;
    width: 100%;
    min-width: unset;
  }

  /* Mỗi sản phẩm trong giỏ biến thành 1 Card Item dạng Flexbox rõ ràng */
  .cart-table tbody tr {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    border-bottom: 1px dashed #e2e8f0;
    position: relative;
    gap: 12px;
  }

  .cart-table tbody tr:last-child {
    border-bottom: none;
  }

  .cart-table td {
    padding: 0 !important;
    border: none !important;
    display: block !important;
    width: 100% !important;
  }

  /* Ẩn cột đơn giá riêng lẻ trên mobile */
  .cart-table td.col-price {
    display: none !important;
  }

  /* 1. Phần Sản phẩm: Ảnh + Tên + Phân loại */
  .cart-table td.col-product {
    width: 100% !important;
  }

  .cart-item-cell {
    display: flex !important;
    align-items: flex-start;
    gap: 14px;
    padding-right: 32px; /* Chừa chỗ cho nút xoá ở góc phải */
  }

  .cart-item-thumb {
    width: 72px;
    height: 72px;
    min-width: 72px;
    max-width: 72px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 4px;
    background: #fff;
    object-fit: contain;
    flex-shrink: 0;
  }

  .cart-item-info {
    flex: 1;
    min-width: 0;
  }

  .cart-item-title {
    font-size: 13.5px;
    line-height: 1.4;
    margin-bottom: 4px;
    font-weight: 700;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .cart-item-variant {
    font-size: 11px;
    padding: 2px 7px;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 4px;
    display: inline-block;
  }

  /* 2. Hàng bên dưới: Cụm Tăng giảm số lượng (Trái) & Thành tiền (Phải) */
  .cart-table td.col-qty {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100% !important;
    padding-left: 86px !important; /* Thẳng hàng với phần text cạnh ảnh 72px + 14px gap */
    box-sizing: border-box;
  }

  .cart-table .quantity-controller {
    height: 30px;
    display: inline-flex;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
  }

  .cart-table .btn-qty {
    width: 28px;
    height: 28px;
    font-size: 13px;
    background: #f8fafc;
  }

  .cart-table .input-qty {
    width: 32px;
    height: 28px;
    font-size: 12.5px;
  }

  .cart-table .mobile-item-total {
    display: inline-block !important;
    font-size: 15px;
    font-weight: 800;
    color: var(--primary-color, #f35478);
  }

  /* 3. Thành tiền nằm cùng hàng số lượng */
  .cart-table td.col-total {
    display: none !important; /* Đã hiển thị cạnh quantity controller */
  }

  /* 4. Nút xoá sản phẩm đặt ở góc trên bên phải */
  .cart-table td.col-action {
    position: absolute;
    top: 14px;
    right: 0;
    width: auto !important;
    display: block !important;
  }

  .btn-cart-remove {
    width: 26px;
    height: 26px;
    font-size: 11px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #94a3b8;
  }

  /* Cart Footer trên Mobile */
  .cart-table-footer {
    flex-direction: column-reverse;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
  }

  .btn-cart-back,
  .btn-cart-clear {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 13px;
  }

  /* Order Summary Card trên Mobile */
  .order-summary-card {
    padding: 18px 16px;
    border-radius: 12px;
  }

  .summary-title {
    font-size: 16px;
    margin-bottom: 14px;
  }

  .summary-row {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .summary-total-row {
    margin-top: 14px;
    padding-top: 14px;
  }

  .summary-total-row span:last-child {
    font-size: 18px;
  }

  .btn-cta-addcart {
    padding: 13px 0 !important;
    font-size: 14px !important;
    border-radius: 30px !important;
  }
}
