/* Modern Modal Dialog for Cart Operations */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-body {
  padding: 16px 24px 24px;
}

.modal-message {
  font-size: 16px;
  line-height: 1.5;
  color: #475569;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.modal-btn-secondary {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.modal-btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.modal-btn-danger {
  background: #ef4444;
  color: white;
}

.modal-btn-danger:hover {
  background: #dc2626;
}

.modal-btn-primary {
  background: #3b82f6;
  color: white;
}

.modal-btn-primary:hover {
  background: #2563eb;
}

.modal-icon {
  font-size: 24px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.modal-icon.danger {
  background: #fef2f2;
  color: #ef4444;
}

.modal-icon.warning {
  background: #fffbeb;
  color: #f59e0b;
}

.modal-icon.success {
  background: #f0fdf4;
  color: #22c55e;
}

.modal-icon.info {
  background: #eff6ff;
  color: #3b82f6;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .modal-dialog {
    margin: 16px;
    max-width: none;
    width: auto;
  }
  
  .modal-header,
  .modal-body {
    padding-left: 20px;
    padding-right: 20px;
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  .modal-btn {
    flex: none;
  }

  /* Checkout confirmation → bottom sheet on mobile */
  body.checkout-confirm-open {
    overflow: hidden;
  }

  .checkout-confirmation-modal {
    align-items: flex-end;
    justify-content: center;
  }

  .checkout-confirmation-modal .checkout-confirm-dialog,
  .checkout-confirmation-modal .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  }

  .checkout-confirmation-modal.show .checkout-confirm-dialog,
  .checkout-confirmation-modal.show .modal-dialog {
    transform: translateY(0);
  }

  .checkout-confirmation-modal .checkout-confirm-handle {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #d1d5db;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  .checkout-confirmation-modal .modal-header {
    padding: 12px 16px 10px;
    flex-shrink: 0;
  }

  .checkout-confirmation-modal .modal-title {
    font-size: 16px;
  }

  .checkout-confirmation-modal .checkout-confirm-body,
  .checkout-confirmation-modal .modal-body {
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    flex: 1;
  }

  .checkout-confirmation-modal .checkout-confirm-actions,
  .checkout-confirmation-modal .modal-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    flex-direction: row;
    gap: 8px;
  }

  .checkout-confirmation-modal .modal-btn {
    flex: 1;
    padding: 12px 10px;
  }
}

@media (min-width: 641px) {
  .checkout-confirmation-modal .checkout-confirm-handle {
    display: none;
  }

  .checkout-confirmation-modal .checkout-confirm-body {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
  }
}

/* Cancel Reason List */
.modal-reason-list {
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-reason-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 14px;
  color: #374151;
  user-select: none;
}

.modal-reason-item:has(input:checked) {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}

.modal-reason-item input[type="radio"] {
  accent-color: #3b82f6;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.modal-reason-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  margin-top: 8px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.modal-reason-textarea:focus {
  border-color: #3b82f6;
}