/* ============================================================
   LIC Dashboard — Premium Login Page Styles
   ============================================================ */

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

:root {
    --bg: #0a0e1a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-border-hover: rgba(255, 255, 255, 0.18);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --error: #ef4444;
    --error-dim: rgba(239, 68, 68, 0.1);
    --error-border: rgba(239, 68, 68, 0.3);
    --input-bg: rgba(255, 255, 255, 0.04);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus-border: rgba(102, 126, 234, 0.5);
    --input-focus-glow: rgba(102, 126, 234, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Animated Background Orbs --- */
.bg-orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    will-change: transform;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #667eea 0%, transparent 70%);
    top: -15%;
    left: -10%;
    animation: orbFloat1 18s ease-in-out infinite;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #764ba2 0%, transparent 70%);
    bottom: -10%;
    right: -8%;
    animation: orbFloat2 22s ease-in-out infinite;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #10b981 0%, transparent 70%);
    top: 50%;
    left: 60%;
    opacity: 0.18;
    animation: orbFloat3 25s ease-in-out infinite;
}

.orb-4 {
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, #f59e0b 0%, transparent 70%);
    top: 20%;
    right: 20%;
    opacity: 0.12;
    animation: orbFloat4 20s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(60px, 80px) scale(1.1); }
    50% { transform: translate(-30px, 120px) scale(0.95); }
    75% { transform: translate(40px, -40px) scale(1.05); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(-70px, -60px) scale(1.08); }
    50% { transform: translate(40px, -100px) scale(0.92); }
    75% { transform: translate(-50px, 50px) scale(1.04); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-80px, 60px) scale(1.15); }
    66% { transform: translate(60px, -80px) scale(0.9); }
}

@keyframes orbFloat4 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, 70px) scale(1.1); }
    66% { transform: translate(-60px, -50px) scale(0.95); }
}

/* --- Noise Overlay --- */
.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Main Container --- */
.login-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 460px;
    padding: 2rem 1.25rem;
}

/* --- Glassmorphism Card --- */
.login-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    padding: 2.5rem 2rem;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 4px 60px rgba(0, 0, 0, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.2);
    animation: cardEntrance 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Card top highlight edge */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

/* Subtle gradient shimmer */
.login-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        from 180deg at 50% 50%,
        transparent 0deg,
        rgba(102, 126, 234, 0.03) 60deg,
        transparent 120deg,
        rgba(118, 75, 162, 0.03) 240deg,
        transparent 360deg
    );
    animation: shimmer 8s linear infinite;
    pointer-events: none;
}

@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes shimmer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Brand --- */
.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.brand-icon {
    display: flex;
    filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.3));
    animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.3)); }
    50% { filter: drop-shadow(0 2px 16px rgba(102, 126, 234, 0.5)); }
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

/* --- Steps --- */
.step {
    display: none;
    position: relative;
    z-index: 1;
}

.step-active {
    display: block;
    animation: stepIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes stepIn {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.step-out {
    animation: stepOut 0.25s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes stepOut {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-20px);
    }
}

.step-header {
    text-align: center;
    margin-bottom: 1.75rem;
    position: relative;
}

.step-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.step-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Back Button --- */
.back-btn {
    position: absolute;
    left: 0;
    top: 0.15rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.back-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

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

.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    pointer-events: none;
    z-index: 1;
}

.form-input {
    width: 100%;
    height: 48px;
    padding: 0 14px 0 44px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    outline: none;
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.form-input:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--input-focus-glow);
    background: rgba(255, 255, 255, 0.06);
}

.form-input:focus ~ .input-icon,
.form-input:focus + .input-icon {
    color: var(--gradient-start);
}

.input-wrapper:focus-within .input-icon {
    color: var(--gradient-start);
}

/* --- Password Toggle --- */
.password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
    z-index: 1;
}

.password-toggle:hover {
    color: var(--text-secondary);
}

/* --- Error Messages --- */
.error-message {
    font-size: 0.8rem;
    color: var(--error);
    margin-bottom: 1rem;
    padding: 0;
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    transition: all var(--transition-normal);
    line-height: 1.4;
}

.error-message.visible {
    padding: 0.65rem 0.85rem;
    min-height: auto;
    max-height: 80px;
    background: var(--error-dim);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    animation: errorShake 0.4s ease-in-out;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* --- Primary Button --- */
.btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: #fff;
    box-shadow: 0 2px 16px rgba(102, 126, 234, 0.25);
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-primary:hover:not(:disabled)::before {
    opacity: 1;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 24px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-text {
    position: relative;
    z-index: 1;
    transition: opacity var(--transition-fast);
}

.btn-loader {
    position: absolute;
    display: none;
}

.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading .btn-loader {
    display: flex;
}

.spinner {
    width: 22px;
    height: 22px;
    animation: spin 0.75s linear infinite;
}

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

/* --- TOTP Inputs --- */
.totp-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.75rem;
}

.totp-shield {
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    color: var(--gradient-start);
    animation: shieldPulse 2.5s ease-in-out infinite;
}

@keyframes shieldPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.15);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(102, 126, 234, 0);
    }
}

