/*
 * PDF attachments panel on the interpretation page
 * (resources/views/components/PDF-Download.blade.php).
 *
 * The panel is rendered in the employee panel and inside WordPress pages, so
 * everything is scoped under .esj-pdf and resets what host themes tend to style.
 */

/* The interpretation HTML ships its own attachments block; this panel replaces it. */
.dv-attachment-content,
.box_attachment {
    display: none !important;
}

.esj-pdf {
    --esj-ink: #1c2230;
    --esj-muted: #687086;
    --esj-line: #e6e8ef;
    --esj-paper: #fff;
    --esj-red: #d33a3a;
    --esj-red-deep: #b42a33;
    --esj-red-soft: #fdeceb;
    --esj-red-line: #f3c9c6;
    --esj-green: #12805c;
    --esj-green-deep: #0e6b4c;
    --esj-green-soft: #e4f5ed;
    --esj-green-line: #bfe3d1;
    --esj-ease: cubic-bezier(.2, .8, .2, 1);
    --esj-spring: cubic-bezier(.34, 1.56, .64, 1);
}

.esj-pdf,
.esj-pdf * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0;
    font-family: 'Yekan Bakh FaNum', 'Yekan Bakh', iranyekan, Tahoma, sans-serif !important;
    letter-spacing: normal;
    text-transform: none;
    text-shadow: none;
    text-decoration: none;
}

.esj-pdf button,
.esj-pdf a {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    background: none;
    box-shadow: none;
    border-radius: 0;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    text-align: inherit;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

/* ---- Floating button ---------------------------------------------------- */

.esj-pdf .esj-pdf__fab {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 99998;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 8px;
    border-radius: 999px;
    background: var(--esj-ink);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    box-shadow: 0 14px 30px -12px rgba(28, 34, 48, .65), 0 2px 6px rgba(28, 34, 48, .2);
    animation: esj-pdf-fab-in .6s var(--esj-spring) .3s backwards;
    transition: transform .25s var(--esj-ease), box-shadow .25s, opacity .2s;
}

.esj-pdf .esj-pdf__fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px -12px rgba(28, 34, 48, .7), 0 2px 6px rgba(28, 34, 48, .2);
}

.esj-pdf .esj-pdf__fab:focus-visible {
    outline: 3px solid #8fb0ff;
    outline-offset: 3px;
}

.esj-pdf .esj-pdf__fab-badge {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ee5d5d, var(--esj-red-deep));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}

.esj-pdf .esj-pdf__fab-icon {
    width: 22px;
    height: 22px;
    overflow: visible;
    animation: esj-pdf-nudge .8s var(--esj-ease) 1.1s;
}

.esj-pdf .esj-pdf__fab-back path {
    fill: rgba(255, 255, 255, .5);
}

.esj-pdf .esj-pdf__fab-back {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    transform: rotate(-14deg) translateX(-1px);
    transition: transform .35s var(--esj-spring);
}

.esj-pdf .esj-pdf__fab:hover .esj-pdf__fab-back,
.esj-pdf.is-open .esj-pdf__fab-back {
    transform: rotate(-26deg) translateX(-2px);
}

.esj-pdf .esj-pdf__fab-front {
    fill: #fff;
}

.esj-pdf .esj-pdf__fab-fold {
    fill: #f7b9b6;
}

.esj-pdf .esj-pdf__fab-line {
    fill: var(--esj-red);
    opacity: .55;
}

.esj-pdf .esj-pdf__count {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    font-size: 12px;
    line-height: 1;
}

@keyframes esj-pdf-fab-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.9);
    }
}

@keyframes esj-pdf-nudge {
    0%, 100% {
        transform: none;
    }
    30% {
        transform: rotate(-14deg) scale(1.08);
    }
    60% {
        transform: rotate(9deg);
    }
}

/* ---- Panel ---------------------------------------------------------------- */

.esj-pdf .esj-pdf__backdrop,
.esj-pdf .esj-pdf__grip {
    display: none;
}

.esj-pdf .esj-pdf__panel {
    position: fixed;
    left: 20px;
    bottom: 82px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    width: 400px;
    max-height: calc(100vh - 110px);
    overflow: hidden;
    background: linear-gradient(180deg, #fff3f1 0, #fff 150px);
    color: var(--esj-ink);
    border: 1px solid var(--esj-line);
    border-radius: 22px;
    box-shadow: 0 30px 70px -24px rgba(28, 34, 48, .42), 0 6px 18px rgba(28, 34, 48, .08);
    outline: none;
    visibility: hidden;
    opacity: 0;
    transform: translateY(14px) scale(.96);
    transform-origin: left bottom;
    transition: opacity .2s var(--esj-ease), transform .35s var(--esj-spring), visibility 0s linear .35s;
}

.esj-pdf.is-open .esj-pdf__panel {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
}

.esj-pdf .esj-pdf__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 14px 14px;
}

