/**
 * ==============================================================================
 * KUSTOMERS OS — SLEEK SLIM GLASS TOAST & VALIDATION SYSTEM (v2026)
 * ==============================================================================
 * Ultra-Compact, Minimalist Sonner/Linear Style Toast Experience
 * - Slim horizontal card (~46px height, no bloated badges)
 * - Frosted glassmorphism with crisp 1px glowing neon border
 * - Clean micro-icons with glowing halos
 * - Ultra-thin 1.5px laser progress line
 * - Interactive input validation states (.is-valid, .is-invalid) with micro-shake
 * ==============================================================================
 */

:root {
  --alg-toast-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --alg-toast-font-heading: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --alg-toast-zindex: 10999;
}

/* ==============================================================================
   1. TOAST CONTAINER DOCK (Top-Right Desktop, Top-Center Mobile)
   ============================================================================== */
.alg-toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: var(--alg-toast-zindex);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 380px;
  pointer-events: none;
}

@media (max-width: 575.98px) {
  .alg-toast-container {
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    max-width: calc(100vw - 1.5rem);
  }
}

/* ==============================================================================
   2. SLEEK SLIM TOAST CARD
   ============================================================================== */
.alg-toast {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 11px 13px;
  border-radius: 12px;
  min-height: 46px;
  
  /* Frosted Glassmorphism */
  background: rgba(14, 22, 19, 0.94);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  
  /* Crisp 1px Border & Elevation */
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 12px 30px -6px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  
  color: #f8fafc;
  cursor: default;
  user-select: none;
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
  animation: algToastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.alg-toast:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.65);
}

