/* MNES Portal startup, transitions, and reusable loading states. */

html.mnes-shell-settling .app-header,
html.mnes-shell-settling .main-nav,
html.mnes-shell-settling .app-topbar,
html.mnes-shell-settling .page-shell,
html.mnes-shell-settling .schedule-flash-wrap,
html.mnes-shell-settling .app-logo-mark,
html.mnes-shell-settling .app-logo-full,
html.mnes-shell-settling .nav-link,
html.mnes-shell-settling .nav-group-toggle,
html.mnes-shell-settling .nav-icon,
html.mnes-shell-settling .nav-label,
html.mnes-shell-settling .nav-group-toggle::after,
html.mnes-shell-settling .mnes-app-shell {
    transition: none !important;
}

body.sidebar-navigating .main-nav .nav-dropdown,
body.sidebar-navigating .main-nav .nav-group:hover .nav-dropdown,
body.sidebar-navigating .main-nav .nav-group:focus-within .nav-dropdown,
body.sidebar-navigating .main-nav .nav-group.open .nav-dropdown {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

@media (max-width: 900px) {
    html.mnes-js body .app-header {
        min-height: 58px !important;
    }

    html.mnes-js body .header-content {
        min-height: 58px !important;
        padding: 8px 14px !important;
    }

    html.mnes-js body .app-title-wrap {
        display: none !important;
    }

    html.mnes-js body .logo-box {
        justify-content: flex-start !important;
        padding: 0 !important;
    }

    html.mnes-js body .app-logo {
        width: auto !important;
        max-width: 158px !important;
        height: 36px !important;
        max-height: 36px !important;
    }

    html.mnes-js body .mobile-fab {
        position: fixed !important;
        left: 18px !important;
        right: auto !important;
        top: auto !important;
        bottom: calc(16px + env(safe-area-inset-bottom)) !important;
        width: 58px !important;
        min-width: 58px !important;
        height: 58px !important;
        min-height: 58px !important;
        z-index: 7000 !important;
        transform: none !important;
        will-change: opacity !important;
    }

    html.mnes-js body .mobile-drawer-overlay {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 6998 !important;
        overscroll-behavior: contain;
    }

    html.mnes-js body .mobile-drawer {
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        width: min(84vw, 340px) !important;
        max-width: 340px !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        z-index: 6999 !important;
        overflow: hidden !important;
        overscroll-behavior: contain;
    }

    html.mnes-js body .mobile-drawer-header {
        min-height: 66px !important;
        padding: calc(10px + env(safe-area-inset-top)) 14px 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
    }

    html.mnes-js body .mobile-drawer-title {
        min-width: 0 !important;
        display: flex !important;
        align-items: center !important;
        font-size: 0 !important;
        line-height: 0 !important;
    }

    html.mnes-js body .mobile-drawer-logo {
        display: block !important;
        width: 152px !important;
        max-width: 56vw !important;
        height: auto !important;
        max-height: 42px !important;
        object-fit: contain !important;
    }

    html.mnes-js body .mobile-close {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
    }

    html.mnes-js body .mobile-drawer-nav {
        height: calc(100dvh - 66px - env(safe-area-inset-top)) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important;
    }
}

html.mnes-js body.mnes-booting {
    overflow: hidden;
}

.mnes-app-shell {
    opacity: 1;
    transition: opacity 120ms ease;
}

html.mnes-js body.mnes-booting .mnes-app-shell {
    opacity: 0;
    pointer-events: none;
}

html.mnes-js.mnes-startup-skip body.mnes-booting .mnes-app-shell {
    opacity: 1;
    pointer-events: auto;
}

html.mnes-js body.mnes-ready .mnes-app-shell {
    opacity: 1;
}

.mnes-boot-overlay {
    display: none;
}

html.mnes-js .mnes-boot-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
        radial-gradient(circle at 50% 36%, rgba(62, 207, 142, 0.08), transparent 22rem),
        linear-gradient(135deg, #181c1b 0%, #101312 54%, #1d2220 100%);
    background-size: 86px 86px, 86px 86px, auto, auto;
    color: #f2f4f7;
    opacity: 1;
    visibility: visible;
    transition: opacity 220ms ease, visibility 220ms ease;
}

html.mnes-js.mnes-startup-skip .mnes-boot-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

html.mnes-js body.mnes-ready .mnes-boot-overlay,
html.mnes-js body.mnes-boot-complete .mnes-boot-overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.mnes-boot-panel {
    width: min(560px, 88vw);
    display: grid;
    justify-items: center;
    gap: 14px;
    text-align: center;
}

.mnes-boot-logo {
    width: min(390px, 74vw);
    height: auto;
    display: block;
    filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.34));
    animation: mnesBootPulse 1850ms ease-in-out infinite;
}

.mnes-boot-title {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f6f8f7;
}

.mnes-boot-subtitle {
    min-height: 18px;
    font-size: 12px;
    font-weight: 700;
    color: #8c96a3;
    opacity: 0.86;
    transition: opacity 220ms ease, transform 220ms ease;
}

.mnes-boot-subtitle.is-changing {
    opacity: 0;
    transform: translateY(3px);
}

.mnes-boot-line {
    width: min(330px, 70vw);
    height: 2px;
    margin-top: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
}

@media (max-width: 640px) {
    .mnes-boot-panel {
        width: min(420px, 90vw);
    }

    .mnes-boot-logo {
        width: min(310px, 78vw);
    }

    .mnes-boot-line {
        width: min(270px, 72vw);
    }
}

.mnes-boot-line span {
    display: block;
    width: 42%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, #3ecf8e, transparent);
    animation: mnesBootLine 1450ms cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.skeleton,
.skeleton-line,
.skeleton-block,
.skeleton-kpi-card,
.skeleton-scheduler-card,
.skeleton-table,
.skeleton-machine-card,
.skeleton-job-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--flat-radius, 8px);
    background: linear-gradient(180deg, #22272e, #1b1f25);
    border: 1px solid var(--flat-border, #2b3138);
}

.skeleton::after,
.skeleton-line::after,
.skeleton-block::after,
.skeleton-kpi-card::after,
.skeleton-scheduler-card::after,
.skeleton-table::after,
.skeleton-machine-card::after,
.skeleton-job-card::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.055), transparent);
    animation: mnesSkeletonShimmer 1400ms ease-in-out infinite;
}

.skeleton-line {
    height: 12px;
}

.skeleton-line.is-short {
    width: 46%;
}

.skeleton-line.is-medium {
    width: 68%;
}

.skeleton-block {
    min-height: 72px;
}

.skeleton-kpi-card,
.skeleton-scheduler-card,
.skeleton-machine-card,
.skeleton-job-card {
    min-height: 118px;
}

.skeleton-table {
    min-height: 220px;
}

.skeleton-stack {
    display: grid;
    gap: 10px;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

@keyframes mnesBootPulse {
    0%, 100% {
        opacity: 0.82;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-1px);
    }
}

@keyframes mnesBootLine {
    0% {
        transform: translateX(-115%);
    }
    100% {
        transform: translateX(255%);
    }
}

@keyframes mnesSkeletonShimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mnes-app-shell,
    html.mnes-js .mnes-boot-overlay,
    .mnes-boot-subtitle {
        transition: none;
    }

    .mnes-boot-logo,
    .mnes-boot-line span,
    .skeleton::after,
    .skeleton-line::after,
    .skeleton-block::after,
    .skeleton-kpi-card::after,
    .skeleton-scheduler-card::after,
    .skeleton-table::after,
    .skeleton-machine-card::after,
    .skeleton-job-card::after {
        animation: none;
    }
}
