/* ─── Kontrol cerdas loading (IspLoadGuard) ─── */

html.isp-lite-mode .dash-reveal,
html.isp-lite-mode .dash-reveal.is-visible {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

html.isp-lite-mode .scroll-progress,
html.isp-lite-mode .dash-hero__mesh {
    animation: none !important;
}

html.isp-lite-mode .motion-fade-up,
html.isp-lite-mode [class*="motionFade"] {
    animation: none !important;
}

/* Modul ISP — animasi reveal tanpa mengubah layout/tabel */
html.isp-lite-mode [data-isp-animate],
html.isp-lite-mode [class*="-layout--ready"] [data-isp-animate],
html.isp-lite-mode [class*="isp-"][class*="-layout"]:not([class*="--ready"]) .isp-stat-card,
html.isp-lite-mode [class*="isp-"][class*="-layout"]:not([class*="--ready"]) [data-isp-stat-card],
html.isp-lite-mode .isp-invoices-layout:not(.isp-invoices-layout--ready) .isp-invoices-stat-strip .isp-stat-card,
html.isp-lite-mode .isp-region-layout:not(.isp-region-layout--ready) .isp-region-stat-strip .isp-stat-card,
html.isp-lite-mode .isp-customers-layout:not(.isp-customers-layout--ready) .isp-stat-card,
html.isp-lite-mode .isp-isolation-layout:not(.isp-isolation-layout--ready) .isp-stat-card {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

/* Mode ringan: layout & tabel tetap responsif (tanpa transform parent yang merusak scroll) */
html.isp-lite-mode .app-shell,
html.isp-lite-mode .app-main,
html.isp-lite-mode .isp-module-manager,
html.isp-lite-mode [class*="isp-"][class*="-layout"],
html.isp-lite-mode .ctrl-card,
html.isp-lite-mode .ctrl-card__table-scroll {
    min-width: 0;
    max-width: 100%;
}

html.isp-lite-mode .isp-module-manager__table-card,
html.isp-lite-mode .ctrl-card__table-scroll,
html.isp-lite-mode .isp-module-manager__toolbar-main,
html.isp-lite-mode .ctrl-card__foot {
    transform: none !important;
}

html.isp-lite-mode .app-topbar__title-row {
    flex-wrap: wrap;
    row-gap: 6px;
    align-items: center;
}

html.isp-lite-mode .app-topbar__heading {
    min-width: 0;
    flex: 1 1 auto;
}

.app-topbar__lite-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(255, 251, 235, 0.95);
    color: #92400e;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.app-topbar__lite-chip:hover {
    background: #fffbeb;
    border-color: rgba(245, 158, 11, 0.55);
}

.app-topbar__lite-chip:focus-visible {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

.app-topbar__lite-chip i {
    font-size: 0.75rem;
}

.isp-load-guard-hint {
    position: fixed;
    top: calc(var(--shell-chrome-h, 58px) + 8px);
    left: 50%;
    z-index: 10050;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: min(92vw, 420px);
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(30, 90, 168, 0.18);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
    transform: translateX(-50%);
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1e293b;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: ispLoadGuardHintIn 0.28s ease-out both;
}

.isp-load-guard-hint__pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1e5aa8;
    box-shadow: 0 0 0 0 rgba(30, 90, 168, 0.45);
    animation: ispLoadGuardPulse 1.4s ease-out infinite;
}

.isp-load-guard-panel {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: ispLoadGuardFadeIn 0.24s ease-out both;
}

.isp-load-guard-panel--dismissed {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.isp-load-guard-panel__card {
    width: min(100%, 440px);
    padding: 20px 20px 18px;
    border-radius: 16px;
    border: 1px solid rgba(228, 230, 235, 0.95);
    background: #fff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.isp-load-guard-panel__head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.isp-load-guard-panel__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(30, 90, 168, 0.1);
    color: #1e5aa8;
    font-size: 1.125rem;
    flex-shrink: 0;
}

/* Pemberitahuan tenang — informatif, bukan alarm */
.isp-load-guard-notice {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 10055;
    width: min(92vw, 440px);
    transform: translateX(-50%);
    animation: ispLoadGuardHintIn 0.28s ease-out both;
}

.isp-load-guard-notice__inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(30, 90, 168, 0.2);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
}

.isp-load-guard-notice--watch .isp-load-guard-notice__inner {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(255, 251, 235, 0.98);
}

.isp-load-guard-notice__icon {
    flex-shrink: 0;
    color: #1e5aa8;
    font-size: 1.125rem;
    margin-top: 2px;
}

.isp-load-guard-notice--watch .isp-load-guard-notice__icon {
    color: #b45309;
}

.isp-load-guard-notice__body {
    flex: 1;
    min-width: 0;
}

.isp-load-guard-notice__title {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.isp-load-guard-notice__detail {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #64748b;
}

.isp-load-guard-notice__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.isp-load-guard-notice__close {
    flex-shrink: 0;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.isp-load-guard-notice__close:hover {
    color: #64748b;
}

.isp-load-guard-panel__head h2 {
    margin: 0 0 4px;
    font-size: 1.0625rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.isp-load-guard-panel__head p {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #64748b;
}

.isp-load-guard-panel__steps {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: grid;
    gap: 8px;
}

.isp-load-guard-panel__steps li {
    position: relative;
    padding: 8px 10px 8px 30px;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 0.8125rem;
    color: #64748b;
}

.isp-load-guard-panel__steps li::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 50%;
    background: #cbd5e1;
}

.isp-load-guard-panel__steps li.is-active {
    color: #164578;
    background: rgba(231, 243, 255, 0.85);
}

.isp-load-guard-panel__steps li.is-active::before {
    background: #1e5aa8;
    animation: ispLoadGuardPulse 1.2s ease-out infinite;
}

.isp-load-guard-panel__steps li.is-done {
    color: #0f766e;
    background: rgba(236, 253, 245, 0.9);
}

.isp-load-guard-panel__steps li.is-done::before {
    background: #10b981;
}

.isp-load-guard-panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@keyframes ispLoadGuardPulse {
    0% { box-shadow: 0 0 0 0 rgba(30, 90, 168, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(30, 90, 168, 0); }
    100% { box-shadow: 0 0 0 0 rgba(30, 90, 168, 0); }
}

@keyframes ispLoadGuardHintIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes ispLoadGuardFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 640px) {
    .isp-load-guard-hint {
        top: auto;
        bottom: 16px;
    }

    .isp-load-guard-panel__actions {
        flex-direction: column;
    }

    .isp-load-guard-panel__actions .btn {
        width: 100%;
    }

    .app-topbar__lite-chip {
        margin-inline-start: 0;
        flex: 0 1 auto;
        max-width: 100%;
    }

    html.isp-lite-mode .app-topbar__title-row {
        gap: 8px;
    }

    html.isp-lite-mode .isp-module-manager__toolbar-actions,
    html.isp-lite-mode .ctrl-card__foot-group {
        flex-wrap: wrap;
    }

    .isp-load-guard-notice {
        bottom: 12px;
        width: min(94vw, 440px);
    }

    .isp-load-guard-notice__actions {
        flex-direction: column;
    }

    .isp-load-guard-notice__actions .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .isp-load-guard-hint,
    .isp-load-guard-panel,
    .isp-load-guard-hint__pulse,
    .isp-load-guard-panel__steps li.is-active::before {
        animation: none !important;
    }
}
