@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-color: #1e1b4b;
  --panel-bg: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(255, 255, 255, 0.9);
  --text-primary: #1e2238;
  --text-secondary: #5a627a;
  --pastel-lavender: #a78bfa;
  --pastel-rose: #f472b6;
  --pastel-indigo: #818cf8;
  --pastel-peach: #fbcfe8;
  --pastel-sky: #93c5fd;
  --input-bg: rgba(255, 255, 255, 0.95);
  --input-border: #e2e5f0;
  --input-border-focus: #a78bfa;
}

/* ==========================================================================
   Base Body & Scenic Wallpaper Background
   ========================================================================== */

html, body {
  background-color: var(--bg-color) !important;
  background-image: url('/wallpaper.jpg') !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-attachment: fixed !important;
  color: var(--text-primary) !important;
  font-family: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  min-height: 100vh;
  margin: 0;
  position: relative;
  overflow-x: hidden;
}

/* Soft ambient vignette & depth overlay on top of wallpaper */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08) 0%, rgba(20, 15, 40, 0.28) 100%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  pointer-events: none;
  z-index: 0;
}

/* React root container on top of backdrop */
#root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Authelia Component Token Overrides (Normalized across all themes) */
:root, [data-theme=dark], [data-theme=light], [data-theme=oled] {
  --background: transparent !important;
  --foreground: #1e2238 !important;
  --card: rgba(255, 255, 255, 0.82) !important;
  --card-foreground: #1e2238 !important;
  --popover: #ffffff !important;
  --popover-foreground: #1e2238 !important;
  --primary: #818cf8 !important;
  --primary-foreground: #ffffff !important;
  --secondary: #f5f3ff !important;
  --secondary-foreground: #6d28d9 !important;
  --muted: #f1f3f9 !important;
  --muted-foreground: #5a627a !important;
  --accent: #fdf2f8 !important;
  --accent-foreground: #be185d !important;
  --destructive: #f87171 !important;
  --destructive-foreground: #ffffff !important;
  --success: #34d399 !important;
  --success-foreground: #064e3b !important;
  --warning: #fbbf24 !important;
  --warning-foreground: #78350f !important;
  --info: #818cf8 !important;
  --info-foreground: #ffffff !important;
  --border: #e2e5f0 !important;
  --input: #e2e5f0 !important;
  --ring: #a78bfa !important;
  --radius: 0.85rem !important;
  --custom-icon: #7c3aed !important;
  --custom-loading-bar: #818cf8 !important;
  --divider: rgba(100, 116, 139, 0.12) !important;
  color-scheme: light !important;
}

/* ==========================================================================
   Broader, Unified Frosted Card Architecture
   ========================================================================== */