.esj-pdf .esj-pdf__heading {
    flex: 1;
    min-width: 0;
}

.esj-pdf .esj-pdf__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.esj-pdf .esj-pdf__title {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.6;
}

.esj-pdf .esj-pdf__pill {
    padding: 0 9px;
    border: 1px solid var(--esj-red-line);
    border-radius: 999px;
    background: var(--esj-red-soft);
    color: var(--esj-red-deep);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.8;
}

.esj-pdf .esj-pdf__hint {
    margin-top: 2px;
    color: var(--esj-muted);
    font-size: 12.5px;
    line-height: 1.8;
}

.esj-pdf .esj-pdf__close {
    flex: none;
    align-self: flex-start;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .75);
    color: var(--esj-muted);
    transition: background-color .15s, color .15s;
}

.esj-pdf .esj-pdf__close:hover {
    background: #fff;
    color: var(--esj-ink);
}

.esj-pdf .esj-pdf__close:focus-visible {
    outline: 2px solid var(--esj-ink);
    outline-offset: 1px;
}

.esj-pdf .esj-pdf__close svg {
    width: 18px;
    height: 18px;
}

/* Header illustration: the back sheets fan out as the panel opens. */

.esj-pdf .esj-pdf__stack {
    flex: none;
    width: 62px;
    height: 52px;
    overflow: visible;
}

.esj-pdf .esj-pdf__stack-sheet {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    transition: transform .55s var(--esj-spring) .12s;
}

.esj-pdf .esj-pdf__stack-paper {
    stroke-width: 1.5;
}

.esj-pdf .esj-pdf__stack-sheet--back .esj-pdf__stack-paper {
    fill: #fbdcd8;
    stroke: #f0c3be;
}

.esj-pdf .esj-pdf__stack-sheet--mid .esj-pdf__stack-paper {
    fill: #fff;
    stroke: #e6d2cf;
}

.esj-pdf.is-open .esj-pdf__stack-sheet--back {
    transform: rotate(-16deg) translateX(-4px);
}

.esj-pdf.is-open .esj-pdf__stack-sheet--mid {
    transform: rotate(10deg) translateX(4px);
}

.esj-pdf .esj-pdf__stack-line {
    fill: #c9cdd8;
}

/* ---- File cards ----------------------------------------------------------- */

.esj-pdf .esj-pdf__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 14px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.esj-pdf.is-open .esj-pdf__item {
    animation: esj-pdf-rise .45s var(--esj-ease) backwards;
    animation-delay: calc(var(--i, 0) * 50ms + 80ms);
}

@keyframes esj-pdf-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

.esj-pdf .esj-pdf__row {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 10px 10px 12px;
    border: 1px solid var(--esj-line);
    border-radius: 16px;
    background: var(--esj-paper);
    color: var(--esj-ink);
    text-align: right;
    transition: border-color .2s, box-shadow .2s, transform .2s var(--esj-ease), opacity .2s;
}

.esj-pdf .esj-pdf__row:hover {
    border-color: var(--esj-red-line);
    box-shadow: 0 10px 24px -14px rgba(211, 58, 58, .5);
    transform: translateY(-1px);
}

.esj-pdf .esj-pdf__row:focus-visible {
    outline: 2px solid var(--esj-ink);
    outline-offset: 2px;
}

.esj-pdf .esj-pdf__row[data-state="generating"] {
    border-color: var(--esj-red-line);
    cursor: progress;
}

.esj-pdf .esj-pdf__row[data-state="error"] {
    border-color: var(--esj-red-line);
}

