
/* ---- Design Tokens ------------------------------------------------------ */
:root {
  /* Light defaults */
  --rn-alert-bg: #ffffff;
  --rn-alert-fg: #1f2937;            /* slate-800 */
  --rn-alert-muted: #6b7280;         /* gray-500 */
  --rn-alert-surface: #f8fafc;       /* slate-50 */
  --rn-alert-border: #e5e7eb;        /* gray-200 */
  --rn-alert-elev: 0 10px 30px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);

  /* Primary colors - easily customizable */
  --rn-alert-accent: #2563eb;        /* blue-600 */
  --rn-alert-accent-hover: #1d4ed8;  /* blue-700 */
  --rn-alert-accent-light: #dbeafe;  /* blue-100 */
  
  /* Danger colors */
  --rn-alert-danger: #dc2626;        /* red-600 */
  --rn-alert-danger-hover: #b91c1c;  /* red-700 */
  --rn-alert-danger-light: #fecaca;  /* red-200 */

  /* Layout tokens */
  --rn-alert-radius: 12px;
  --rn-alert-radius-sm: 8px;
  --rn-alert-spacing: 20px;
  --rn-alert-spacing-sm: 12px;
  --rn-alert-btn-min: 40px;          /* touch target height */

  /* Computed colors (auto-generated from accent) */
  --rn-alert-outline: 3px solid color-mix(in srgb, var(--rn-alert-accent) 40%, transparent);
  --rn-alert-outline-weak: 2px solid color-mix(in srgb, var(--rn-alert-accent) 25%, transparent);

  /* Typography */
  --rn-alert-font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --rn-alert-font-size: 14px;
  --rn-alert-title-size: 18px;
}

:root[data-theme="dark"],
.rn-alert-theme--dark {
  --rn-alert-bg: #0b1220;            /* deep surface */
  --rn-alert-fg: #e5e7eb;            /* gray-200 */
  --rn-alert-muted: #a1a1aa;         /* zinc-400 */
  --rn-alert-surface: #0f172a;       /* slate-900 */
  --rn-alert-border: #334155;        /* slate-700 */
  --rn-alert-elev: 0 10px 30px rgba(0,0,0,.50), 0 2px 8px rgba(0,0,0,.35);

  --rn-alert-accent: #60a5fa;        /* blue-400 */
  --rn-alert-accent-hover: #3b82f6;  /* blue-500 */
  --rn-alert-accent-light: #1e3a8a;  /* blue-900 */
  
  --rn-alert-danger: #f87171;        /* red-400 */
  --rn-alert-danger-hover: #ef4444;  /* red-500 */
  --rn-alert-danger-light: #7f1d1d;  /* red-900 */

  --rn-alert-outline: 3px solid color-mix(in srgb, var(--rn-alert-accent) 50%, transparent);
  --rn-alert-outline-weak: 2px solid color-mix(in srgb, var(--rn-alert-accent) 35%, transparent);
}

/* System dark mode auto – keeps in sync unless user sets data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --rn-alert-bg: #0b1220;
    --rn-alert-fg: #e5e7eb;
    --rn-alert-muted: #a1a1aa;
    --rn-alert-surface: #0f172a;
    --rn-alert-border: #334155;
    --rn-alert-elev: 0 10px 30px rgba(0,0,0,.50), 0 2px 8px rgba(0,0,0,.35);

    --rn-alert-accent: #60a5fa;
    --rn-alert-accent-hover: #3b82f6;
    --rn-alert-accent-light: #1e3a8a;
    
    --rn-alert-danger: #f87171;
    --rn-alert-danger-hover: #ef4444;
    --rn-alert-danger-light: #7f1d1d;

    --rn-alert-outline: 3px solid color-mix(in srgb, var(--rn-alert-accent) 50%, transparent);
    --rn-alert-outline-weak: 2px solid color-mix(in srgb, var(--rn-alert-accent) 35%, transparent);
  }
}

/* ---- Dialog ------------------------------------------------------------- */
.rn-alert__dialog {
  color-scheme: light dark; 
  margin: auto;
  border: none;
  border-radius: var(--rn-alert-radius);
  padding: 0;
  inline-size: min(400px, 92dvi);
  max-block-size: 80dvb;
  background: var(--rn-alert-bg);
  color: var(--rn-alert-fg);
  box-shadow: var(--rn-alert-elev);
  font: 400 var(--rn-alert-font-size)/1.45 var(--rn-alert-font);
  animation: rn-alert__fade-in 120ms ease-out;
  overflow: hidden;
}

