/* ══════════════════════════════════════════════════
   Status Modal — always-dark overlay
   Variants: error (rose), success (emerald), warning (amber), info (blue)
   ══════════════════════════════════════════════════ */

/* ── Variables ── */
.sm-overlay {
  --sm-navy: #1E1B4B;
  --sm-surface: #252249;
  --sm-border: rgba(255, 255, 255, 0.06);
  --sm-text-primary: #F1F0F7;
  --sm-text-secondary: #9896B8;

  /* Per-variant accent — overridden by .sm--success etc. */
  --sm-accent: #F43F5E;
  --sm-accent-glow: rgba(244, 63, 94, 0.15);
  --sm-accent-glow-strong: rgba(244, 63, 94, 0.35);
  --sm-accent-ring: rgba(244, 63, 94, 0.2);
  --sm-accent-bg: rgba(244, 63, 94, 0.12);
  --sm-accent-bg-subtle: rgba(244, 63, 94, 0.04);
  --sm-accent-shadow: rgba(244, 63, 94, 0.3);
  --sm-accent-shadow-hover: rgba(244, 63, 94, 0.4);
  --sm-accent-dark: #E11D48;
}

/* Success (emerald) */
.sm-overlay.sm--success {
  --sm-accent: #10B981;
  --sm-accent-glow: rgba(16, 185, 129, 0.15);
  --sm-accent-glow-strong: rgba(16, 185, 129, 0.35);
  --sm-accent-ring: rgba(16, 185, 129, 0.2);
  --sm-accent-bg: rgba(16, 185, 129, 0.12);
  --sm-accent-bg-subtle: rgba(16, 185, 129, 0.04);
  --sm-accent-shadow: rgba(16, 185, 129, 0.3);
  --sm-accent-shadow-hover: rgba(16, 185, 129, 0.4);
  --sm-accent-dark: #059669;
}

/* Warning (amber) */
.sm-overlay.sm--warning {
  --sm-accent: #F59E0B;
  --sm-accent-glow: rgba(245, 158, 11, 0.15);
  --sm-accent-glow-strong: rgba(245, 158, 11, 0.35);
  --sm-accent-ring: rgba(245, 158, 11, 0.2);
  --sm-accent-bg: rgba(245, 158, 11, 0.12);
  --sm-accent-bg-subtle: rgba(245, 158, 11, 0.04);
  --sm-accent-shadow: rgba(245, 158, 11, 0.3);
  --sm-accent-shadow-hover: rgba(245, 158, 11, 0.4);
  --sm-accent-dark: #D97706;
}

/* Info (blue) */
.sm-overlay.sm--info {
  --sm-accent: #3B82F6;
  --sm-accent-glow: rgba(59, 130, 246, 0.15);
  --sm-accent-glow-strong: rgba(59, 130, 246, 0.35);
  --sm-accent-ring: rgba(59, 130, 246, 0.2);
  --sm-accent-bg: rgba(59, 130, 246, 0.12);
  --sm-accent-bg-subtle: rgba(59, 130, 246, 0.04);
  --sm-accent-shadow: rgba(59, 130, 246, 0.3);
  --sm-accent-shadow-hover: rgba(59, 130, 246, 0.4);
  --sm-accent-dark: #2563EB;
}

/* ── Backdrop / overlay ── */
.sm-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}

.sm-overlay.sm--visible {
  opacity: 1;
  visibility: visible;
}

.sm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 30, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ── Ambient glow ── */
.sm-ambient {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--sm-accent-glow) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  pointer-events: none;
  animation: sm-pulse-glow 3s ease-in-out infinite;
}

@keyframes sm-pulse-glow {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -55%) scale(1); }
  50% { opacity: 0.8; transform: translate(-50%, -55%) scale(1.08); }
}

/* ── Modal card ── */
.sm-modal {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 380px;
  background: var(--sm-surface);
  border: 1px solid var(--sm-border);
  border-radius: 24px;
  padding: 40px 36px 32px;
  text-align: center;
  font-family: 'Outfit', 'Cairo', sans-serif;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 8px 32px rgba(0, 0, 0, 0.3);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition: transform .45s cubic-bezier(0.16, 1, 0.3, 1), opacity .45s cubic-bezier(0.16, 1, 0.3, 1);
}

.sm--visible .sm-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Noise texture */
.sm-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* ── Floating particles ── */
.sm-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 24px;
}

.sm-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--sm-accent);
  opacity: 0;
}

.sm-particle:nth-child(1) { top: 18%; left: 12%; animation: sm-particle-float 5s 0s infinite; }
.sm-particle:nth-child(2) { top: 32%; right: 15%; animation: sm-particle-float 6s 1.5s infinite; }
.sm-particle:nth-child(3) { bottom: 28%; left: 20%; animation: sm-particle-float 4.5s 0.8s infinite; }
.sm-particle:nth-child(4) { top: 60%; right: 10%; animation: sm-particle-float 5.5s 2s infinite; }
.sm-particle:nth-child(5) { bottom: 15%; right: 25%; animation: sm-particle-float 4s 0.3s infinite; }

@keyframes sm-particle-float {
  0%   { opacity: 0;    transform: translateY(8px) scale(0.5); }
  20%  { opacity: 0.25; }
  50%  { opacity: 0.15; transform: translateY(-12px) scale(1); }
  80%  { opacity: 0.25; }
  100% { opacity: 0;    transform: translateY(-24px) scale(0.5); }
}

/* ── Icon ring ── */
.sm-icon-container {
  margin-bottom: 28px;
  opacity: 0;
  transform: scale(0.5) rotate(-10deg);
  transition: opacity .5s .15s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform .5s .15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sm--visible .sm-icon-container {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.sm-icon-ring {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: sm-float 4s ease-in-out infinite;
}

@keyframes sm-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Rotating outer ring */
.sm-icon-ring::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, transparent, var(--sm-accent-glow-strong), transparent);
  animation: sm-ring-rotate 6s linear infinite;
}