.esj-pdf .esj-pdf__row[data-state="ready"] {
    border-color: var(--esj-green-line);
    background: linear-gradient(90deg, #fff 30%, var(--esj-green-soft));
    animation: esj-pdf-ready .9s var(--esj-ease);
}

.esj-pdf .esj-pdf__row[data-state="ready"]:hover {
    border-color: #8fd0b2;
    box-shadow: 0 10px 24px -14px rgba(18, 128, 92, .55);
}

.esj-pdf .esj-pdf__row[aria-disabled="true"] {
    opacity: .45;
    cursor: not-allowed;
}

.esj-pdf .esj-pdf__row[aria-disabled="true"]:hover {
    border-color: var(--esj-line);
    box-shadow: none;
    transform: none;
}

@keyframes esj-pdf-ready {
    from {
        box-shadow: 0 0 0 0 rgba(18, 128, 92, .4);
    }
    to {
        box-shadow: 0 0 0 10px rgba(18, 128, 92, 0);
    }
}

.esj-pdf .esj-pdf__tile {
    flex: none;
    display: grid;
    place-items: center;
    width: 48px;
    height: 52px;
    border-radius: 12px;
    background: var(--esj-red-soft);
    transition: background-color .2s;
}

.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__tile {
    background: #d6f0e3;
}

.esj-pdf .esj-pdf__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.esj-pdf .esj-pdf__name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.esj-pdf .esj-pdf__status {
    color: var(--esj-muted);
    font-size: 12px;
    line-height: 1.7;
}

.esj-pdf .esj-pdf__status:empty {
    display: none;
}

.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__status {
    color: var(--esj-green);
}

.esj-pdf .esj-pdf__row[data-state="error"] .esj-pdf__status {
    color: var(--esj-red);
}

.esj-pdf .esj-pdf__chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border: 1px solid var(--esj-line);
    border-radius: 999px;
    background: var(--esj-paper);
    color: var(--esj-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    transition: border-color .2s, background-color .2s, color .2s;
}

.esj-pdf .esj-pdf__row[data-state="idle"]:hover .esj-pdf__chip {
    border-color: var(--esj-ink);
    background: var(--esj-ink);
    color: #fff;
}

.esj-pdf .esj-pdf__row[aria-disabled="true"]:hover .esj-pdf__chip {
    border-color: var(--esj-line);
    background: var(--esj-paper);
    color: var(--esj-ink);
}

.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__chip {
    border-color: transparent;
    background: none;
    color: var(--esj-red-deep);
}

.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__chip {
    border-color: var(--esj-green);
    background: var(--esj-green);
    color: #fff;
    box-shadow: 0 6px 14px -6px rgba(18, 128, 92, .7);
}

.esj-pdf .esj-pdf__row[data-state="ready"]:hover .esj-pdf__chip {
    border-color: var(--esj-green-deep);
    background: var(--esj-green-deep);
}

.esj-pdf .esj-pdf__row[data-state="error"] .esj-pdf__chip {
    border-color: var(--esj-red-line);
    background: var(--esj-red-soft);
    color: var(--esj-red);
}

.esj-pdf .esj-pdf__chip-icon {
    display: none;
    width: 14px;
    height: 14px;
}

.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__chip-icon--download,
.esj-pdf .esj-pdf__row[data-state="error"] .esj-pdf__chip-icon--retry {
    display: block;
}

/* Indeterminate bar along the card's bottom edge, running right to left. */
.esj-pdf .esj-pdf__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity .2s;
}

.esj-pdf .esj-pdf__progress::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: -40%;
    width: 40%;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(211, 58, 58, 0), var(--esj-red), rgba(211, 58, 58, 0));
}

.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__progress {
    opacity: 1;
}

.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__progress::before {
    animation: esj-pdf-progress 1.4s ease-in-out infinite;
}

@keyframes esj-pdf-progress {
    to {
        right: 100%;
    }
}

/* ---- Paper icon: its lines get written right-to-left while the file is made */

.esj-pdf .esj-pdf__doc {
    display: block;
    width: 30px;
    height: 36px;
    overflow: visible;
    transition: transform .35s var(--esj-spring);
}

.esj-pdf .esj-pdf__row:hover .esj-pdf__doc {
    transform: rotate(-7deg) translateY(-2px);
}

.esj-pdf .esj-pdf__row[aria-disabled="true"]:hover .esj-pdf__doc,
.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__doc {
    transform: none;
}

.esj-pdf .esj-pdf__doc-sheet {
    fill: #fff;
    stroke: #d9d3d6;
    stroke-width: 1.5;
}

