/* ═══════════════════════════════════════════════════
   JUNIOR IDENTITY — Personality Layer
   Avatar, animations, micro-interactions, login premium
   ═══════════════════════════════════════════════════ */

/* ═══ LOADING SCREEN ═══ */
#loadingScreen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
#loadingScreen.fade-out {
    opacity: 0;
    visibility: hidden;
}
#loadingScreen .loading-text {
    margin-top: var(--space-4);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

/* ═══ AVATAR BASE ═══ */
.junior-avatar-wrap {
    display: block;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.junior-avatar-wrap svg.junior-face {
    display: block;
    width: 100%;
    height: 100%;
}
.junior-avatar-sm { width: 36px; height: 36px; }
.junior-avatar-md { width: 64px; height: 64px; }
.junior-avatar-lg { width: 80px; height: 80px; }
.junior-avatar-xl { width: 120px; height: 120px; }

/* ═══ AVATAR STATES ═══ */

/* Idle: breathing + blink */
.junior-idle .junior-eye {
    animation: junior-blink 4s ease-in-out infinite;
}
.junior-idle .junior-face {
    animation: junior-breathe 3s ease-in-out infinite;
}

@keyframes junior-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes junior-blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

/* Working: scanning eyes + rotating ring + pulse glow */
.junior-working .junior-eye {
    animation: junior-scan 2s ease-in-out infinite;
}
.junior-working .junior-glow {
    opacity: 1;
    animation: junior-ring-spin 2s linear infinite;
}
.junior-working .junior-face {
    animation: junior-focus 3s ease-in-out infinite;
}
.junior-working .junior-mouth {
    animation: junior-concentrate 3s ease-in-out infinite;
}

/* Scan pulse halo behind avatar during work */
.junior-status-avatar .junior-working::before {
    content: '';
    position: absolute;
    inset: -16px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-primary-glow) 0%, transparent 70%);
    animation: junior-scan-pulse 2s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes junior-scan {
    0%, 100% { transform: translateX(0) scaleY(1); }
    15% { transform: translateX(-2px) scaleY(0.85); }
    30% { transform: translateX(-2px) scaleY(1); }
    50% { transform: translateX(0) scaleY(0.15); }
    55% { transform: translateX(0) scaleY(1); }
    70% { transform: translateX(2px) scaleY(1); }
    85% { transform: translateX(2px) scaleY(0.85); }
}

@keyframes junior-focus {
    0%, 100% { transform: scale(1) translateY(0); }
    30% { transform: scale(1.02) translateY(-1px); }
    60% { transform: scale(0.98) translateY(1px); }
}

@keyframes junior-concentrate {
    0%, 100% { stroke-dasharray: none; opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes junior-ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes junior-scan-pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.9); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* ═══ ORBITING DOCUMENTS ═══ */
.junior-orbit-container {
    position: absolute;
    inset: -40px;
    pointer-events: none;
    z-index: 1;
}
.junior-orbit-doc {
    position: absolute;
    width: 24px;
    height: 30px;
    background: var(--bg-surface);
    border: 1.5px solid var(--accent-primary);
    border-radius: 3px;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: var(--accent-primary);
    box-shadow: 0 2px 8px var(--accent-primary-glow);
}
.junior-orbit-doc::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 7px;
    height: 7px;
    background: var(--accent-primary-light);
    border-left: 1.5px solid var(--accent-primary);
    border-bottom: 1.5px solid var(--accent-primary);
    border-radius: 0 0 0 2px;
}
/* Lines inside the document */
.junior-orbit-doc::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 4px;
    right: 4px;
    height: 2px;
    background: var(--accent-primary);
    opacity: 0.3;
    box-shadow: 0 -4px 0 var(--accent-primary), 0 -8px 0 var(--accent-primary);
}

.junior-orbit-doc.orbit-0 {
    animation: junior-orbit-0 4s ease-in-out infinite;
}
.junior-orbit-doc.orbit-1 {
    animation: junior-orbit-1 4.5s ease-in-out infinite 0.8s;
}
.junior-orbit-doc.orbit-2 {
    animation: junior-orbit-2 5s ease-in-out infinite 1.6s;
}

/* Scan line that sweeps across documents */
.junior-orbit-doc .scan-line {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 2px;
    background: var(--accent-primary);
    border-radius: 1px;
    opacity: 0;
    animation: junior-doc-scan 1.5s ease-in-out infinite;
    box-shadow: 0 0 4px var(--accent-primary);
}