/* Expand outer stage width from narrow default (444px -> 500px+) */
[id$="-stage"] div.mx-auto.w-full {
  max-width: 500px !important;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

/* Consent Stage Width */
[id="openid-consent-decision-stage"] div.mx-auto.w-full {
  max-width: 580px !important;
}

/* Unified Frosted Glass Card encompassing Avatar, Title, and Form */
[id$="-stage"] div.flex.flex-col.items-stretch {
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(28px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(160%) !important;
  border: 1px solid rgba(255, 255, 255, 0.95) !important;
  border-radius: 1.75rem !important;
  box-shadow:
    0 25px 60px -15px rgba(20, 15, 45, 0.35),
    0 4px 18px -2px rgba(20, 15, 45, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset !important;
  padding: 2.75rem 2.5rem 2rem 2.5rem !important;
  width: 100% !important;
  margin: 1.5rem auto !important;
  box-sizing: border-box !important;
}

/* Reset inner containers so they don't form redundant nested cards */
[id$="-stage"] div.flex.flex-col.items-stretch > div.mt-2,
[id$="-stage"] div.flex.flex-col.items-stretch > div.w-full.p-2,
div:has(> #form-login) {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

/* Header Avatar Icon */
div.flex.flex-col.items-stretch > div.w-full.p-2 {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin-bottom: 0.25rem !important;
}

div.flex.flex-col.items-stretch > div.w-full.p-2 svg {
  width: 4.25rem !important;
  height: 4.25rem !important;
  color: #7c3aed !important;
  filter: drop-shadow(0 6px 18px rgba(124, 58, 237, 0.25)) !important;
}

/* Typography & Headers */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em !important;
  color: #1e2238 !important;
}

h5 {
  font-size: 1.55rem !important;
  margin-top: 0.25rem !important;
  margin-bottom: 1.25rem !important;
}

p, span, label, .text-muted-foreground {
  color: #5a627a !important;
  font-family: 'Plus Jakarta Sans', sans-serif !important;
}

/* ==========================================================================
   Form Input Fields & Floating Label Layout (Fixes Password Overlap Bug)
   ========================================================================== */

/* Proper height and padding for Authelia floating label inputs */
input[type="text"],
input[type="password"],
#username-textfield,
#password-textfield,
[data-slot="floating-input"] {
  background: rgba(255, 255, 255, 0.92) !important;
  border: 1.5px solid #e2e5f0 !important;
  color: #1e2238 !important;
  border-radius: 0.85rem !important;
  height: 3.5rem !important; /* 56px height matches Authelia floating label */
  padding-top: 1.25rem !important; /* Leaves room for top floating label */
  padding-bottom: 0.35rem !important;
  padding-left: 0.9rem !important;
  padding-right: 0.9rem !important;
  font-size: 0.95rem !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
}

/* Space for the eye icon in the password field */
#password-textfield {
  padding-right: 2.75rem !important;
}

/* CRITICAL: Keep input placeholder transparent so it NEVER overlaps floating labels */
input[type="text"]::placeholder,
input[type="password"]::placeholder,
[data-slot="floating-input"]::placeholder {
  color: transparent !important;
  opacity: 0 !important;
}

/* Focused input state */
input[type="text"]:focus,
input[type="password"]:focus,
#username-textfield:focus,
#password-textfield:focus,
[data-slot="floating-input"]:focus {
  border-color: #a78bfa !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3.5px rgba(167, 139, 250, 0.25), 0 2px 8px rgba(167, 139, 250, 0.12) !important;
  outline: none !important;
}

/* Floating Labels Styling */
div.relative:has(> [data-slot="floating-input"]) > label,
div.relative:has(> #username-textfield) > label,
div.relative:has(> #password-textfield) > label {
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  color: #64748b !important;
  font-size: 0.9rem !important;
  pointer-events: none !important;
  transition: all 0.2s ease !important;
}

/* Eye Toggle Password Visibility Button */
div:has(> #password-textfield) button,
button:has(> svg.lucide-eye),
button:has(> svg.lucide-eye-off) {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.35rem !important;
  color: #64748b !important;
  cursor: pointer !important;
  transition: color 0.15s ease !important;
}

div:has(> #password-textfield) button:hover,
button:has(> svg.lucide-eye):hover,
button:has(> svg.lucide-eye-off):hover {
  color: #7c3aed !important;
}

/* Checkbox Styling */
input[type="checkbox"], [role="checkbox"] {
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 0.4rem !important;
  background: #ffffff !important;
  transition: all 0.2s ease !important;
}

[role="checkbox"][data-state="checked"], input[type="checkbox"]:checked {
  background: #818cf8 !important;
  border-color: #818cf8 !important;
  box-shadow: 0 2px 8px rgba(129, 140, 248, 0.35) !important;
}

/* ==========================================================================
   Buttons & Interactive Actions
   ========================================================================== */

/* Primary Submit Action (Sign in, Accept consent, Reauth submit) */
#sign-in-button,
#openid-consent-accept,
#openid-consent-authenticate,
button[type="submit"]:not(#openid-consent-deny):not(#openid-consent-cancel) {
  background: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #f472b6 100%) !important;
  color: #ffffff !important;
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  font-weight: 700 !important;
  font-size: 0.98rem !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  border: none !important;
  border-radius: 0.85rem !important;
  padding: 0.85rem 1.5rem !important;
  box-shadow:
    0 8px 24px -4px rgba(167, 139, 250, 0.42),
    0 2px 6px -1px rgba(244, 114, 182, 0.25) !important;
  cursor: pointer !important;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#sign-in-button:hover,
#openid-consent-accept:hover,
#openid-consent-authenticate:hover,
button[type="submit"]:not(#openid-consent-deny):not(#openid-consent-cancel):hover {
  box-shadow:
    0 12px 28px -3px rgba(167, 139, 250, 0.52),
    0 4px 10px -1px rgba(244, 114, 182, 0.32) !important;
  transform: translateY(-1.5px) !important;
  filter: brightness(1.03) !important;
}

#sign-in-button:active,
#openid-consent-accept:active,
#openid-consent-authenticate:active {
  transform: translateY(0px) !important;
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.3) !important;
}

/* Secondary Actions on Consent Stage (Deny & Cancel Buttons) */
#openid-consent-deny,
#openid-consent-cancel {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #64748b !important;
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  font-weight: 600 !important;
  font-size: 0.92rem !important;
  border: 1.5px solid #e2e5f0 !important;
  border-radius: 0.85rem !important;
  padding: 0.75rem 1rem !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

#openid-consent-deny:hover,
#openid-consent-cancel:hover {
  background: rgba(254, 242, 242, 0.95) !important;
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
  transform: translateY(-1.5px) !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15) !important;
}

/* Consent Stage 2-Button Grid Sizing */
#openid-consent-accept,
#openid-consent-deny,
#openid-consent-authenticate,
#openid-consent-cancel {
  padding: 0.75rem 1rem !important;
  font-size: 0.92rem !important;
}

/* User Switcher / Header Ghost Buttons (Logout, Switch User, Methods) */
#logout-button,
#switch-user-button,
#methods-button {
  color: #7c3aed !important;
  font-weight: 500 !important;
  font-size: 0.85rem !important;
  background: transparent !important;
  border-radius: 0.5rem !important;
  padding: 0.3rem 0.6rem !important;
  transition: all 0.2s ease !important;
}

