/* ============================================================
   KLYVERO_UX_STYLES_V854
   ============================================================ */


/* ------------------------------------------------------------
   SKELETONS
------------------------------------------------------------ */

.klyvero-skeleton-active {
    position: relative;
    overflow: hidden;
}


.klyvero-skeleton-text {
    min-width: 64px;
    min-height: 0.9em;

    display: inline-block !important;

    border-radius: 6px;

    color: transparent !important;
    background: #e9edf3 !important;

    user-select: none;
}


.klyvero-skeleton-panel,
.klyvero-skeleton-card {
    position: relative;

    min-height: 130px;

    overflow: hidden;

    border-radius: 12px;

    color: transparent !important;
    background: #f4f6f9 !important;
}


.klyvero-skeleton-panel::before,
.klyvero-skeleton-card::before {
    content: "";

    position: absolute;

    top: 28px;
    left: 24px;

    width: min(62%, 280px);
    height: 13px;

    border-radius: 7px;

    background: #e3e7ed;

    box-shadow:
        0 28px 0 #e8ebf0,
        0 56px 0 #eceff3;
}


.klyvero-skeleton-active::after,
.klyvero-generated-skeleton-card::after {
    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(
            100deg,
            transparent 20%,
            rgba(255, 255, 255, 0.72) 45%,
            transparent 70%
        );

    transform: translateX(-110%);

    animation:
        klyveroSkeletonSweep
        1.25s
        ease-in-out
        infinite;

    pointer-events: none;
}


@keyframes klyveroSkeletonSweep {

    to {
        transform: translateX(110%);
    }

}


/* ------------------------------------------------------------
   GENERATED CARDS
------------------------------------------------------------ */

.klyvero-generated-skeleton-card {
    position: relative;

    min-height: 190px;

    overflow: hidden;

    padding: 24px;

    border: 1px solid #e5e9ef;
    border-radius: 16px;

    background: #ffffff;
}


.klyvero-skeleton-avatar {
    width: 42px;
    height: 42px;

    display: block;

    margin-bottom: 24px;

    border-radius: 12px;

    background: #e6eaf0;
}


.klyvero-skeleton-line {
    height: 12px;

    display: block;

    margin-top: 12px;

    border-radius: 999px;

    background: #e9edf2;
}


.klyvero-skeleton-line.wide {
    width: 76%;
}


.klyvero-skeleton-line.medium {
    width: 54%;
}


.klyvero-skeleton-line.short {
    width: 34%;
}


/* ------------------------------------------------------------
   ERROR SURFACES
------------------------------------------------------------ */

.klyvero-error-card {
    width: 100%;

    display: grid;

    grid-template-columns:
        38px
        minmax(0, 1fr)
        auto;

    align-items: center;

    gap: 14px;

    padding: 17px;

    border: 1px solid #fecaca;
    border-radius: 13px;

    background: #fffafa;

    color: #7f1d1d;
}


.klyvero-error-icon {
    width: 34px;
    height: 34px;

    display: grid;

    place-items: center;

    border-radius: 50%;

    background: #fee2e2;

    color: #b91c1c;

    font-weight: 800;
}


.klyvero-error-content {
    min-width: 0;
}


.klyvero-error-content strong {
    display: block;

    margin-bottom: 4px;

    color: #991b1b;

    font-size: 13px;
}


.klyvero-error-content p {
    margin: 0;

    color: #b45353;

    font-size: 12px;
    line-height: 1.5;
}


.klyvero-error-retry {
    min-height: 36px;

    padding: 8px 11px;

    border: 1px solid #fecaca;
    border-radius: 8px;

    background: #ffffff;

    color: #991b1b;

    font: inherit;
    font-size: 11px;
    font-weight: 700;

    cursor: pointer;
}


.klyvero-error-retry:hover {
    background: #fff1f2;
}


.klyvero-error-surface:not(.hidden) {
    padding: 12px 14px !important;

    border: 1px solid #fecaca !important;
    border-radius: 10px !important;

    background: #fff7f7 !important;

    color: #991b1b !important;

    font-size: 12px;
    line-height: 1.5;
}


