/**
 * AlertDialog styles
 * @countermeasure/web-components/overlays/alert-dialog
 */

/* ============================================================================
   OVERLAY BACKDROP
   ============================================================================ */
.cmm-alert-dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 400);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgb(0 0 0 / 0.5); /* TODO(phase-1): tokenize — backdrop overlay */
  opacity: 0;
  transition: opacity var(--transition-normal, 200ms) ease-out;
}

.cmm-alert-dialog--open {
  opacity: 1;
}

/* ============================================================================
   DIALOG BOX
   ============================================================================ */
.cmm-alert-dialog__dialog {
  position: relative;
  width: 100%;
  max-width: 28rem;
  margin: 1rem;
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: scale(0.95);
  transition:
    opacity var(--transition-normal, 200ms) ease-out,
    transform var(--transition-normal, 200ms) ease-out;
}

.cmm-alert-dialog--open .cmm-alert-dialog__dialog {
  opacity: 1;
  transform: scale(1);
}

.cmm-alert-dialog__dialog:focus-visible {
  outline: none;
}

/* ============================================================================
   HEADER
   ============================================================================ */
.cmm-alert-dialog__header {
  padding: 1.5rem 1.5rem 0;
}

.cmm-alert-dialog__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  color: hsl(var(--foreground));
}

.cmm-alert-dialog__description {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: hsl(var(--muted-foreground));
}

/* ============================================================================
   VARIANT: WARNING
   ============================================================================ */
.cmm-alert-dialog--warning .cmm-alert-dialog__dialog {
  border-color: hsl(var(--warning) / 0.5);
}

.cmm-alert-dialog--warning .cmm-alert-dialog__title {
  color: hsl(var(--warning));
}

/* ============================================================================
   VARIANT: DESTRUCTIVE
   ============================================================================ */
.cmm-alert-dialog--destructive .cmm-alert-dialog__dialog {
  border-color: hsl(var(--danger) / 0.5);
}

.cmm-alert-dialog--destructive .cmm-alert-dialog__title {
  color: hsl(var(--danger));
}

/* ============================================================================
   CONFIRM INPUT (type-to-confirm for destructive)
   ============================================================================ */
.cmm-alert-dialog__confirm-group {
  padding: 1rem 1.5rem 0;
}

.cmm-alert-dialog__confirm-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.cmm-alert-dialog__confirm-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast, 150ms);
}

.cmm-alert-dialog__confirm-input:focus {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
  border-color: hsl(var(--focus-ring));
}

/* ============================================================================
   FOOTER / BUTTONS
   ============================================================================ */
.cmm-alert-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
}

.cmm-alert-dialog__btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--transition-fast, 150ms),
    opacity var(--transition-fast, 150ms);
}

.cmm-alert-dialog__btn:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.cmm-alert-dialog__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cmm-alert-dialog__btn--cancel {
  background-color: hsl(var(--muted));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}

.cmm-alert-dialog__btn--cancel:hover:not(:disabled) {
  background-color: hsl(var(--muted-foreground) / 0.1);
}

.cmm-alert-dialog__btn--confirm {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
}

.cmm-alert-dialog__btn--confirm:hover:not(:disabled) {
  opacity: 0.9;
}

/* Destructive confirm button */
.cmm-alert-dialog--destructive .cmm-alert-dialog__btn--confirm {
  background-color: hsl(var(--danger));
  color: hsl(var(--danger-foreground));
}

/* Loading spinner for async confirm */
.cmm-alert-dialog__spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.375rem;
  vertical-align: middle;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cmm-alert-spin 0.6s linear infinite;
}

@keyframes cmm-alert-spin {
  to {
    transform: rotate(360deg);
  }
}
