#checkout-modal {
  position: fixed;
  inset: 0;
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
#checkout-modal.open {
  opacity: 1;
  pointer-events: all;
}

.checkout-box {
  background: var(--card-bg);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  overflow-y: auto;
  transform: scale(0.93) translateY(16px);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-xl);
}
#checkout-modal.open .checkout-box {
  transform: scale(1) translateY(0);
}

.checkout-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card-bg, #fff);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}
.checkout-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}
.checkout-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--fg-muted);
  border: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.checkout-close:hover { background: var(--accent); color: var(--white); }

.checkout-body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
}

.checkout-form-side {
  padding: 28px;
  border-right: 1px solid var(--border);
}

.form-section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 16px;
  margin-top: 24px;
}
.form-section-title:first-child { margin-top: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.form-field.full { grid-column: 1 / -1; }

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg);
}
.form-label .req { color: var(--red); }

.form-input,
.form-select,
.form-textarea {
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  color: var(--fg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}
.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255,58,58,0.15);
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-error-msg {
  font-size: 0.72rem;
  color: var(--red);
  font-weight: 500;
  display: none;
}
.form-error-msg.show { display: block; }

.cod-banner-box {
  background: rgba(37, 211, 102, 0.09);
  border: 1.5px solid rgba(37, 211, 102, 0.35);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 16px;
  margin-bottom: 8px;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}

.cod-banner-icon {
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
}

.cod-banner-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #15803d;
  margin-bottom: 3px;
}

.cod-banner-desc {
  font-size: 0.82rem;
  color: #166534;
  line-height: 1.45;
  font-weight: 500;
}

[data-theme="light"] .cod-banner-box,
body:not(.dark) .cod-banner-box {
  background: #f0fdf4;
  border-color: #86efac;
}

[data-theme="light"] .cod-banner-title,
body:not(.dark) .cod-banner-title {
  color: #15803d;
}

[data-theme="light"] .cod-banner-desc,
body:not(.dark) .cod-banner-desc {
  color: #166534;
  font-weight: 500;
}

[data-theme="light"] .cod-banner-icon svg,
body:not(.dark) .cod-banner-icon svg {
  stroke: #16a34a;
}

[data-theme="dark"] .cod-banner-box,
body.dark .cod-banner-box {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}

[data-theme="dark"] .cod-banner-title,
body.dark .cod-banner-title {
  color: #4ade80;
}

[data-theme="dark"] .cod-banner-desc,
body.dark .cod-banner-desc {
  color: #dcfce7;
  font-weight: 400;
}

[data-theme="dark"] .cod-banner-icon svg,
body.dark .cod-banner-icon svg {
  stroke: #4ade80;
}

#checkout-submit {
  width: 100%;
  padding: 14px;
  border-radius: var(--r);
  background: var(--accent);
  color: var(--white);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  margin-top: 20px;
  transition: transform var(--t-mid), box-shadow var(--t-mid), background var(--t-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#checkout-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.spinner.show { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.checkout-summary-side {
  padding: 28px;
  background: var(--bg);
}

.checkout-summary-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.summary-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  max-height: 220px;
  overflow-y: auto;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.summary-item-thumb,
.summary-item-emoji {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.summary-item-thumb .summary-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.summary-item-name {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.3;
}
.summary-item-qty {
  font-size: 0.72rem;
  color: var(--fg-muted);
}
.summary-item-price {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.95rem;
  color: var(--fg);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.summary-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 8px;
}
.summary-line-label { color: var(--fg-muted); }
.summary-line-value { font-weight: 600; }
.summary-line.free-delivery .summary-line-value { color: var(--green); }

.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--r);
  border: 1.5px solid var(--border-strong);
  margin-top: 8px;
}
.summary-total-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.summary-total-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.checkout-success {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px;
  min-height: 400px;
}
.checkout-success.show { display: flex; }

.success-check {
  width: 80px;
  height: 80px;
  background: rgba(0,196,122,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 24px;
  animation: successPop 0.5s var(--t-spring) both;
}
@keyframes successPop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.success-title {
  font-size: 2rem;
  margin-bottom: 12px;
}
.success-msg {
  font-size: 0.95rem;
  color: var(--fg-muted);
  max-width: 380px;
  line-height: 1.7;
}

[dir="rtl"] .checkout-form-side {
  border-right: none;
  border-left: 1px solid var(--border);
}

[dir="rtl"] .summary-item {
  direction: rtl;
}

[dir="rtl"] .summary-line,
[dir="rtl"] .summary-total {
  direction: rtl;
}