/* ------------------------------------------------------------
   BUSY BUTTON
------------------------------------------------------------ */

.klyvero-button-busy {
    display: inline-flex !important;

    align-items: center;
    justify-content: center;

    gap: 8px;

    cursor: wait !important;
}


.klyvero-button-spinner {
    width: 14px;
    height: 14px;

    flex: 0 0 auto;

    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;

    animation:
        klyveroButtonSpin
        0.65s
        linear
        infinite;
}


@keyframes klyveroButtonSpin {

    to {
        transform: rotate(360deg);
    }

}


/* ------------------------------------------------------------
   BUSY REGION
------------------------------------------------------------ */

.klyvero-region-busy {
    position: relative;

    pointer-events: none;

    opacity: 0.72;
}


.klyvero-region-busy::after {
    content: "";

    position: absolute;

    inset: 0;

    z-index: 10;

    border-radius: inherit;

    background:
        linear-gradient(
            100deg,
            transparent,
            rgba(255, 255, 255, 0.44),
            transparent
        );

    background-size: 200% 100%;

    animation:
        klyveroRegionSweep
        1.2s
        linear
        infinite;
}


@keyframes klyveroRegionSweep {

    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }

}


/* ------------------------------------------------------------
   NETWORK STATUS
------------------------------------------------------------ */

.klyvero-network-banner {
    position: fixed;

    left: 50%;
    bottom: 22px;

    z-index: 2147483500;

    max-width: calc(100vw - 32px);

    padding: 10px 14px;

    border-radius: 999px;

    box-shadow:
        0 12px 36px
        rgba(15, 23, 42, 0.16);

    opacity: 0;

    transform:
        translate(
            -50%,
            12px
        );

    transition:
        opacity 180ms ease,
        transform 180ms ease;

    pointer-events: none;

    font-size: 11px;
    font-weight: 700;
}


.klyvero-network-banner.visible {
    opacity: 1;

    transform:
        translate(
            -50%,
            0
        );
}


.klyvero-network-banner.offline {
    border: 1px solid #fed7aa;

    background: #fff7ed;

    color: #9a3412;
}


.klyvero-network-banner.online {
    border: 1px solid #bbf7d0;

    background: #f0fdf4;

    color: #166534;
}


/* ------------------------------------------------------------
   ROUTE PROGRESS
------------------------------------------------------------ */

.klyvero-route-progress {
    position: fixed;

    top: 0;
    left: 0;

    z-index: 2147483600;

    width: 0;
    height: 3px;

    opacity: 0;

    background:
        linear-gradient(
            90deg,
            #3b82f6,
            #8b5cf6
        );

    box-shadow:
        0 0 12px
        rgba(99, 102, 241, 0.35);
}


.klyvero-route-progress.active {
    width: 88%;

    opacity: 1;

    transition:
        width
        2.8s
        cubic-bezier(
            0.1,
            0.7,
            0.25,
            1
        ),
        opacity
        120ms
        ease;
}


/* ------------------------------------------------------------
   FALLBACK TOASTS
------------------------------------------------------------ */

.klyvero-ux-toast-container {
    position: fixed;

    top: 18px;
    right: 18px;

    z-index: 2147483550;

    width:
        min(
            380px,
            calc(100vw - 36px)
        );

    display: flex;
    flex-direction: column;

    gap: 9px;

    pointer-events: none;
}


.klyvero-ux-toast {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        28px;

    align-items: center;

    gap: 10px;

    padding: 12px 13px;

    border: 1px solid #e2e8f0;
    border-radius: 11px;

    background: #ffffff;

    box-shadow:
        0 14px 38px
        rgba(15, 23, 42, 0.14);

    opacity: 0;

    transform: translateY(-7px);

    transition:
        opacity 160ms ease,
        transform 160ms ease;

    pointer-events: auto;

    color: #334155;

    font-size: 12px;
    font-weight: 600;
}


.klyvero-ux-toast.visible {
    opacity: 1;

    transform: translateY(0);
}


