/* =========================================================
   CRYSTAL CITY — PREMIUM FULL-BLEED TOPBAR
========================================================= */

.topbar {
    position: relative;
    z-index: 50;
    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;

    background:
        radial-gradient(
            circle at 8% 0%,
            rgba(52, 220, 174, 0.16),
            transparent 38%
        ),
        radial-gradient(
            circle at 92% 0%,
            rgba(239, 188, 76, 0.10),
            transparent 36%
        ),
        linear-gradient(
            180deg,
            rgba(18, 65, 50, 0.98) 0%,
            rgba(8, 38, 29, 0.98) 100%
        );

    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.17),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);

    backdrop-filter: blur(22px) saturate(165%);
    -webkit-backdrop-filter: blur(22px) saturate(165%);
}

.topbar::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;

    background:
        linear-gradient(
            110deg,
            rgba(255, 255, 255, 0.065),
            transparent 42%
        );
}

.topbar::after {
    content: "";
    position: absolute;
    right: -60px;
    bottom: -95px;

    width: 190px;
    height: 190px;
    border-radius: 50%;
    pointer-events: none;

    background:
        radial-gradient(
            circle,
            rgba(45, 219, 173, 0.12),
            transparent 68%
        );
}

.topbar-actions {
    position: relative;
    z-index: 1;
}

.topbar .icon-button {
    position: relative;

    display: grid;
    place-items: center;

    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 0;
    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;

    color: #f3fcf8;

    background:
        linear-gradient(
            145deg,
            rgba(53, 111, 91, 0.70),
            rgba(17, 55, 43, 0.92)
        );

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        0 8px 18px rgba(0, 0, 0, 0.17);

    appearance: none;
    -webkit-appearance: none;

    transition:
        transform 180ms ease,
        filter 180ms ease,
        border-color 180ms ease;
}

.topbar .icon-button::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    pointer-events: none;

    background:
        linear-gradient(
            115deg,
            rgba(255, 255, 255, 0.10),
            transparent 48%
        );
}

.topbar .icon-button span {
    position: relative;
    z-index: 1;

    font-size: 14px;
    font-weight: 850;
    line-height: 1;
}

.topbar .icon-button:hover {
    filter: brightness(1.08);
    border-color: rgba(78, 224, 184, 0.28);
}

.topbar .icon-button:active {
    transform: scale(0.94);
}


/* =========================================================
   TOPBAR USER PROFILE
========================================================= */

.user-lockup {
    position: relative;
    z-index: 1;

    display: flex;
    align-items: center;
    gap: 12px;

    min-width: 0;
    flex: 1;
}

.user-avatar {
    position: relative;

    display: grid;
    place-items: center;

    width: 56px;
    height: 56px;
    flex: 0 0 56px;

    overflow: hidden;

    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;

    background:
        radial-gradient(
            circle at 30% 20%,
            rgba(255, 255, 255, 0.20),
            transparent 45%
        ),
        linear-gradient(
            145deg,
            rgba(56, 218, 171, 0.33),
            rgba(31, 89, 68, 0.88)
        );

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 8px 18px rgba(0, 0, 0, 0.17);
}

.user-avatar-image {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
    object-position: center;
}

.user-avatar-fallback {
    color: #ffffff;
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.04em;
}

.user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;

    min-width: 0;
}

.user-info strong {
    display: block;

    overflow: hidden;

    color: #ffffff;
    font-size: 16px;
    font-weight: 850;
    line-height: 1.2;
    letter-spacing: -0.025em;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-info small {
    display: block;

    margin-top: 4px;
    overflow: hidden;

    color: rgba(221, 240, 231, 0.62);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;

    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (max-width: 390px) {
    .user-lockup {
        gap: 10px;
    }

    .user-avatar {
        width: 50px;
        height: 50px;
        flex-basis: 50px;
        border-radius: 16px;
    }

    .user-info strong {
        font-size: 15px;
    }

    .user-info small {
        max-width: 130px;
        font-size: 10px;
    }
}


/* =========================================================
   CRYSTAL CITY — LOADING SCREEN
========================================================= */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;

    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;

    padding:
        env(safe-area-inset-top, 0px)
        20px
        env(safe-area-inset-bottom, 0px);

    overflow: hidden;

    background:
        radial-gradient(
            circle at 50% 42%,
            rgba(48, 221, 174, 0.18),
            transparent 32%
        ),
        radial-gradient(
            circle at 70% 18%,
            rgba(239, 190, 76, 0.10),
            transparent 28%
        ),
        linear-gradient(
            180deg,
            #071511 0%,
            #0a2019 52%,
            #07130f 100%
        );

    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transition:
        opacity 320ms ease,
        visibility 320ms ease;
}

.loading-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;

    pointer-events: none;
    opacity: 0.08;

    background-image:
        linear-gradient(
            rgba(255, 255, 255, 0.07) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.07) 1px,
            transparent 1px
        );

    background-size: 34px 34px;
}

.loading-logo {
    position: relative;
    z-index: 5;

    display: block;
    flex: 0 0 auto;

    width: 160px;
    height: 160px;

    background-image: url("/assets/icons/logo.svg?v=<?= $assetVersion ?>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;

    opacity: 1;
    visibility: visible;

    filter:
        drop-shadow(0 14px 22px rgba(0, 0, 0, 0.30))
        drop-shadow(0 0 28px rgba(54, 217, 170, 0.38));

    animation: loadingLogoFloat 1.8s ease-in-out infinite;
}

.loading-screen.is-hidden,
.loading-screen.hidden,
.loading-screen[hidden] {
    display: none !important;
}

.loading-screen.is-leaving {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes loadingLogoFloat {
    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-8px) scale(1.04);
    }
}

@media (max-width: 390px) {
    .loading-logo {
        width: 160px;
        height: 160px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading-logo {
        animation: none;
    }

    .loading-screen {
        transition: none;
    }
}