@keyframes junior-doc-scan {
    0% { top: 4px; opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { top: calc(100% - 4px); opacity: 0; }
}

@keyframes junior-orbit-0 {
    0% { top: 50%; left: -30px; opacity: 0; transform: translate(0, -50%) scale(0.6) rotate(-10deg); }
    15% { opacity: 1; transform: translate(0, -50%) scale(1) rotate(0); }
    50% { top: 10%; left: -20px; opacity: 1; transform: translate(0, 0) scale(0.9) rotate(5deg); }
    85% { opacity: 1; transform: translate(0, 0) scale(1) rotate(-3deg); }
    100% { top: 50%; left: -30px; opacity: 0; transform: translate(0, -50%) scale(0.6) rotate(-10deg); }
}

@keyframes junior-orbit-1 {
    0% { top: -20px; right: 10px; left: auto; opacity: 0; transform: scale(0.6) rotate(8deg); }
    15% { opacity: 1; transform: scale(1) rotate(0); }
    50% { top: 10px; right: -25px; opacity: 1; transform: scale(0.9) rotate(-5deg); }
    85% { opacity: 1; transform: scale(1) rotate(3deg); }
    100% { top: -20px; right: 10px; left: auto; opacity: 0; transform: scale(0.6) rotate(8deg); }
}

@keyframes junior-orbit-2 {
    0% { bottom: -15px; left: 30%; top: auto; opacity: 0; transform: scale(0.6) rotate(-5deg); }
    15% { opacity: 1; transform: scale(1) rotate(0); }
    50% { bottom: -25px; left: 10%; opacity: 1; transform: scale(0.9) rotate(8deg); }
    85% { opacity: 1; transform: scale(1) rotate(-3deg); }
    100% { bottom: -15px; left: 30%; top: auto; opacity: 0; transform: scale(0.6) rotate(-5deg); }
}

/* Checkmark flash on document when "validated" */
.junior-orbit-doc.validated {
    border-color: var(--accent-success);
    color: var(--accent-success);
    box-shadow: 0 2px 8px rgba(5,150,105,0.3);
    animation: junior-doc-validate 0.5s ease-out forwards;
}
@keyframes junior-doc-validate {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(0); opacity: 0; }
}

/* Success: happy eyes + bounce */
.junior-success .junior-face {
    animation: junior-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.junior-success .junior-eye {
    transform: scaleY(0.6) translateY(0.5px);
}
.junior-success .junior-mouth {
    d: path("M9 17q7 5 14 0");
}

@keyframes junior-bounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Success particles */
.junior-success::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-primary-glow) 0%, transparent 70%);
    animation: junior-particle-burst 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes junior-particle-burst {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

/* Error: worried + shake + red tint */
.junior-error .junior-face {
    animation: junior-shake 0.5s ease-in-out;
    filter: hue-rotate(-40deg) saturate(1.5);
}
.junior-error .junior-eye {
    transform: scaleY(1.2) translateY(-0.5px);
}
.junior-error .junior-mouth {
    d: path("M9 19q7 -4 14 0");
}

@keyframes junior-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* ═══ LOGIN PAGE PREMIUM ═══ */

/* Animated gradient background */
.login-view {
    background: linear-gradient(-45deg, #431407, #7c2d12, #9a3412, #431407) !important;
    background-size: 400% 400% !important;
    animation: login-gradient 15s ease infinite;
    position: relative;
    overflow: hidden;
    z-index: 200;
}

[data-theme="dark"] .login-view {
    background: linear-gradient(-45deg, #1a0a04, #431407, #3b1106, #1a0a04) !important;
    background-size: 400% 400% !important;
}

@keyframes login-gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Floating particles canvas */
#loginParticles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* Login card entrance */
.login-card {
    animation: login-card-enter 0.8s ease-out both;
    position: relative;
    z-index: 1;
}

@keyframes login-card-enter {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Login avatar entrance */
.login-view .junior-avatar-wrap {
    animation: login-avatar-enter 1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

@keyframes login-avatar-enter {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

/* Login brand text override — card is white, so use dark text */
.login-view .login-card .brand p {
    color: var(--text-secondary);
}

/* ═══ CARD HOVER GLOW ═══ */
/* Géré dans styles.css — border-color + shadow-md */

/* ═══ RIPPLE EFFECT ═══ */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple-expand 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-expand {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ═══ SIDEBAR ACTIVE INDICATOR ═══ */
.nav-item {
    position: relative;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(1);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--accent-gradient);
    animation: sidebar-indicator 0.3s ease-out;
}

@keyframes sidebar-indicator {
    from { transform: translateY(-50%) scaleY(0); }
    to { transform: translateY(-50%) scaleY(1); }
}

/* ═══ TOAST PERSONALITY ═══ */
.toast {
    animation: toast-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    border-left: 4px solid var(--text-muted);
}
.toast.success { border-left-color: var(--accent-success); }
.toast.error { border-left-color: var(--accent-error); }
.toast.warning { border-left-color: var(--accent-warning); }

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.toast.dismissing { animation: toast-exit 0.25s ease forwards !important; }
@keyframes toast-exit { to { opacity: 0; transform: translateY(20px); } }

/* ═══ GRADIENT TITLES ═══ */
@supports (-webkit-background-clip: text) or (background-clip: text) {
    .view h2 {
        background: var(--accent-gradient);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    .login-view .brand h1 {
        background: var(--accent-gradient);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

/* ═══ TYPOGRAPHY POLISH ═══ */
.view h2 {
    letter-spacing: -0.02em;
    line-height: 1.2;
}

/* ═══ SIDEBAR SEPARATOR GRADIENT ═══ */
.sidebar-label {
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(90deg, rgba(255,255,255,0.1), transparent) 1;
}

/* ═══ STATUS PAGE AVATAR ═══ */
.junior-status-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}
.junior-status-avatar .junior-avatar-wrap {
    width: 64px;
    height: 64px;
}
.junior-status-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: opacity 0.4s ease;
    min-height: 1.5em;
    text-align: center;
}

/* ═══ REDUCED MOTION ═══ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .login-view {
        animation: none !important;
    }
    #loginParticles {
        display: none !important;
    }
}