.esj-pdf .esj-pdf__doc-fold {
    fill: #f8d0cc;
    stroke: #d9d3d6;
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.esj-pdf .esj-pdf__doc-line {
    fill: #cfd3dd;
    transform-box: fill-box;
    transform-origin: 100% 50%;
}

.esj-pdf .esj-pdf__doc-tag {
    fill: var(--esj-red);
}

.esj-pdf .esj-pdf__doc-label {
    fill: #fff;
    font-size: 6.6px;
    font-weight: 800;
}

.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__doc-line {
    fill: var(--esj-ink);
    animation: esj-pdf-write 1.8s var(--esj-ease) infinite;
}

.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__doc-line:nth-of-type(2) {
    animation-delay: .25s;
}

.esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__doc-line:nth-of-type(3) {
    animation-delay: .5s;
}

.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__doc-line {
    fill: #8fb9a6;
}

@keyframes esj-pdf-write {
    0% {
        transform: scaleX(0);
        opacity: 1;
    }
    40%, 80% {
        transform: scaleX(1);
        opacity: 1;
    }
    100% {
        transform: scaleX(1);
        opacity: 0;
    }
}

.esj-pdf .esj-pdf__doc-badge {
    opacity: 0;
    transform: scale(.4);
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity .2s, transform .35s var(--esj-spring);
}

.esj-pdf .esj-pdf__doc-badge circle {
    stroke: #fff;
    stroke-width: 2;
}

.esj-pdf .esj-pdf__doc-badge path {
    fill: none;
    stroke: #fff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.esj-pdf .esj-pdf__doc-badge--ready circle {
    fill: var(--esj-green);
}

.esj-pdf .esj-pdf__doc-badge--error circle {
    fill: var(--esj-red);
}

.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__doc-badge--ready,
.esj-pdf .esj-pdf__row[data-state="error"] .esj-pdf__doc-badge--error {
    opacity: 1;
    transform: none;
}

/* The ready card is a new element, so its badge pops in with an animation. */
.esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__doc-badge--ready {
    animation: esj-pdf-pop .5s var(--esj-spring) .1s backwards;
}

@keyframes esj-pdf-pop {
    from {
        opacity: 0;
        transform: scale(.3);
    }
}

.esj-pdf .esj-pdf__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- Phones: the panel becomes a bottom sheet ----------------------------- */

@media (max-width: 640px) {
    .esj-pdf .esj-pdf__fab {
        left: 12px;
        bottom: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        font-size: 13px;
    }

    .esj-pdf.is-open .esj-pdf__fab {
        visibility: hidden;
        opacity: 0;
    }

    .esj-pdf .esj-pdf__backdrop {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 99998;
        background: rgba(20, 24, 34, .45);
        visibility: hidden;
        opacity: 0;
        transition: opacity .25s, visibility 0s linear .25s;
    }

    .esj-pdf.is-open .esj-pdf__backdrop {
        visibility: visible;
        opacity: 1;
        transition-delay: 0s;
    }

    .esj-pdf .esj-pdf__panel {
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-height: 85vh;
        padding-bottom: env(safe-area-inset-bottom);
        border-width: 1px 0 0;
        border-radius: 24px 24px 0 0;
        opacity: 1;
        transform: translateY(100%);
        transition: transform .35s var(--esj-ease), visibility 0s linear .35s;
    }

    .esj-pdf .esj-pdf__grip {
        display: block;
        flex: none;
        width: 40px;
        height: 4px;
        margin: 10px auto 0;
        border-radius: 999px;
        background: rgba(28, 34, 48, .14);
    }

    .esj-pdf .esj-pdf__head {
        padding: 8px 16px 12px 12px;
    }

    .esj-pdf .esj-pdf__stack {
        width: 52px;
        height: 44px;
    }

    .esj-pdf .esj-pdf__list {
        padding: 4px 12px 16px;
    }

    .esj-pdf .esj-pdf__tile {
        width: 44px;
        height: 48px;
    }
}

@media (max-width: 380px) {
    .esj-pdf .esj-pdf__row {
        gap: 10px;
        padding: 8px 8px 8px 10px;
    }

    .esj-pdf .esj-pdf__tile {
        width: 38px;
        height: 44px;
    }

    .esj-pdf .esj-pdf__doc {
        width: 26px;
        height: 31px;
    }

    .esj-pdf .esj-pdf__chip {
        padding: 5px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .esj-pdf .esj-pdf__fab,
    .esj-pdf .esj-pdf__fab-icon,
    .esj-pdf.is-open .esj-pdf__item,
    .esj-pdf .esj-pdf__row[data-state="ready"],
    .esj-pdf .esj-pdf__row[data-state="ready"] .esj-pdf__doc-badge--ready,
    .esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__doc-line {
        animation: none;
    }

    .esj-pdf .esj-pdf__fab,
    .esj-pdf .esj-pdf__panel,
    .esj-pdf .esj-pdf__backdrop,
    .esj-pdf .esj-pdf__stack-sheet,
    .esj-pdf .esj-pdf__row,
    .esj-pdf .esj-pdf__doc,
    .esj-pdf .esj-pdf__doc-badge {
        transition: none;
    }

    .esj-pdf .esj-pdf__row[data-state="generating"] .esj-pdf__progress::before {
        right: 0;
        width: 100%;
        animation: none;
    }
}

@media print {
    .esj-pdf {
        display: none !important;
    }
}
