:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --input-bg: rgba(255, 255, 255, 0.9);
    --form-header-color: #0f172a;
    --grid-line: rgba(0, 0, 0, 0.05);
    --primary-btn: linear-gradient(135deg, #4f46e5, #3b82f6);
    --primary-btn-shadow: rgba(59, 130, 246, 0.4);
    --input-border: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #ffffff;
    --text-muted: #cbd5e1;
    --input-bg: #0f172a;
    --form-header-color: #cbd5e1;
    --grid-line: rgba(255, 255, 255, 0.03);
    --primary-btn: linear-gradient(135deg, #4f46e5, #3b82f6);
    --primary-btn-shadow: rgba(59, 130, 246, 0.4);
    --input-border: rgba(255, 255, 255, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; transition: background-color 0.3s ease, color 0.3s ease; }

/* Modern Heading Font */
h1, h2, h3, h4, h5, h6, .brand-text, .btn-primary {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}
body { 
    font-family: 'Inter', sans-serif; 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    background: var(--bg-color);
    color: var(--text-color);
    padding: 20px; 
    overflow: hidden;
    position: relative;
    /* Hide scrollbar for the page */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
body::-webkit-scrollbar, html::-webkit-scrollbar, *::-webkit-scrollbar { 
    display: none !important; 
    width: 0 !important; 
    height: 0 !important; 
}
* { scrollbar-width: none; }        /* Grid Background Pattern */
.grid-pattern {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 1;
    pointer-events: none;
    mask-image: radial-gradient(circle at center, black 0%, transparent 80%);
    -webkit-mask-image: radial-gradient(circle at center, black 0%, transparent 80%);
}

/* Form Container (No Card, just constraints) */
.form-wrapper { 
    width: 100%; 
    max-width: 450px; 
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; 
    position: relative; 
    z-index: 10;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

.form-header { margin-bottom: 25px; text-align: center; }
.form-header p { color: var(--form-header-color); font-size: 0.95rem; font-weight: 400; }

.brand-logo { height: 120px; margin-bottom: 25px; transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

.form-group { margin-bottom: 22px; position: relative; }
.form-label { display: none; /* Hidden, replaced by animated label */ }

/* Interactive Particle Placeholder */
.interactive-placeholder {
    position: absolute;
    left: 55px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    height: 22px;
    pointer-events: none;
    z-index: 5;
    color: #64748b;
    font-size: 1rem;
    font-weight: 400;
}
.shatter-text { display: flex; }
.shatter-text span {
    display: inline-block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.float-text {
    display: inline-block;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: left top;
    padding: 0 4px;
    border-radius: 4px;
    position: relative;
}
.interactive-placeholder.focused .float-text {
    color: #38bdf8;
    background: var(--bg-color);
    font-weight: 500;
}

.input-group { 
    position: relative; 
    border-radius: 14px; 
    background: var(--input-border); /* Static border */
    padding: 1px; 
    /* overflow: hidden removed to allow placeholder overflow */
}
.input-group::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle 120px at var(--x, 50%) var(--y, 50%), rgba(56, 189, 248, 1), transparent 100%);
    z-index: 0;
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: inherit; /* keeps glow fully contained */
}
.input-group:hover::before, .input-group:focus-within::before {
    opacity: 1;
}

.input-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: #64748b; width: 22px; height: 22px; pointer-events: none; transition: color 0.3s; z-index: 2;}

.form-control { 
    width: 100%; 
    padding: 16px 20px 16px 55px; 
    border: none;
    border-radius: 13px; /* Slightly smaller than wrapper */
    font-size: 1rem; 
    color: var(--text-color); 
    transition: all 0.3s ease; 
    background: var(--input-bg); 
    position: relative;
    z-index: 1;
}
.form-control::placeholder { color: #64748b; font-weight: 300; }
.form-control:focus { 
    background: var(--input-bg); 
    outline: none; 
}

/* Fix autofill background color */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover, 
.form-control:-webkit-autofill:focus, 
.form-control:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 50px var(--input-bg) inset !important;
    -webkit-text-fill-color: var(--text-color) !important;
    transition: background-color 5000s ease-in-out 0s;
    border-radius: 13px;
}

@keyframes typingGlow {
    0%, 100% { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4); }
    50% { box-shadow: 0 0 14px rgba(56, 189, 248, 0.9); }
}
.form-control.is-typing {
    animation: typingGlow 0.2s ease-out;
}

.form-control:focus + .input-icon, .input-group:focus-within .input-icon { color: #38bdf8; }

.btn-primary { 
    width: 100%; 
    padding: 18px; 
    background: transparent; 
    color: var(--text-muted); 
    border: 1px solid var(--input-border); 
    border-radius: 14px; 
    font-size: 1.1rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.3s ease; 
    margin-top: 10px; 
    position: relative;
    display: flex; justify-content: center; align-items: center; gap: 10px;
    z-index: 1;
}

/* Active animated border state */
.btn-primary.ready-btn {
    color: #4f46e5;
    border-color: rgba(79, 70, 229, 0.4);
    background: rgba(79, 70, 229, 0.08); /* Transparent but enabled feel */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.3);
}

[data-theme="dark"] .btn-primary.ready-btn {
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.1);
    box-shadow: 0 10px 25px -5px rgba(56, 189, 248, 0.2);
}

.btn-primary.ready-btn::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    z-index: -1;
    border-radius: 15px;
    background: linear-gradient(90deg, transparent 0%, #4f46e5 50%, transparent 100%);
    background-size: 200% auto;
    animation: pingPongLight 1.5s linear infinite alternate;
    opacity: 0.6;
}

[data-theme="dark"] .btn-primary.ready-btn::before {
    background: linear-gradient(90deg, transparent 0%, #38bdf8 50%, transparent 100%);
    background-size: 200% auto;
}

@keyframes pingPongLight {
    0% { background-position: 0% center; }
    100% { background-position: 100% center; }
}

.btn-primary:active { transform: scale(0.96); }

/* Custom Animated Login SVG */
.btn-primary .arrow-group {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-primary .door {
    transition: opacity 0.3s ease;
}
.btn-primary:active .arrow-group {
    transform: translateX(4px);
}

/* Custom Tooltip Validation */
.custom-error-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: rgba(239, 68, 68, 0.1); /* Glassmorphic almost transparent red */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444; /* Brighter red text */
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 20px);
    line-height: 1.4;
}
[data-theme="dark"] .custom-error-tooltip {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.15);
}
.custom-error-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 20px;
    width: 10px;
    height: 10px;
    background: rgba(239, 68, 68, 0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(239, 68, 68, 0.3);
    border-left: 1px solid rgba(239, 68, 68, 0.3);
    transform: rotate(45deg);
}
[data-theme="dark"] .custom-error-tooltip::before {
    background: rgba(239, 68, 68, 0.15);
}
.custom-error-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}
.input-group.has-error {
    box-shadow: 0 0 0 1px #ef4444;
}
.input-group.has-error .input-icon {
    color: #ef4444;
}

