/**
 * Module 08 : Panier latéral (drawer)
 *
 * Panneau qui glisse depuis la droite au clic sur l'icône panier.
 * Complète 02-header-footer.css (icône + badge) et inc/cart-drawer.php (balisage).
 */

.tma-cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
}

.tma-cart-drawer.is-open {
  display: block;
}

.tma-cart-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.tma-cart-drawer.is-open .tma-cart-drawer-overlay {
  opacity: 1;
}

.tma-cart-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 400px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  outline: none;
}

.tma-cart-drawer.is-open .tma-cart-drawer-panel {
  transform: translateX(0);
}

.tma-cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
  flex-shrink: 0;
}

.tma-cart-drawer-title {
  margin: 0 !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  color: var(--agri-anthracite-base, #1e2322);
}

.tma-cart-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
  padding: 0.25rem !important;
  cursor: pointer;
  color: #6b7280 !important;
  transition: color 0.15s ease;
}

.tma-cart-drawer-close:hover {
  color: var(--agri-green-primary, #215833) !important;
}

/* --- Contenu : widget panier WooCommerce --- */

.tma-cart-drawer-inner {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.35rem;
}

.tma-cart-drawer-inner .widget_shopping_cart_content {
  font-size: 0.95rem;
}

.tma-cart-drawer-inner .cart_list,
.tma-cart-drawer-inner .woocommerce-mini-cart {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.tma-cart-drawer-inner .woocommerce-mini-cart-item,
.tma-cart-drawer-inner .cart_list li {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 0 0.85rem 0;
  margin: 0 !important;
  border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
}

.tma-cart-drawer-inner .woocommerce-mini-cart-item img,
.tma-cart-drawer-inner .cart_list li img {
  width: 56px !important;
  height: 56px !important;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  margin: 0 !important;
}

.tma-cart-drawer-inner .woocommerce-mini-cart-item a,
.tma-cart-drawer-inner .cart_list li a {
  color: var(--agri-anthracite-base, #1e2322);
  text-decoration: none !important;
  font-weight: 600;
  line-height: 1.35;
}

.tma-cart-drawer-inner .woocommerce-mini-cart-item a:hover,
.tma-cart-drawer-inner .cart_list li a:hover {
  color: var(--agri-green-primary, #215833);
}

.tma-cart-drawer-inner .quantity {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--agri-anthracite-muted, #525c59);
}

.tma-cart-drawer-inner .woocommerce-mini-cart-item .remove,
.tma-cart-drawer-inner .cart_list li .remove {
  position: absolute;
  top: 0.7rem;
  right: 0;
  width: 20px;
  height: 20px;
  line-height: 18px !important;
  text-align: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06) !important;
  color: #4b5563 !important;
  font-size: 0.95rem !important;
  text-decoration: none !important;
}

.tma-cart-drawer-inner .woocommerce-mini-cart-item .remove:hover,
.tma-cart-drawer-inner .cart_list li .remove:hover {
  background: #dc2626 !important;
  color: #ffffff !important;
}

.tma-cart-drawer-inner .woocommerce-mini-cart__total,
.tma-cart-drawer-inner .total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 !important;
  padding: 1rem 0 !important;
  border-top: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-bottom: none !important;
  font-size: 1rem;
  font-weight: 700;
  color: var(--agri-anthracite-base, #1e2322);
}

.tma-cart-drawer-inner .woocommerce-mini-cart__empty-message,
.tma-cart-drawer-inner .cart-empty {
  margin: 0 !important;
  padding: 2rem 0 !important;
  text-align: center;
  color: var(--agri-anthracite-muted, #525c59);
  font-size: 0.95rem;
  border: none !important;
  background: none !important;
}

/* Les boutons WooCommerce du widget sont remplacés par les CTA du module. */
.tma-cart-drawer-inner .woocommerce-mini-cart__buttons {
  display: none !important;
}

/* --- Actions --- */

.tma-cart-drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.tma-drawer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tma-drawer-btn-primary {
  background-color: var(--agri-green-primary, #215833);
  color: #ffffff !important;
}

.tma-drawer-btn-primary:hover {
  background-color: var(--agri-green-dark, #163e23);
  color: #ffffff !important;
}

.tma-drawer-btn-secondary {
  background-color: #f3f4f6;
  color: var(--agri-anthracite-base, #1e2322) !important;
}

.tma-drawer-btn-secondary:hover {
  background-color: #e5e7eb;
}

.tma-cart-drawer-footer {
  flex-shrink: 0;
  padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--agri-border-subtle, #e2e8f0);
  text-align: center;
}

.tma-cart-drawer-hint {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--agri-green-primary, #215833);
  text-decoration: none !important;
}

.tma-cart-drawer-hint:hover {
  text-decoration: underline !important;
}

/* --- Verrouillage du défilement arrière-plan --- */

body.tma-cart-drawer-open {
  overflow: hidden;
}

/* --- Mobile --- */

@media (max-width: 576px) {
  .tma-cart-drawer-panel {
    width: 100%;
    max-width: 100%;
  }
  .tma-cart-drawer-inner {
    padding: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tma-cart-drawer-panel,
  .tma-cart-drawer-overlay {
    transition: none;
  }
}
