/* =========================================================
   Global Loading Skeleton
   Dipakai oleh semua halaman Frontend.
   ========================================================= */

:root {
    --sk-base: #eceff3;
    --sk-highlight: #f7f9fb;
    --sk-radius: 10px;
    --sk-speed: 1.35s;
    --sk-brand: #830006;
}

.skeleton {
    position: relative;
    overflow: hidden;
    background-color: var(--sk-base);
    border-radius: var(--sk-radius);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, .72) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: skeleton-shimmer var(--sk-speed) ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.skeleton-text {
    height: 12px;
    border-radius: 6px;
}

.skeleton-text--sm {
    height: 9px;
    border-radius: 5px;
}

.skeleton-text--lg {
    height: 16px;
    border-radius: 8px;
}

.skeleton-title {
    height: 22px;
    border-radius: 8px;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-block {
    border-radius: 12px;
}

.skeleton-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (prefers-reduced-motion: reduce) {

    .skeleton::after,
    .img-skeleton::after,
    .img-skeleton--direct {
        animation: none !important;
    }
}

/* =========================================================
   Skeleton untuk gambar (wrapper)
   ========================================================= */
.img-skeleton {
    position: relative;
    overflow: hidden;
    background-color: var(--sk-base);
}

.img-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, .65) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: skeleton-shimmer var(--sk-speed) ease-in-out infinite;
    pointer-events: none;
}

.img-skeleton>img {
    opacity: 0;
    transition: opacity .25s ease;
}

.img-skeleton.is-loaded::after {
    display: none;
}

.img-skeleton.is-loaded>img {
    opacity: 1;
}

.product-image-wrap {
    position: relative;
    overflow: hidden;
}

/* Untuk <img> yang diberi class langsung (tanpa wrapper) */
img.img-skeleton--direct {
    background-color: var(--sk-base);
    background-image: linear-gradient(100deg, var(--sk-base) 25%, var(--sk-highlight) 50%, var(--sk-base) 75%);
    background-size: 220% 100%;
    animation: skeleton-bg var(--sk-speed) ease-in-out infinite;
}

img.img-skeleton--direct.is-loaded {
    animation: none;
    background-image: none;
    background-color: transparent;
}

@keyframes skeleton-bg {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

/* =========================================================
   Page skeleton (navigasi & initial load)
   ========================================================= */
.page-skeleton {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: none;
    overflow: hidden;
    background: #fff;
    font-family: "Montserrat", sans-serif;
}

.page-skeleton.is-visible {
    display: block;
}

.loader-mask .page-skeleton {
    display: block;
    position: absolute;
    z-index: 1;
}

.page-skeleton__topbar {
    height: 30px;
    background: #f6f7f9;
    border-bottom: 1px solid #f0f1f3;
}

.page-skeleton__header {
    background: #fff;
    border-bottom: 1px solid #f0f1f3;
    box-shadow: 0 1px 8px rgba(0, 0, 0, .03);
}

.page-skeleton__container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.page-skeleton__header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 64px;
}

.page-skeleton__logo {
    width: 128px;
    height: 32px;
    flex-shrink: 0;
}

.page-skeleton__search {
    flex: 1;
    max-width: none;
    height: 38px;
    border-radius: 8px;
}

.page-skeleton__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.page-skeleton__icon {
    width: 34px;
    height: 34px;
}

.page-skeleton__body {
    padding-top: 20px;
    padding-bottom: 40px;
}

.page-skeleton__crumb {
    width: 170px;
    height: 10px;
    margin-bottom: 16px;
}

.page-skeleton__hero {
    width: 100%;
    aspect-ratio: 3 / 1;
    max-height: 320px;
    border-radius: 16px;
    margin-bottom: 26px;
}

.page-skeleton__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.page-skeleton__title {
    width: 160px;
    height: 18px;
}

.page-skeleton__link {
    width: 70px;
    height: 10px;
}

.page-skeleton__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.page-skeleton__card {
    border: 1px solid #f1f2f4;
    border-radius: 12px;
    padding: 0 0 12px;
    overflow: hidden;
    background: #fff;
}

.page-skeleton__thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 0;
    margin-bottom: 12px;
}

.page-skeleton__line {
    width: calc(100% - 24px);
    margin: 0 12px 8px;
}

.page-skeleton__line-sm {
    width: 55%;
    height: 9px;
    margin: 0 12px;
}

.page-skeleton__panel {
    border: 1px solid #f1f2f4;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 18px;
}

.page-skeleton__row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.page-skeleton__row:last-child {
    margin-bottom: 0;
}

.page-skeleton__avatar {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.page-skeleton__row-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Mobile */
@media (max-width: 991.98px) {
    .page-skeleton__topbar {
        display: none;
    }

    .page-skeleton__header-inner {
        height: 56px;
        gap: 10px;
    }

    .page-skeleton__logo {
        width: 74px;
        height: 26px;
    }

    .page-skeleton__search {
        height: 34px;
    }

    .page-skeleton__actions {
        gap: 8px;
    }

    .page-skeleton__icon {
        width: 26px;
        height: 26px;
    }

    .page-skeleton__body {
        padding-top: 14px;
    }

    .page-skeleton__hero {
        aspect-ratio: 16 / 9;
        max-height: 190px;
        border-radius: 12px;
        margin-bottom: 20px;
    }

    .page-skeleton__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .page-skeleton__title {
        width: 120px;
        height: 16px;
    }
}

/* =========================================================
   Progress bar tipis untuk request AJAX
   ========================================================= */
.ajax-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}

.ajax-progress.is-active {
    opacity: 1;
}

.ajax-progress>span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--sk-brand);
    border-radius: 0 3px 3px 0;
    transition: width .35s ease;
}

/* =========================================================
   Live search skeleton
   ========================================================= */
.dh-search-results.is-loading {
    padding: 6px 0;
}

.dh-sr-skeleton {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
}

.dh-sr-skeleton__thumb {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    flex-shrink: 0;
}

.dh-sr-skeleton__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dh-sr-skeleton__line {
    width: 72%;
    height: 11px;
    border-radius: 5px;
}

.dh-sr-skeleton__line-sm {
    width: 42%;
    height: 9px;
    border-radius: 5px;
}

/* =========================================================
   Skeleton tracking GoSend
   ========================================================= */
#gosend-tracking .go-body {
    position: relative;
}

#gosend-tracking .tracking-skeleton {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: none;
    padding: 20px;
    background: #fff;
}

#gosend-tracking.is-refreshing .tracking-skeleton {
    display: block;
}

.tracking-skeleton__meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.tracking-skeleton__steps {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tracking-skeleton__step {
    display: flex;
    align-items: center;
    gap: 14px;
}

.tracking-skeleton__dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tracking-skeleton__step-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
