/* ========================================================
   9Router Custom Login Theme - Pure CSS Safe Architecture
   No DOM Node Removal - 100% React Reconciliation Safe
   ======================================================== */

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

/* Global Background Wallpaper & Typography */
body:has(.max-w-md),
.min-h-screen:has(.max-w-md) {
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    background-image: url("/custom-assets/Placeholder.png") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-attachment: fixed !important;
    background-color: #07090e !important;
    overflow-x: hidden !important;
}

/* Hide default grid background */
.landing-grid {
    display: none !important;
}

/* Hide Default Password Helper Text & Code Safely via CSS (Leaves DOM Node for React) */
.max-w-md form > p.text-text-muted,
.max-w-md button[type="submit"] + p {
    display: none !important;
}

/* Entrance Animation for Card */
@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(28px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Error Shake Animation triggered purely via CSS :has() */
@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-10px); }
    30% { transform: translateX(9px); }
    45% { transform: translateX(-7px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(2px); }
}

/* The Main Glassmorphism Card Container */
.max-w-md {
    position: relative !important;
    z-index: 10 !important;
    max-width: 420px !important;
    margin: 0 auto !important;
    background: rgba(13, 19, 33, 0.82) !important;
    backdrop-filter: blur(28px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(28px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 26px !important;
    box-shadow: 
        0 25px 60px -10px rgba(0, 0, 0, 0.75),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 0 35px rgba(56, 189, 248, 0.18) !important;
    padding: 34px 30px !important;
    overflow: hidden !important;
    animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

/* Shake Card when React renders error paragraph */
.max-w-md:has(p.text-red-500) {
    animation: shakeError 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
    box-shadow: 
        0 25px 60px -10px rgba(0, 0, 0, 0.75),
        0 0 35px rgba(239, 68, 68, 0.22) !important;
}

/* Glowing Top Accent Bar on Card */
.max-w-md::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #38bdf8 30%, #818cf8 70%, transparent);
    border-radius: 9999px;
    opacity: 0.9;
    z-index: 20;
}

/* Remove default background/border from inner Card so it blends into the main glass card */
.max-w-md > div:last-child {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* ========================================================
   Header Transformation (9Router -> Modern Welcome Back)
   Uses CSS Pseudo-Elements so React DOM is 100% Preserved!
   ======================================================== */
.max-w-md .text-center.mb-8 {
    margin-bottom: 22px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

/* Hide original 9Router text safely via font-size: 0 */
.max-w-md .text-center.mb-8 h1 {
    font-size: 0 !important;
    line-height: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

/* Glowing Shield/Lock Icon Badge */
.max-w-md .text-center.mb-8 h1::before {
    content: "";
    display: block;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(99, 102, 241, 0.28)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center no-repeat;
    background-size: 26px 26px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 22px rgba(56, 189, 248, 0.35), inset 0 0 14px rgba(255, 255, 255, 0.15);
    margin-bottom: 14px;
}

/* Replaced Title: Welcome Back */
.max-w-md .text-center.mb-8 h1::after {
    content: "Welcome Back";
    font-family: "Outfit", sans-serif !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    letter-spacing: -0.3px !important;
    background: linear-gradient(135deg, #ffffff 35%, #7dd3fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(56, 189, 248, 0.2);
    line-height: 1.3 !important;
    margin-bottom: 6px;
}

/* Hide original description text safely */
.max-w-md .text-center.mb-8 p {
    font-size: 0 !important;
    line-height: 0 !important;
    margin: 0 !important;
}

/* Replaced Subtitle */
.max-w-md .text-center.mb-8 p::after {
    content: "Enter master password to unlock dashboard";
    font-family: "Plus Jakarta Sans", sans-serif !important;
    font-size: 13px !important;
    color: #94a3b8 !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
}

/* ========================================================
   Form & Input Controls
   ======================================================== */
.max-w-md label {
    font-family: "Outfit", sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #cbd5e1 !important;
    letter-spacing: 0.3px !important;
    margin-bottom: 2px;
}

.max-w-md input[type="password"],
.max-w-md input[type="text"] {
    font-family: "Plus Jakarta Sans", sans-serif !important;
    background: rgba(15, 23, 42, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-radius: 14px !important;
    padding: 12px 16px !important;
    color: #f8fafc !important;
    font-size: 14px !important;
    letter-spacing: 0.2px !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.max-w-md input[type="password"]::placeholder,
.max-w-md input[type="text"]::placeholder {
    color: rgba(148, 163, 184, 0.6) !important;
    font-size: 13px !important;
}

.max-w-md input:focus {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.28), 0 0 20px rgba(56, 189, 248, 0.2) !important;
    outline: none !important;
}

/* High-Contrast Crisp Error Alert Styling */
.max-w-md p.text-red-500 {
    font-family: "Plus Jakarta Sans", sans-serif !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    color: #fee2e2 !important;
    background: rgba(185, 28, 28, 0.38) !important;
    border: 1px solid rgba(248, 113, 113, 0.5) !important;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25) !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    margin-top: 6px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* Submit Button - Vibrant Azure/Indigo/Cyan Gradient */
.max-w-md button[type="submit"] {
    font-family: "Outfit", sans-serif !important;
    height: 46px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 50%, #06b6d4 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 14px !important;
    box-shadow: 
        0 4px 18px rgba(59, 130, 246, 0.45),
        0 0 25px rgba(6, 182, 212, 0.25) !important;
    cursor: pointer !important;
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    margin-top: 6px !important;
}

.max-w-md button[type="submit"]:hover:not(:disabled) {
    background: linear-gradient(135deg, #4338ca 0%, #2563eb 50%, #0891b2 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 
        0 8px 25px rgba(59, 130, 246, 0.6),
        0 0 35px rgba(6, 182, 212, 0.4) !important;
}

.max-w-md button[type="submit"]:active:not(:disabled) {
    transform: translateY(1px) scale(0.98) !important;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3) !important;
}

/* Button text transformation safely via CSS */
.max-w-md button[type="submit"]:not(:disabled) {
    font-size: 0 !important;
}

.max-w-md button[type="submit"]:not(:disabled)::after {
    content: "Unlock Dashboard →";
    font-size: 15px !important;
    letter-spacing: 0.5px !important;
}

/* Background Ambient Floating Particles */
#ambient-canvas-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.ambient-sparkle {
    position: absolute;
    pointer-events: none;
    user-select: none;
    will-change: transform, opacity;
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.15;
    }
    30% {
        opacity: 0.65;
    }
    70% {
        opacity: 0.65;
    }
    100% {
        transform: translateY(-160px) rotate(45deg);
        opacity: 0;
    }
}