#logout-button:hover,
#switch-user-button:hover,
#methods-button:hover {
  color: #db2777 !important;
  background: rgba(243, 232, 255, 0.6) !important;
}

/* Secondary Links & Password Reset */
#reset-password-button, a:not([class*="button"]) {
  color: #7c3aed !important;
  font-weight: 500 !important;
  font-size: 0.92rem !important;
  transition: all 0.2s ease !important;
}

#reset-password-button:hover, a:not([class*="button"]):hover {
  color: #db2777 !important;
  text-decoration: none !important;
}

/* Top-right Language Selector Pill */
#language-button {
  background: rgba(255, 255, 255, 0.82) !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  border-radius: 0.65rem !important;
  color: #4b5563 !important;
  backdrop-filter: blur(12px) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
  transition: all 0.2s ease !important;
}

#language-button:hover {
  border-color: #a78bfa !important;
  color: #1e2238 !important;
  background: #ffffff !important;
}

/* ==========================================================================
   OpenID Permissions & Consent Screen Component Polish
   ========================================================================== */

/* Inner Client Info & Permissions Card in Consent Stage */
[id="openid-consent-decision-stage"] [data-slot="card"],
[id="openid-consent-decision-stage"] .bg-card {
  background: rgba(255, 255, 255, 0.65) !important;
  border: 1px solid rgba(226, 232, 240, 0.85) !important;
  border-radius: 1rem !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* Client Header Badge */
[id="openid-consent-decision-stage"] [data-slot="card-header"] {
  padding: 1rem 1.25rem !important;
}

[id="openid-consent-decision-stage"] [data-slot="card-content"] {
  padding: 1.25rem !important;
}

/* Client App Icon Badge */
[id="openid-consent-decision-stage"] span:has(> svg.lucide-app-window),
[id="openid-consent-decision-stage"] .bg-muted:has(> svg) {
  background: rgba(238, 242, 255, 0.9) !important;
  border: 1px solid rgba(199, 210, 254, 0.7) !important;
  color: #6366f1 !important;
  border-radius: 0.65rem !important;
}

/* Show / Hide Details Toggle */
#openid-consent-request-disclosure {
  color: #6366f1 !important;
  font-weight: 500 !important;
  padding: 0.65rem 1.25rem !important;
  transition: all 0.15s ease !important;
}