.alert { padding: 14px 18px; border-radius: 12px; margin-bottom: 24px; font-size: 0.9rem; display: flex; align-items: center; gap: 12px; font-weight: 500; animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; position: relative; overflow: hidden; transition: opacity 0.5s ease, max-height 0.5s ease, margin 0.5s ease, padding 0.5s ease; }
.alert-error { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-success { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }

.alert.fade-out {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
}

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

.forgot-btn { 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    background: transparent;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    padding: 4px 10px;
    text-decoration: none; 
    font-weight: 500; 
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
}
.forgot-btn:hover { 
    background: var(--input-border); 
    color: var(--text-color);
}

/* Highlighted state for forgot password */
.forgot-btn.highlight {
    color: #ef4444; /* Bright Red Text */
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1); 
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px -3px rgba(239, 68, 68, 0.3);
    animation: pulse-red 2s infinite ease-in-out alternate;
}

[data-theme="dark"] .forgot-btn.highlight {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.15);
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 4px 15px -3px rgba(239, 68, 68, 0.3); }
    100% { transform: scale(1.05); box-shadow: 0 8px 20px -3px rgba(239, 68, 68, 0.5); }
}

.toggle-password { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #64748b; transition: color 0.2s; z-index: 2;}
.toggle-password:hover { color: #38bdf8; }

.register-box {
    text-align: center;
    margin-top: 40px;
    font-size: 0.95rem;
    color: var(--text-color);
}
.register-box a {
    color: #38bdf8;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
    margin-left: 5px;
}
.register-box a:hover { color: #bae6fd; text-decoration: underline; }

/* Mobile Optimizations */
@media (max-width: 480px) {
    .app-container { padding: 15px; }
    .form-wrapper { padding: 30px 20px; border-radius: 20px; }
    .theme-toggle-wrapper { top: 15px; right: 15px; }
    .brand-logo { height: 85px; margin-bottom: 20px; }
    .form-control {
        padding: 16px 20px 16px 45px;
        font-size: 0.95rem;
    }
    .input-icon {
        left: 16px; /* Changed from 14px to 16px */
        width: 18px;
        height: 18px;
    }
    .interactive-placeholder { left: 45px; } /* Added */
    .btn-primary {
        padding: 15px;
        font-size: 1rem;
    }
    .brand-icon {
        height: 140px !important;
        margin-bottom: 10px !important;
    }
}
.register-box a:hover { color: #bae6fd; text-decoration: underline; }

/* Top Left Corner Logo */
.corner-logo {
    position: absolute;
    top: 30px;
    left: 40px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}
@media (max-width: 600px) {
    .corner-logo {
        display: none; /* Hide top left logo on mobile */
    }
    #theme-toggle {
        top: 20px !important;
        right: 20px !important;
        bottom: auto !important;
    }
}
