/*
 * HL Document System — Login Page Styles
 * Modern dark theme with glassmorphism
 */

/* ── Reset & Variables ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-base: #08080d;
    --bg-card: rgba(18, 18, 28, 0.75);
    --bg-surface: #14141f;
    --accent-1: #6c5ce7;
    --accent-2: #00cec9;
    --accent-3: #a29bfe;
    --accent-grad: linear-gradient(135deg, #6c5ce7, #00cec9);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --border: rgba(255,255,255,0.06);
    --radius: 1.25rem;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body.auth-page {
    font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Animated Background ── */
.auth-background {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 500px at 20% 20%, rgba(108, 92, 231, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse 500px 400px at 80% 80%, rgba(0, 206, 201, 0.1) 0%, transparent 60%),
        radial-gradient(ellipse 400px 300px at 50% 50%, rgba(108, 92, 231, 0.04) 0%, transparent 70%),
        var(--bg-base);
}

.bg-circles {
    position: absolute;
    inset: 0;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.08), rgba(0, 206, 201, 0.06));
    animation: orbitFloat 24s ease-in-out infinite;
}

.circle-1 {
    width: 450px;
    height: 450px;
    top: -120px;
    right: -120px;
    animation-delay: 0s;
}

.circle-2 {
    width: 350px;
    height: 350px;
    bottom: -80px;
    left: -80px;
    animation-delay: -6s;
}

.circle-3 {
    width: 250px;
    height: 250px;
    top: 45%;
    left: 45%;
    animation-delay: -12s;
}

@keyframes orbitFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -20px) scale(1.04); }
    50% { transform: translate(-15px, 25px) scale(0.97); }
    75% { transform: translate(20px, 10px) scale(1.02); }
}

/* Grid pattern overlay */
.auth-background::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(108, 92, 231, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108, 92, 231, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 1;
}

/* ── Auth Container ── */
.auth-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 400px;
}

/* ── Auth Card ── */
.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 2.5rem 2rem 2rem;
    box-shadow: 
        0 24px 80px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    animation: cardReveal 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}

/* Top glow line */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(108, 92, 231, 0.5), rgba(0, 206, 201, 0.5), transparent);
}

@keyframes cardReveal {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Logo ── */
.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon-wrap {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 1.25rem;
    background: var(--accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.3);
    animation: logoFloat 4s ease-in-out infinite;
    position: relative;
}

.logo-icon-wrap::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 1.35rem;
    background: var(--accent-grad);
    opacity: 0.3;
    filter: blur(12px);
    z-index: -1;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.logo-icon {
    font-size: 2rem;
    line-height: 1;
    filter: grayscale(0) brightness(1.2);
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.auth-logo p {
    color: var(--text-muted);
    margin-top: 0.4rem;
    font-size: 0.82rem;
}

/* ── Form ── */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: formFade 0.4s ease;
}

@keyframes formFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-group {
    margin-bottom: 0.85rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-svg {
    position: absolute;
    left: 14px;
    z-index: 1;
    color: var(--text-muted);
    transition: color 0.25s ease;
}

.input-wrapper:focus-within .input-icon-svg {
    color: var(--accent-1);
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.25s ease;
    font-family: inherit;
    outline: none;
}

.input-wrapper input:focus {
    border-color: rgba(108, 92, 231, 0.5);
    background: rgba(108, 92, 231, 0.05);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Error Message ── */
.error-message {
    color: #ff6b6b;
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
    min-height: 1.2rem;
    text-align: center;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-grad);
    color: white;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-full {
    width: 100%;
}

.btn-login {
    border-radius: 0.875rem;
    padding: 15px 28px;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.btn-login .btn-arrow {
    transition: transform 0.25s ease;
}

.btn-login:hover .btn-arrow {
    transform: translateX(4px);
}

/* Loading State */
.btn.loading span:first-child { opacity: 0; }
.btn.loading .btn-arrow { display: none; }
.btn.loading .btn-loader { display: block; }

.btn-loader {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Auth Footer ── */
.auth-footer {
    margin-top: 1.2rem;
    padding: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.6;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .auth-card {
        padding: 2rem 1.5rem 1.5rem;
    }
    
    .logo-icon-wrap {
        width: 64px;
        height: 64px;
    }
    
    .auth-logo h1 {
        font-size: 1.3rem;
    }
}