#openid-consent-request-disclosure:hover {
  color: #4f46e5 !important;
  background: rgba(238, 242, 255, 0.45) !important;
}

/* Permission Row Items */
[id="openid-consent-decision-stage"] [data-slot="item-group"] > [data-slot="item"],
[id="openid-consent-decision-stage"] div[role="listitem"] {
  background: rgba(255, 255, 255, 0.75) !important;
  border: 1px solid rgba(226, 232, 240, 0.7) !important;
  border-radius: 0.65rem !important;
  padding: 0.55rem 0.85rem !important;
  margin-bottom: 0.35rem !important;
  transition: all 0.15s ease !important;
}

[id="openid-consent-decision-stage"] [data-slot="item-group"] > [data-slot="item"]:hover,
[id="openid-consent-decision-stage"] div[role="listitem"]:hover {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(199, 210, 254, 0.9) !important;
}

/* Permission Row Icons */
[id="openid-consent-decision-stage"] [data-slot="item-media"] svg {
  color: #818cf8 !important;
}

/* Essential Permission Badge */
[id="openid-consent-decision-stage"] span.rounded-full.bg-muted {
  background: rgba(238, 242, 255, 0.95) !important;
  color: #6366f1 !important;
  border: 1px solid rgba(199, 210, 254, 0.8) !important;
  font-weight: 600 !important;
}

/* "Remember Consent" Switch Row */
[id="openid-consent-decision-stage"] div[data-slot="item"]:has(#pre-configure) {
  background: rgba(255, 255, 255, 0.7) !important;
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
  border-radius: 0.85rem !important;
  padding: 0.75rem 1rem !important;
  margin: 0.25rem 0 0.5rem 0 !important;
}

/* ==========================================================================
   Second Factor & System Alerts
   ========================================================================== */

/* Second Factor Inner Container */
[id="second-factor-stage"] div.border-border {
  background: rgba(255, 255, 255, 0.65) !important;
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
  border-radius: 1rem !important;
  padding: 1.5rem !important;
}

/* Soft, Legible Alerts (Error, Success, Warning) */
[role="alert"] {
  border-radius: 0.85rem !important;
  padding: 0.85rem 1.15rem !important;
  backdrop-filter: blur(8px) !important;
}

[role="alert"][class*="destructive"], [data-state="error"], .bg-destructive {
  background: rgba(254, 242, 242, 0.95) !important;
  border: 1px solid #fecaca !important;
  color: #991b1b !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.08) !important;
}

[role="alert"][class*="success"], [data-state="success"], .bg-success {
  background: rgba(240, 253, 244, 0.95) !important;
  border: 1px solid #bbf7d0 !important;
  color: #166534 !important;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.08) !important;
}

[role="alert"][class*="warning"], [data-state="warning"], .bg-warning {
  background: rgba(254, 243, 199, 0.95) !important;
  border: 1px solid #fde68a !important;
  color: #92400e !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08) !important;
}

[role="alert"][class*="info"], [data-state="info"], .bg-info {
  background: rgba(238, 242, 255, 0.95) !important;
  border: 1px solid #c7d2fe !important;
  color: #3730a3 !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08) !important;
}

/* QR Code & 2FA Container Safety (Scoped specifically to QR elements) */
[data-testid="qrcode"], .qr-code, canvas[data-slot="qrcode"] {
  background: #ffffff !important;
  padding: 0.85rem !important;
  border-radius: 0.85rem !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

/* Footer Link */
a[href*="authelia.com"] {
  color: #94a3b8 !important;
  font-size: 0.75rem !important;
  transition: color 0.2s ease !important;
}

a[href*="authelia.com"]:hover {
  color: #7c3aed !important;
}