.klyvero-ux-toast.leaving {
    opacity: 0;
}


.klyvero-ux-toast.error {
    border-color: #fecaca;
}


.klyvero-ux-toast.success {
    border-color: #bbf7d0;
}


.klyvero-ux-toast-close {
    width: 28px;
    height: 28px;

    border: 0;
    border-radius: 7px;

    background: transparent;

    color: #64748b;

    font: inherit;
    font-size: 18px;

    cursor: pointer;
}


/* ------------------------------------------------------------
   RESPONSIVE
------------------------------------------------------------ */

@media (max-width: 700px) {

    .klyvero-error-card {
        grid-template-columns:
            34px
            minmax(0, 1fr);
    }


    .klyvero-error-retry {
        grid-column: 1 / -1;

        width: 100%;
    }


    .klyvero-network-banner {
        width: calc(100vw - 28px);

        border-radius: 10px;

        text-align: center;
    }

}


/* ------------------------------------------------------------
   REDUCED MOTION
------------------------------------------------------------ */

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

    .klyvero-skeleton-active::after,
    .klyvero-generated-skeleton-card::after,
    .klyvero-button-spinner,
    .klyvero-region-busy::after {
        animation: none;
    }


    .klyvero-route-progress {
        transition: none;
    }

}


/* ============================================================
   KLYVERO_QOL_POLISH_V95
   Shared UX polish, safe above existing pages.
   ============================================================ */

/* Better focus indicators */

:where(
    button,
    a,
    input,
    textarea,
    select,
    [role="button"]
):focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 3px;
}

/* Input usability */

:where(input, textarea, select) {
    accent-color: #3b82f6;
}

:where(input, textarea, select):disabled {
    cursor: not-allowed;
    opacity: .65;
}

:where(button):disabled {
    cursor: not-allowed;
}

/* Buttons, without overriding existing branded colors */

:where(
    .primary-button,
    .secondary-button,
    .login-submit,
    .button,
    .nav-button
) {
    transition:
        box-shadow 180ms ease,
        border-color 180ms ease,
        background-color 180ms ease,
        transform 180ms ease;
}

:where(
    .primary-button,
    .secondary-button,
    .login-submit,
    .button
):not(:disabled):active {
    transform: scale(.985);
}

/* Reusable surface consistency */

:where(
    .dashboard-card,
    .metric-card,
    .stat-card,
    .settings-card,
    .analytics-card
) {
    border-radius: 14px;
}

/* Table readability without restyling all tables */

:where(table) {
    border-collapse: separate;
    border-spacing: 0;
}

:where(th) {
    font-weight: 700;
}

:where(td, th) {
    vertical-align: middle;
}

/* Existing UX reliability components */

.klyvero-error-card {
    border-radius: 14px;
    overflow-wrap: anywhere;
}

.klyvero-error-retry {
    min-height: 36px;
    border-radius: 9px;
    cursor: pointer;
}

.klyvero-network-banner {
    overflow-wrap: anywhere;
}

.klyvero-ux-toast {
    border-radius: 12px;
    overflow-wrap: anywhere;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
}

.klyvero-skeleton-card,
.klyvero-generated-skeleton-card {
    border-radius: 13px;
}

/* Touch targets */

@media (pointer: coarse) {
    :where(
        .primary-button,
        .secondary-button,
        .login-submit
    ) {
        min-height: 42px;
    }
}

/* Mobile layout protection */

@media (max-width: 640px) {
    :where(
        .klyvero-error-card,
        .klyvero-network-banner,
        .klyvero-ux-toast
    ) {
        max-width: 100%;
    }

    :where(input, textarea, select) {
        max-width: 100%;
    }
}

/* Respect accessibility settings */

@media (prefers-reduced-motion: reduce) {
    .klyvero-skeleton-active,
    .klyvero-button-spinner {
        animation-duration: .01ms !important;
    }

    :where(
        .primary-button,
        .secondary-button,
        .login-submit,
        .button,
        .nav-button
    ) {
        transition: none !important;
    }
}
