@layer components {
  /* ==========================================================================
     Devise Auth
     Authentication page styles (login, signup, password reset)

     NOTE: Glassmorphism effects use raw rgba values for visual fidelity.
     These are documented exceptions to the no-raw-values rule.
     ========================================================================== */

  /* ══ BASE DEVISE BODY ═══════════════════════════════════════════════ */
  .devise-body {
    min-height: 100vh;
    background: #0b1120;
    position: relative;
    overflow: hidden;
  }
  .devise-body::before {
    content: "";
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    /* Glassmorphism background - documented exception */
    background: radial-gradient(ellipse at 20% 50%, rgba(14, 165, 233, 0.15) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.12) 0%, transparent 50%),
                radial-gradient(ellipse at 60% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    animation: mesh-drift 20s ease-in-out infinite alternate;
  }

  @keyframes mesh-drift {
    0% {
      transform: translate(0, 0) rotate(0deg);
    }
    100% {
      transform: translate(-2%, 2%) rotate(3deg);
    }
  }

  .devise-body .container {
    position: relative;
    z-index: 1;
  }

  /* Brand */
  .devise-body .devise-brand {
    text-align: center;
    margin-bottom: 2rem;
  }
  .devise-body .devise-brand .brand-icon-lg {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    color: #fff;
    margin-bottom: 0.875rem;
    box-shadow: 0 0 24px rgba(14, 165, 233, 0.35);
  }
  .devise-body .devise-brand h2,
  .devise-body .devise-brand .h2 {
    color: #f1f5f9;
    font-weight: var(--font-weight-bold);
    font-size: 1.375rem;
    letter-spacing: -0.025em;
    margin: 0;
  }
  .devise-body .devise-brand .brand-tagline {
    color: rgba(148, 163, 184, 0.6);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-weight: var(--font-weight-normal);
  }

  /* Card - Glassmorphism */
  .devise-body .card {
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: var(--radius-xl);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
  .devise-body .card-body {
    padding: 2rem;
  }
  .devise-body .card-title {
    color: #e2e8f0;
    font-weight: var(--font-weight-bold);
    font-size: 1.125rem;
    letter-spacing: -0.02em;
  }

  /* Forms */
  .devise-body .form-label {
    color: rgba(148, 163, 184, 0.7);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .devise-body .form-control {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(148, 163, 184, 0.12);
    color: #e2e8f0;
    border-radius: var(--radius);
  }
  .devise-body .form-control::placeholder {
    color: rgba(148, 163, 184, 0.35);
  }
  .devise-body .form-control:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--cloud);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
    color: #f1f5f9;
  }
  .devise-body .form-check-input {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(148, 163, 184, 0.2);
  }
  .devise-body .form-check-input:checked {
    background-color: var(--cloud);
    border-color: var(--cloud);
  }
  .devise-body .form-check-label {
    color: rgba(148, 163, 184, 0.65);
    font-size: 0.8125rem;
  }

  /* Buttons */
  .devise-body .btn-primary {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
    border: none;
    padding: 0.5625rem 1.25rem;
    font-weight: var(--font-weight-semibold);
    font-size: 0.8125rem;
    box-shadow: 0 2px 12px rgba(14, 165, 233, 0.25);
  }
  .devise-body .btn-primary:hover {
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
    transform: translateY(-1px);
  }

  /* Utilities */
  /* `.text-muted` is a Bootstrap utility (`!important`) that sets a body-text
     muted colour. On the glassmorphic devise surface that colour reads as
     near-invisible — bump opacity via a slate-blue muted with elevated
     alpha so footnote / helper text remains legible on the dark backdrop. */
  .devise-body .text-muted {
    color: rgba(148, 163, 184, 0.4) !important;
  }

  /* Alerts */
  .devise-body .alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.15);
  }
  .devise-body .alert-success {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.15);
  }

  /* Portal Links */
  .devise-body .devise-portal-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
  }
  .devise-body .devise-portal-links a {
    color: rgba(148, 163, 184, 0.5);
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transition: color 0.2s ease;
  }
  .devise-body .devise-portal-links a i {
    margin-right: 0.25rem;
  }
  .devise-body .devise-portal-links a:hover {
    color: rgba(148, 163, 184, 0.85);
  }

  /* ══ CLIENT VARIANT (Teal/Green) ═══════════════════════════════════
     Backgrounds use literal hex (not portal-*-bg tokens) because devise
     pages are intentionally dark regardless of [data-bs-theme]. */
  .devise-body--client {
    background: #071a12;
  }
  .devise-body--client::before {
    background: radial-gradient(ellipse at 20% 50%, rgba(16, 185, 129, 0.18) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(20, 184, 166, 0.14) 0%, transparent 50%),
                radial-gradient(ellipse at 60% 80%, rgba(34, 197, 94, 0.1) 0%, transparent 50%);
  }
  .devise-body--client .devise-brand .brand-icon-lg {
    background: linear-gradient(135deg, #10b981, #14b8a6);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.35);
  }
  .devise-body--client .card {
    border-color: rgba(16, 185, 129, 0.12);
  }
  .devise-body--client .form-control:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  }
  .devise-body--client .form-check-input:checked {
    background-color: #10b981;
    border-color: #10b981;
  }
  .devise-body--client .btn-primary {
    background: linear-gradient(135deg, #10b981, #14b8a6);
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.25);
  }
  .devise-body--client .btn-primary:hover {
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  }

  /* ══ RESELLER VARIANT (Purple/Violet) ═══════════════════════════════ */
  .devise-body--reseller {
    background: #110b20;
  }
  .devise-body--reseller::before {
    background: radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.18) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.14) 0%, transparent 50%),
                radial-gradient(ellipse at 60% 80%, rgba(192, 132, 252, 0.1) 0%, transparent 50%);
  }
  .devise-body--reseller .devise-brand .brand-icon-lg {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    box-shadow: 0 0 24px rgba(139, 92, 246, 0.35);
  }
  .devise-body--reseller .card {
    border-color: rgba(139, 92, 246, 0.12);
  }
  .devise-body--reseller .form-control:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  }
  .devise-body--reseller .form-check-input:checked {
    background-color: #8b5cf6;
    border-color: #8b5cf6;
  }
  .devise-body--reseller .btn-primary {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.25);
  }
  .devise-body--reseller .btn-primary:hover {
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  }
}