@keyframes sm-ring-rotate {
  to { transform: rotate(360deg); }
}

.sm-icon-ring-inner {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--sm-accent-bg), var(--sm-accent-bg-subtle));
  border: 1.5px solid var(--sm-accent-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* ── SVG icon ── */
.sm-icon-svg {
  width: 36px;
  height: 36px;
}

.sm-icon-svg .sm-circle {
  fill: none;
  stroke: var(--sm-accent);
  stroke-width: 2;
  stroke-dasharray: 132;
  stroke-dashoffset: 132;
  stroke-linecap: round;
}

.sm--visible .sm-icon-svg .sm-circle {
  animation: sm-dash-spin 0.8s 0.4s ease-out forwards;
}

@keyframes sm-dash-spin {
  to { stroke-dashoffset: 0; }
}

.sm-icon-svg .sm-x-line {
  stroke: var(--sm-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
}

.sm--visible .sm-icon-svg .sm-x1 { animation: sm-x-draw 0.35s 1.0s ease-out forwards; }
.sm--visible .sm-icon-svg .sm-x2 { animation: sm-x-draw 0.35s 1.15s ease-out forwards; }

@keyframes sm-x-draw {
  from { stroke-dashoffset: 34; }
  to   { stroke-dashoffset: 0; }
}

/* Checkmark for success */
.sm-icon-svg .sm-check {
  stroke: var(--sm-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}

.sm--visible .sm-icon-svg .sm-check {
  animation: sm-check-draw 0.5s 1.0s ease-out forwards;
}

@keyframes sm-check-draw {
  to { stroke-dashoffset: 0; }
}

/* Exclamation for warning */
.sm-icon-svg .sm-excl-line,
.sm-icon-svg .sm-excl-dot {
  stroke: var(--sm-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}

.sm--visible .sm-icon-svg .sm-excl-line { animation: sm-excl-draw 0.4s 1.0s ease-out forwards; }
.sm--visible .sm-icon-svg .sm-excl-dot  { animation: sm-excl-draw 0.3s 1.2s ease-out forwards; }

@keyframes sm-excl-draw {
  to { stroke-dashoffset: 0; }
}

/* Info "i" */
.sm-icon-svg .sm-info-dot,
.sm-icon-svg .sm-info-line {
  stroke: var(--sm-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}

.sm--visible .sm-icon-svg .sm-info-dot  { animation: sm-excl-draw 0.3s 1.0s ease-out forwards; }
.sm--visible .sm-icon-svg .sm-info-line { animation: sm-excl-draw 0.4s 1.15s ease-out forwards; }

/* ── Text ── */
.sm-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--sm-text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .4s .25s cubic-bezier(0.16, 1, 0.3, 1),
              transform .4s .25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sm--visible .sm-title {
  opacity: 1;
  transform: translateY(0);
}

.sm-message {
  font-size: 14.5px;
  font-weight: 400;
  color: var(--sm-text-secondary);
  line-height: 1.6;
  margin-bottom: 28px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .4s .35s cubic-bezier(0.16, 1, 0.3, 1),
              transform .4s .35s cubic-bezier(0.16, 1, 0.3, 1);
}

.sm--visible .sm-message {
  opacity: 1;
  transform: translateY(0);
}

/* ── Buttons ── */
.sm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .4s .5s cubic-bezier(0.16, 1, 0.3, 1),
              transform .4s .5s cubic-bezier(0.16, 1, 0.3, 1);
}

.sm--visible .sm-actions {
  opacity: 1;
  transform: translateY(0);
}

.sm-btn {
  width: 100%;
  padding: 13px 24px;
  border-radius: 14px;
  border: none;
  font-family: 'Outfit', 'Cairo', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
}

.sm-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sm-btn-primary {
  background: linear-gradient(135deg, var(--sm-accent) 0%, var(--sm-accent-dark) 100%);
  color: white;
  box-shadow:
    0 4px 16px var(--sm-accent-shadow),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.sm-btn-primary:hover {
  box-shadow:
    0 6px 24px var(--sm-accent-shadow-hover),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.sm-btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

.sm-btn-ghost {
  background: transparent;
  color: var(--sm-text-secondary);
  border: 1px solid var(--sm-border);
}

.sm-btn-ghost:hover {
  color: var(--sm-text-primary);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ── Support link ── */
.sm-support-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--sm-text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: color 200ms ease;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .4s .6s cubic-bezier(0.16, 1, 0.3, 1),
              transform .4s .6s cubic-bezier(0.16, 1, 0.3, 1),
              color 200ms ease;
}

.sm--visible .sm-support-link {
  opacity: 1;
  transform: translateY(0);
}

.sm-support-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sm-support-link:hover {
  color: var(--sm-text-primary);
}

.sm-support-link span {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(152, 150, 184, 0.3);
  transition: text-decoration-color 200ms ease;
}

.sm-support-link:hover span {
  text-decoration-color: var(--sm-text-primary);
}

/* ── Shake animation (retry) ── */
@keyframes sm-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px) rotate(-1deg); }
  30% { transform: translateX(5px) rotate(1deg); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-1px); }
}

.sm-modal.sm--shake {
  animation: sm-shake 0.5s ease;
}

/* ── RTL ── */
[dir="rtl"] .sm-modal {
  font-family: 'Cairo', 'Outfit', sans-serif;
}

[dir="rtl"] .sm-btn {
  font-family: 'Cairo', 'Outfit', sans-serif;
}