/* Light Mode Overrides (Crisp Crystalline Ceramic Glass) */
body:not(.dark-mode):not([data-bs-theme="dark"]) .alg-toast {
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 
    0 14px 32px -6px rgba(15, 23, 42, 0.14),
    0 2px 6px rgba(15, 23, 42, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Slide Entrance & Dismiss Animation */
@keyframes algToastSlideIn {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.alg-toast.alg-toast--dismissing {
  opacity: 0 !important;
  transform: translateX(110%) scale(0.95) !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 1, 1) !important;
}

/* ==============================================================================
   3. SLEEK MICRO-ICON
   ============================================================================== */
.alg-toast-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}

/* ==============================================================================
   4. TOAST CONTENT (Title & Message)
   ============================================================================== */
.alg-toast-body {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.alg-toast-title {
  font-family: var(--alg-toast-font-heading);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.alg-toast-message {
  font-family: var(--alg-toast-font);
  font-size: 0.77rem;
  line-height: 1.35;
  color: #cbd5e1;
  word-break: break-word;
}

body:not(.dark-mode):not([data-bs-theme="dark"]) .alg-toast-message {
  color: #475569;
}

/* When only message is present */
.alg-toast-single-text .alg-toast-body {
  font-size: 0.82rem;
  font-weight: 600;
  color: inherit;
}

/* Action button if present */
.alg-toast-btn {
  font-family: var(--alg-toast-font);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
  transition: all 0.18s ease;
}

/* ==============================================================================
   5. SLEEK MICRO CLOSE BUTTON
   ============================================================================== */
.alg-toast-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 20px;
  height: 20px;
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.6;
  transition: all 0.18s ease;
}

.alg-toast-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

body:not(.dark-mode):not([data-bs-theme="dark"]) .alg-toast-close:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

/* ==============================================================================
   6. ULTRA-THIN LASER PROGRESS BAR (1.5px)
   ============================================================================== */
.alg-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.alg-toast-progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: algToastLaser linear forwards;
}

.alg-toast:hover .alg-toast-progress-bar {
  animation-play-state: paused !important;
}

@keyframes algToastLaser {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ==============================================================================
   7. STATUS ACCENTS & NEON GLOWS
   ============================================================================== */

/* --- A. SUCCESS (Emerald Mint) --- */
.alg-toast--success {
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 
    0 12px 30px -6px rgba(16, 185, 129, 0.22),
    0 2px 6px rgba(0, 0, 0, 0.2);
}
.alg-toast--success .alg-toast-icon { color: #10b981; }
.alg-toast--success .alg-toast-title { color: #10b981; }
.alg-toast--success .alg-toast-progress-bar { background: #10b981; }
.alg-toast--success .alg-toast-btn { background: #10b981; color: #fff; }

/* --- B. ERROR (Crimson Coral) --- */
.alg-toast--error {
  border-color: rgba(239, 68, 68, 0.38);
  box-shadow: 
    0 12px 30px -6px rgba(239, 68, 68, 0.25),
    0 2px 6px rgba(0, 0, 0, 0.2);
}
.alg-toast--error .alg-toast-icon { color: #ef4444; }
.alg-toast--error .alg-toast-title { color: #ef4444; }
.alg-toast--error .alg-toast-progress-bar { background: #ef4444; }
.alg-toast--error .alg-toast-btn { background: #ef4444; color: #fff; }

/* --- C. WARNING (Warm Amber) --- */
.alg-toast--warning {
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 
    0 12px 30px -6px rgba(245, 158, 11, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.2);
}
.alg-toast--warning .alg-toast-icon { color: #f59e0b; }
.alg-toast--warning .alg-toast-title { color: #f59e0b; }
.alg-toast--warning .alg-toast-progress-bar { background: #f59e0b; }
.alg-toast--warning .alg-toast-btn { background: #f59e0b; color: #fff; }

/* --- D. INFO (Electric Cyan-Blue) --- */
.alg-toast--info {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 
    0 12px 30px -6px rgba(56, 189, 248, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.2);
}
.alg-toast--info .alg-toast-icon { color: #38bdf8; }
.alg-toast--info .alg-toast-title { color: #38bdf8; }
.alg-toast--info .alg-toast-progress-bar { background: #38bdf8; }
.alg-toast--info .alg-toast-btn { background: #38bdf8; color: #fff; }

/* --- E. GOLD / REVENUE OPPORTUNITY --- */
.alg-toast--gold, .alg-toast--vip {
  border-color: rgba(224, 176, 74, 0.45);
  box-shadow: 
    0 12px 30px -6px rgba(224, 176, 74, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.2);
}
.alg-toast--gold .alg-toast-icon, .alg-toast--vip .alg-toast-icon { color: #e0b04a; }
.alg-toast--gold .alg-toast-title, .alg-toast--vip .alg-toast-title { color: #e0b04a; }
.alg-toast--gold .alg-toast-progress-bar, .alg-toast--vip .alg-toast-progress-bar { background: #e0b04a; }
.alg-toast--gold .alg-toast-btn, .alg-toast--vip .alg-toast-btn { background: #e0b04a; color: #000; }

/* --- F. LOADING STATE --- */
.alg-toast--loading .alg-toast-icon { color: #38bdf8; }
.alg-toast--loading .alg-toast-progress { display: none; }

/* ==============================================================================
   8. FORM VALIDATION UX ENGINE (.is-valid, .is-invalid, micro-shake, hints)
   ============================================================================== */
.form-control.is-invalid, .form-select.is-invalid {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.04) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16) !important;
  animation: algInputShake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.form-control.is-valid, .form-select.is-valid {
  border-color: #10b981 !important;
  background-color: rgba(16, 185, 129, 0.035) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14) !important;
}

@keyframes algInputShake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}

.alg-field-error {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--alg-toast-font);
  font-size: 0.77rem;
  font-weight: 600;
  color: #ef4444;
  margin-top: 5px;
  animation: algHintFade 0.2s ease-out forwards;
}

.alg-field-error i {
  font-size: 11px;
}

.alg-field-success {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--alg-toast-font);
  font-size: 0.77rem;
  font-weight: 600;
  color: #10b981;
  margin-top: 5px;
  animation: algHintFade 0.2s ease-out forwards;
}

.alg-field-success i {
  font-size: 11px;
}

@keyframes algHintFade {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}