.totp-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.totp-digit {
    width: 48px;
    height: 56px;
    text-align: center;
    font-family: 'Inter', monospace;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    outline: none;
    caret-color: var(--gradient-start);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast),
        transform var(--transition-fast);
}

.totp-digit:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

.totp-digit:focus {
    border-color: var(--gradient-start);
    box-shadow: 0 0 0 3px var(--input-focus-glow);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.totp-digit.filled {
    border-color: var(--gradient-start);
    background: rgba(102, 126, 234, 0.08);
}

.totp-digit.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
    animation: digitShake 0.35s ease-in-out;
}

@keyframes digitShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

.totp-separator {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0 2px;
    user-select: none;
}

/* --- QR Code Section --- */
.qr-section {
    text-align: center;
}

.qr-frame {
    display: inline-block;
    position: relative;
    padding: 16px;
    margin-bottom: 1rem;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.qr-image {
    display: block;
    width: 180px;
    height: 180px;
    border-radius: 4px;
    image-rendering: pixelated;
}

.qr-corners span {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gradient-start);
}

.qr-corners span:nth-child(1) { top: 6px; left: 6px; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.qr-corners span:nth-child(2) { top: 6px; right: 6px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.qr-corners span:nth-child(3) { bottom: 6px; left: 6px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.qr-corners span:nth-child(4) { bottom: 6px; right: 6px; border-left: none; border-top: none; border-radius: 0 0 6px 0; }

.qr-apps {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.qr-app-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 100px;
}

.secret-section {
    margin-bottom: 0.5rem;
}

.secret-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.secret-value-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
}

.secret-value {
    font-family: 'Inter', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gradient-start);
    letter-spacing: 0.08em;
    word-break: break-all;
}

.copy-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.copy-btn:hover {
    color: var(--text-primary);
}

.copy-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #fff;
    background: var(--success);
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-fast);
}

.copy-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Password Strength --- */
.password-strength {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(-4px);
    transition: all var(--transition-normal);
}

.password-strength.visible {
    opacity: 1;
    transform: translateY(0);
}

.strength-bars {
    display: flex;
    gap: 4px;
    flex: 1;
}

.strength-bar {
    height: 4px;
    flex: 1;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.08);
    transition: background var(--transition-normal);
}

.strength-bar.active {
    background: var(--error);
}

.password-strength[data-strength="2"] .strength-bar.active {
    background: var(--warning);
}

.password-strength[data-strength="3"] .strength-bar.active {
    background: #22d3ee;
}

.password-strength[data-strength="4"] .strength-bar.active {
    background: var(--success);
}

.strength-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 48px;
    text-align: right;
}

/* --- Password Rules --- */
.password-rules {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.rule {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.rule-icon {
    flex-shrink: 0;
    transition: color var(--transition-fast);
    color: rgba(255, 255, 255, 0.12);
}

.rule.met {
    color: var(--success);
}

.rule.met .rule-icon {
    color: var(--success);
}

/* --- Success Animation --- */
.success-animation {
    text-align: center;
    padding: 2rem 0;
}

.success-circle {
    display: inline-flex;
    animation: successPop 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes successPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.success-circle-bg {
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: circleStroke 0.6s 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes circleStroke {
    to { stroke-dashoffset: 0; }
}

.success-check {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: checkDraw 0.4s 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes checkDraw {
    to { stroke-dashoffset: 0; }
}

/* --- Footer --- */
.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.login-footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .login-container {
        padding: 1.5rem 1rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
        border-radius: var(--radius-lg);
    }

    .totp-digit {
        width: 42px;
        height: 50px;
        font-size: 1.2rem;
    }

    .totp-inputs {
        gap: 6px;
    }

    .qr-image {
        width: 150px;
        height: 150px;
    }

    .step-title {
        font-size: 1.2rem;
    }
}

/* --- Focus-Visible for accessibility --- */
*:focus-visible {
    outline: 2px solid var(--gradient-start);
    outline-offset: 2px;
}

.form-input:focus-visible,
.totp-digit:focus-visible {
    outline: none; /* We use custom focus styles */
}

/* --- Selection --- */
::selection {
    background: rgba(102, 126, 234, 0.3);
    color: #fff;
}
