/* ============================================================
   DSI FRANCE — Cart Sidebar Drawer
   Slide-in cart panel with real-time qty management
   ============================================================ */

/* ── Variables ── */
:root {
  --cs-width:        420px;
  --cs-bg:           #ffffff;
  --cs-head-bg:      #1a1f2e;
  --cs-head-color:   #ffffff;
  --cs-backdrop:     rgba(10, 15, 30, 0.6);
  --cs-border:       #e5e7eb;
  --cs-primary:      #0055a4;
  --cs-primary-h:    #003f80;
  --cs-danger:       #dc2626;
  --cs-danger-bg:    #fee2e2;
  --cs-z:            9990;
  --cs-ease:         0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset for sidebar children ── */
.dsi-cart-overlay *,
.dsi-cart-overlay *::before,
.dsi-cart-overlay *::after {
  box-sizing: border-box;
}

/* ── Backdrop ── */
.dsi-cart-backdrop {
  position: fixed;
  inset: 0;
  background: var(--cs-backdrop);
  z-index: var(--cs-z);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--cs-ease);
}

/* ── Sidebar panel ── */
.dsi-cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  height: 100vh; /* fallback */
  width: var(--cs-width);
  max-width: 100vw;
  z-index: calc(var(--cs-z) + 1);
  display: flex;
  flex-direction: column;
  background: var(--cs-bg);
  box-shadow: -6px 0 40px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform var(--cs-ease);
  border-left: 1px solid var(--cs-border);
}

/* ── Open state ── */
body.dsi-cart-open .dsi-cart-backdrop {
  opacity: 1;
  pointer-events: auto;
}
body.dsi-cart-open .dsi-cart-panel {
  transform: translateX(0);
}

/* ── Header ── */
.dsi-cart-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--cs-head-bg);
  color: var(--cs-head-color);
  flex-shrink: 0;
  gap: 0.5rem;
}

.dsi-cart-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: inherit;
}

.dsi-cart-panel-title .material-icons {
  font-size: 20px;
}

.dsi-cart-panel-count {
  background: rgba(255, 255, 255, 0.15);
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.dsi-cart-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}
.dsi-cart-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.dsi-cart-close .material-icons { font-size: 20px; }

/* ── Body (scrollable) ── */
.dsi-cart-panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
}

/* scrollbar */
.dsi-cart-panel-body::-webkit-scrollbar { width: 4px; }
.dsi-cart-panel-body::-webkit-scrollbar-track { background: transparent; }
.dsi-cart-panel-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Product list ── */
.dsi-cart-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dsi-cart-item-row {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--cs-border);
  transition: background 0.15s;
}
.dsi-cart-item-row:hover { background: #fafafa; }

/* ── Product item layout ── */
.dsi-cart-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.dsi-cart-item-img-link {
  flex-shrink: 0;
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--cs-border);
  width: 64px;
  height: 64px;
}
.dsi-cart-item-img-link img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  display: block;
}

.dsi-cart-item-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dsi-cart-item-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: #1a1f2e;
  text-decoration: none;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dsi-cart-item-name:hover { color: var(--cs-primary); text-decoration: none; }

.dsi-cart-item-attrs {
  font-size: 0.73rem;
  color: #6b7280;
  line-height: 1.3;
}

/* row2: qty + price */
.dsi-cart-item-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

/* ── Qty controls ── */
.dsi-qty-ctrl {
  display: flex;
  align-items: stretch;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  overflow: hidden;
  height: 28px;
}

.dsi-qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  background: #f3f4f6;
  color: #374151;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.dsi-qty-btn:hover {
  background: #e5e7eb;
  color: #111;
  text-decoration: none;
}
.dsi-qty-btn .material-icons { font-size: 14px; line-height: 1; }

.dsi-qty-num {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 100%;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1a1f2e;
  padding: 0 0.4rem;
  background: #fff;
  border-left: 1px solid #d1d5db;
  border-right: 1px solid #d1d5db;
  user-select: none;
}

.dsi-cart-item-price {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1a1f2e;
  white-space: nowrap;
}

/* ── Delete button ── */
.dsi-cart-item-del {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #9ca3af;
  border-radius: 6px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.dsi-cart-item-del:hover {
  color: var(--cs-danger);
  background: var(--cs-danger-bg);
  text-decoration: none;
}
.dsi-cart-item-del .material-icons { font-size: 17px; }

/* ── Customizations ── */
.dsi-cart-item-customizations {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--cs-border);
  font-size: 0.75rem;
  color: #6b7280;
}

/* ── Empty state ── */
.dsi-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: #9ca3af;
}
.dsi-cart-empty .material-icons {
  font-size: 52px;
  color: #d1d5db;
  margin-bottom: 1rem;
}
.dsi-cart-empty p {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: #6b7280;
}
.dsi-cart-empty-sub {
  font-size: 0.78rem !important;
  color: #9ca3af !important;
}

/* ── Footer ── */
.dsi-cart-panel-foot {
  flex-shrink: 0;
  border-top: 2px solid var(--cs-border);
  background: #fff;
  padding: 1rem 1.25rem 1.25rem;
}

.dsi-cart-totals { margin-bottom: 0.75rem; }

.dsi-cart-total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0;
  font-size: 0.82rem;
  color: #6b7280;
}

.dsi-cart-grand-total {
  padding-top: 0.55rem;
  margin-top: 0.55rem;
  border-top: 1px solid var(--cs-border);
}
.dsi-cart-grand-total .dsi-cart-total-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1f2e;
}
.dsi-cart-grand-total .dsi-cart-total-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1f2e;
}

/* ── Action buttons ── */
.dsi-cart-panel-btns {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.dsi-cart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.72rem 1rem;
  border-radius: 9px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  cursor: pointer;
  border: none;
  line-height: 1;
}
.dsi-cart-btn .material-icons { font-size: 17px; }

.dsi-cart-btn-primary {
  background: var(--cs-primary);
  color: #fff;
}
.dsi-cart-btn-primary:hover {
  background: var(--cs-primary-h);
  color: #fff;
  text-decoration: none;
}

.dsi-cart-btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}
.dsi-cart-btn-secondary:hover {
  background: #e5e7eb;
  color: #1a1f2e;
  text-decoration: none;
}

/* ── Trigger button (nav) ── */
.dsi-cart-trigger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  outline: none;
}

/* ── Loading state for qty buttons ── */
.dsi-qty-btn.loading {
  pointer-events: none;
  opacity: 0.45;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  :root { --cs-width: 100vw; }
  .dsi-cart-panel { border-radius: 0; border-left: none; }
}