/* Backdrop */
.rn-alert__dialog::backdrop {
  background: color-mix(in srgb, #000 60%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: rn-alert__backdrop-fade-in 120ms ease-out;
}

/* Container */
.rn-alert__container {
  display: flex;
  flex-direction: column;
  min-block-size: 100px;
}

/* Content */
.rn-alert__content {
  padding: var(--rn-alert-spacing);
  background: var(--rn-alert-bg);
}

/* Title */
.rn-alert__title {
  font-size: var(--rn-alert-title-size);
  font-weight: 600;
  margin: 0 0 8px 0;
  line-height: 1.25;
  color: inherit;
}

/* Body */
.rn-alert__body {
  margin: 0;
}

/* Message */
.rn-alert__message {
  font-size: 14px;
  color: var(--rn-alert-muted);
  margin: 0 0 16px 0;
  line-height: 1.6;
}

/* Input */
.rn-alert__input-container { margin-block-start: 8px; }

.rn-alert__input-field {
  inline-size: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rn-alert-border);
  border-radius: var(--rn-alert-radius-sm);
  font: inherit;
  box-sizing: border-box;
  background: var(--rn-alert-surface);
  color: var(--rn-alert-fg);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.rn-alert__input-field::placeholder { color: color-mix(in srgb, var(--rn-alert-muted) 80%, transparent); }

.rn-alert__input-field:focus-visible {
  border-color: var(--rn-alert-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rn-alert-accent) 20%, transparent);
}

/* Actions */
.rn-alert__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px var(--rn-alert-spacing) var(--rn-alert-spacing) var(--rn-alert-spacing);
  border-block-start: 1px solid var(--rn-alert-border);
  background: color-mix(in srgb, var(--rn-alert-surface) 94%, transparent);
}

/* Buttons (base) */
.rn-alert__button {
  appearance: none;
  padding: 10px 16px;
  min-inline-size: 72px;
  min-block-size: var(--rn-alert-btn-min);
  border-radius: var(--rn-alert-radius-sm);
  font: 500 14px/1 var(--rn-alert-font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .06s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
  text-align: center;
  white-space: nowrap;
  background: var(--rn-alert-surface);
  color: var(--rn-alert-fg);
}

.rn-alert__button:active { transform: translateY(1px); }

/* Focus only for keyboard users */
.rn-alert__button:focus { outline: none; }
.rn-alert__button:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--rn-alert-accent) 25%, transparent); }

/* Variants */
.rn-alert__button--primary {
  background: var(--rn-alert-accent);
  color: #fff;
  border-color: color-mix(in srgb, #000 10%, var(--rn-alert-accent));
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.rn-alert__button--primary:hover { background: var(--rn-alert-accent-hover); }

.rn-alert__button--secondary {
  background: var(--rn-alert-bg);
  color: var(--rn-alert-fg);
  border-color: var(--rn-alert-border);
}
.rn-alert__button--secondary:hover {
  background: color-mix(in srgb, var(--rn-alert-surface) 85%, transparent);
  border-color: color-mix(in srgb, var(--rn-alert-border) 70%, #000 10%);
}

.rn-alert__button--destructive {
  background: var(--rn-alert-danger);
  color: #fff;
  border-color: color-mix(in srgb, #000 10%, var(--rn-alert-danger));
}
.rn-alert__button--destructive:hover { background: var(--rn-alert-danger-hover); }

/* Confirm layout (two buttons spread) */
.rn-alert__dialog--confirm .rn-alert__actions { justify-content: space-between; }

/* ---- Motion ------------------------------------------------------------- */
@keyframes rn-alert__fade-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rn-alert__backdrop-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Reduced Motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .rn-alert__dialog,
  .rn-alert__dialog::backdrop { animation: none; }
  .rn-alert__button,
  .rn-alert__input-field { transition: none; }
}

/* ---- High Contrast / Forced Colors (Windows) --------------------------- */
@media (forced-colors: active) {
  .rn-alert__dialog {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
    box-shadow: none;
  }
  .rn-alert__dialog::backdrop { background: rgba(0,0,0,.6); }
  .rn-alert__input-field {
    forced-color-adjust: none;
    background: Canvas;
    color: CanvasText;
    border-color: ButtonText;
  }
  .rn-alert__button {
    forced-color-adjust: none;
    border-color: ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }
  .rn-alert__button--primary { background: Highlight; color: HighlightText; border-color: Highlight; }
  .rn-alert__button--destructive { background: Highlight; color: HighlightText; border-color: Highlight; }
}

/* ---- Legacy Backdrop Fallback ------------------------------------------ */
@supports not (backdrop-filter: blur(2px)) {
  .rn-alert__dialog::backdrop { background: rgba(0,0,0,.6); }
}

/* ---- Small screens ----------------------------------------------------- */
@media (max-width: 480px) {
  .rn-alert__dialog {
    inline-size: 95%;
    border-radius: var(--rn-alert-radius-sm);
  }
  .rn-alert__content { padding: 16px; }
  .rn-alert__actions {
    padding: 12px 16px 16px 16px;
    flex-direction: column;
    gap: 8px;
  }
  .rn-alert__button { min-inline-size: unset; inline-size: 100%; }
}

/* Very small screens */
@media (max-width: 320px) {
  .rn-alert__content { padding: var(--rn-alert-spacing-sm); }
  .rn-alert__title { font-size: 16px; }
  .rn-alert__message { font-size: 13px; }
}

/* ---- Print -------------------------------------------------------------- */
@media print { .rn-alert__dialog { display: none !important; } }
