/* Animation keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.slide-in-left {
    animation: slideInLeft 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.delay-100 { animation-delay: 0.05s; }
.delay-200 { animation-delay: 0.1s; }
.delay-300 { animation-delay: 0.15s; }

.sidebar-visible {
    animation: slideInLeft 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@media (prefers-reduced-motion) {
    .animate-fade-in, .slide-in-left {
        animation: none;
        opacity: 1;
    }
}

/* Hamburger Menu Top Animation */
.hamburger-menu-top {
    width: 24px;
    height: 16px;
    position: relative;
    cursor: pointer;
}

.hamburger-menu-top span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: white;
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger-menu-top span:nth-child(1) {
    top: 0px;
}

.hamburger-menu-top span:nth-child(2) {
    top: 7px;
}

.hamburger-menu-top span:nth-child(3) {
    top: 14px;
}

.open .hamburger-menu-top span:nth-child(1) {
    top: 7px;
    transform: rotate(135deg);
}

.open .hamburger-menu-top span:nth-child(2) {
    opacity: 0;
    left: -60px;
}

.open .hamburger-menu-top span:nth-child(3) {
    top: 7px;
    transform: rotate(-135deg);
}

/* Hamburger Menu Small Animation */
.hamburger-menu-small {
    width: 20px;
    height: 14px;
    position: relative;
    margin: 0 auto;
}

.hamburger-menu-small span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: #4a90e2;
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger-menu-small span:nth-child(1) {
    top: 0px;
}

.hamburger-menu-small span:nth-child(2) {
    top: 6px;
}

.hamburger-menu-small span:nth-child(3) {
    top: 12px;
}

.open .hamburger-menu-small span:nth-child(1) {
    top: 6px;
    transform: rotate(135deg);
}

.open .hamburger-menu-small span:nth-child(2) {
    opacity: 0;
    left: -60px;
}

.open .hamburger-menu-small span:nth-child(3) {
    top: 6px;
    transform: rotate(-135deg);
}

/* Bottom Navigation Styles */
.home-button {
    top: -20px;
    z-index: 1;
}

.nav-item {
    position: relative;
    z-index: 0;
    min-width: 60px;
}

@media (max-width: 400px) {
    .nav-item span {
        font-size: 0.65rem;
    }
}

/* Mobile sidebar animation */
#sidebar {
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-font-smoothing: subpixel-antialiased;
}

/* Ensure the logout button is always visible on mobile */
@media (max-width: 768px) {
    #sidebar {
        padding-bottom: 100px; /* Extra space to ensure logout is visible */
    }
    
    #sidebar form button {
        position: relative;
        z-index: 60; /* Higher than sidebar but lower than bottom nav */
        margin-bottom: 28px; /* Extra margin to push above bottom nav */
    }
}

/* Responsive adjustments for desktop navigation */
@media (min-width: 768px) {
    .nav-links-container {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }
}

/* Modern sporty loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    background:
        radial-gradient(120% 140% at 50% -20%, rgba(56, 189, 248, 0.18), transparent 55%),
        radial-gradient(80% 100% at 100% 100%, rgba(14, 165, 233, 0.12), transparent 60%),
        rgba(2, 8, 23, 0.78);
    backdrop-filter: blur(10px) saturate(1.2);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

.loading-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 28px 28px;
    opacity: 0.32;
    mask-image: radial-gradient(circle at center, black 35%, transparent 75%);
    pointer-events: none;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loader {
    width: clamp(72px, 8vw, 102px);
    height: clamp(72px, 8vw, 102px);
    border-radius: 50%;
    position: relative;
    isolation: isolate;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle, rgba(14, 165, 233, 0.2) 0 34%, transparent 36%),
        radial-gradient(circle at 50% 50%, rgba(2, 132, 199, 0.18), rgba(2, 8, 23, 0.15));
    box-shadow:
        0 22px 45px rgba(2, 8, 23, 0.55),
        inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.loader::before,
.loader::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.loader::before {
    border: 4px solid transparent;
    border-top-color: #38bdf8;
    border-right-color: #0ea5e9;
    animation: sporty-orbit 0.9s linear infinite;
    filter: drop-shadow(0 0 10px rgba(14, 165, 233, 0.55));
}

.loader::after {
    inset: 18%;
    border: 3px dashed rgba(125, 211, 252, 0.9);
    animation: sporty-orbit-reverse 1.25s linear infinite;
    opacity: 0.95;
}

@keyframes sporty-orbit {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes sporty-orbit-reverse {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(-360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .loader::before,
    .loader::after {
        animation-duration: 2.4s;
    }
}
