﻿/* ==========================================================
   AI PDF SUMMARY - ENHANCED ACCORDION DESIGN
   Inspired by the approved AI Page Summary component.
   Existing Razor view and JavaScript remain unchanged.
   ========================================================== */

/* ---------- Main accordion ---------- */

.summary-accordion {
    padding-top: 40px;
}

    .summary-accordion .accordion-item {
        overflow: hidden;
        border: 1px solid #5aacc1;
        border-radius: 5px;
        background: linear-gradient( 180deg, rgba(255, 255, 255, 0.96) 0%, rgba(235, 247, 251, 0.98) 100% );
        transition: border-color 250ms ease, box-shadow 250ms ease;
    }

        .summary-accordion .accordion-item:hover {
            border-color: #418397;
            box-shadow: 0 5px 22px rgba(3, 80, 105, 0.08);
        }

    /* ---------- Accordion heading ---------- */

    .summary-accordion .accordion-button {
        position: relative;
        display: flex;
        align-items: center;
        gap: 20px;
        width: 100%;
        min-height: 124px;
        padding: 24px 30px;
        border: 0;
        border-radius: 0;
        background: linear-gradient( 180deg, rgba(255, 255, 255, 0.98) 0%, rgba(239, 249, 252, 0.96) 100% );
        color: #303c3e;
        box-shadow: none !important;
        text-align: left;
        transition: background 250ms ease;
    }

        .summary-accordion .accordion-button:hover {
            background: linear-gradient( 180deg, #ffffff 0%, #eaf7fb 100% );
        }

        .summary-accordion .accordion-button:focus,
        .summary-accordion .accordion-button:focus-visible {
           /* outline: 2px solid #418397;*/
            outline-offset: -4px;
            box-shadow: none !important;
        }

        /* Subtle animated accent across the top when expanded */

        .summary-accordion .accordion-button[aria-expanded="true"]::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: linear-gradient( 90deg, #5badc2, #418397, #7fd1e6, #418397, #5badc2 );
            background-size: 200% 100%;
            animation: pdfSummaryBar 4s linear infinite;
            pointer-events: none;
        }

@keyframes pdfSummaryBar {
    to {
        background-position: 200% 0;
    }
}

/* ---------- Left sparkle icon ---------- */

.summary-accordion .accordion-button .left-icon {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(3, 151, 201, 0.06);
}

    .summary-accordion .accordion-button .left-icon img {
        display: block;
        width: 34px;
        height: 34px;
        object-fit: contain;
        transform-origin: center;
        animation: pdfSummarySparkle 2.6s ease-in-out infinite;
    }

    /* Soft pulse around the sparkle */

    .summary-accordion .accordion-button .left-icon::before,
    .summary-accordion .accordion-button .left-icon::after {
        content: "";
        position: absolute;
        inset: 2px;
        border: 1px solid rgba(3, 151, 201, 0.45);
        border-radius: 50%;
        opacity: 0;
        pointer-events: none;
        animation: pdfSummaryRing 2.6s ease-out infinite;
    }

    .summary-accordion .accordion-button .left-icon::after {
        animation-delay: 1.3s;
    }

@keyframes pdfSummarySparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow( 0 0 2px rgba(3, 151, 201, 0.12) );
    }

    40% {
        transform: scale(1.12) rotate(8deg);
        filter: drop-shadow( 0 0 6px rgba(3, 151, 201, 0.35) );
    }

    70% {
        transform: scale(0.96) rotate(-4deg);
    }
}

@keyframes pdfSummaryRing {
    0% {
        transform: scale(0.85);
        opacity: 0.55;
    }

    100% {
        transform: scale(1.65);
        opacity: 0;
    }
}

/* Calm the sparkle while the accordion is expanded */

.summary-accordion
.accordion-button[aria-expanded="true"]
.left-icon img {
    animation-duration: 3.8s;
}

.summary-accordion
.accordion-button[aria-expanded="true"]
.left-icon::before,
.summary-accordion
.accordion-button[aria-expanded="true"]
.left-icon::after {
    animation-duration: 3.8s;
}

/* ---------- Heading and subtitle ---------- */

/* The existing span contains both the title and subtitle.
   Stack them vertically to prevent inline wrapping. */

.summary-accordion .accordion-button > span {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    margin: 0;
    color: #303c3e;
    font-family: "DIN", sans-serif;
    /*font-size: 21px;
    font-weight: 400;
    line-height: 1.5;*/
    letter-spacing: 0;
}

    /* Main heading */

    .summary-accordion .accordion-button > span b {
        position: relative;
        display: block;
        width: 100%;
        margin: 0 0 7px;
        padding-bottom: 9px;
        color: #418397;
      /*  font-family: "DIN", sans-serif;
        font-size: 28px;
        font-weight: 600;
        line-height: 1.35;
        letter-spacing: 0.04em;*/
        text-transform: uppercase;
    }

        /* Animated blue underline */

        .summary-accordion .accordion-button > span b::after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            width: 76px;
            height: 2px;
            border-radius: 2px;
            background: linear-gradient( 90deg, #418397 0%, #5badc2 55%, rgba(127, 209, 230, 0) 100% );
            background-size: 200% 100%;
            transform-origin: left center;
            animation: pdfSummaryUnderline 3s ease-in-out infinite;
        }

@keyframes pdfSummaryUnderline {
    0%, 100% {
        background-position: 0 0;
        transform: scaleX(0.85);
    }

    50% {
        background-position: 100% 0;
        transform: scaleX(1);
    }
}

/* ---------- Right-side icon ---------- */

/* Keep the supplied icon area, but style it as a subtle circle.
   Your existing show/hide icon classes continue to work. */

.summary-accordion .accordion-button .right-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 66px;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: rgba(3, 151, 201, 0.13);
    transition: background 250ms ease, transform 250ms ease;
}

.summary-accordion .accordion-button:hover .right-icon {
    background: rgba(3, 151, 201, 0.2);
}

.summary-accordion .accordion-button .right-icon img {
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
    transition: transform 300ms ease;
}

.summary-accordion .accordion-button .right-icon .show-icon {
    display: none;
}

.summary-accordion .accordion-button .right-icon .hide-icon {
    display: block;
    max-width: 34px;
    width: 100%;
}

.summary-accordion
.accordion-button[aria-expanded="true"]
.right-icon .show-icon {
    display: block;
}

.summary-accordion
.accordion-button[aria-expanded="true"]
.right-icon .hide-icon {
    display: none;
}

/* Use Bootstrap's arrow only if the supplied HTML doesn't
   already provide its own arrow image. */

.summary-accordion .accordion-button::after {
    display: none;
}

/* ---------- Accordion collapse animation ---------- */

.summary-accordion .accordion-collapse {
    border: 0;
}

.summary-accordion .accordion-body {
    padding: 0 30px 28px;
    color: #262425;
}

    /* Divider above the generated response */

    .summary-accordion .accordion-body #pdfSummaryContent {
        position: relative;
        padding-top: 24px;
       /* border-top: 1px solid rgba(0, 0, 0, 0.12);*/
    }

/* ---------- Loader ---------- */

#pdfSummaryLoader {
    padding: 28px 20px 32px;
    text-align: center;
}

    #pdfSummaryLoader .spinner-border {
        display: inline-block;
        width: 34px;
        height: 34px;
        border: 3px solid #d5e8ee;
        border-top-color: #418397;
        border-radius: 50%;
        animation: pdfSummarySpin 0.8s linear infinite;
    }

@keyframes pdfSummarySpin {
    to {
        transform: rotate(360deg);
    }
}

#pdfSummaryLoader p {
    margin: 14px 0 18px;
    color: #667a82;
    font-family: "DIN", sans-serif;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.5;
    background: linear-gradient( 90deg, #667a82 25%, #418397 50%, #667a82 75% );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pdfSummaryTextShimmer 1.8s linear infinite;
}

@keyframes pdfSummaryTextShimmer {
    to {
        background-position: -200% 0;
    }
}

/* Loading skeleton */

#pdfSummaryLoader .ai-skel {
    display: grid;
    gap: 12px;
    margin-top: 22px;
    text-align: left;
}

    #pdfSummaryLoader .ai-skel i {
        display: block;
        height: 14px;
        border-radius: 7px;
        background: linear-gradient( 90deg, #e3f0f5 25%, #f5fafc 50%, #e3f0f5 75% );
        background-size: 200% 100%;
        animation: pdfSummarySkeleton 1.3s infinite;
    }

        #pdfSummaryLoader .ai-skel i:nth-child(1) {
            width: 94%;
        }

        #pdfSummaryLoader .ai-skel i:nth-child(2) {
            width: 100%;
        }

        #pdfSummaryLoader .ai-skel i:nth-child(3) {
            width: 82%;
        }

        #pdfSummaryLoader .ai-skel i:nth-child(4) {
            width: 90%;
        }

@keyframes pdfSummarySkeleton {
    to {
        background-position: -200% 0;
    }
}

/* ---------- Generated summary body ---------- */

#pdfSummaryContent {
    color: #262425;
  /*  font-family: "DIN", sans-serif;
    font-size: 19px;
    font-weight: 400;
    line-height: 1.65;
    letter-spacing: -0.01em;*/
    overflow-wrap: anywhere;
}

    #pdfSummaryContent.is-formatted {
        animation: pdfSummaryFadeUp 450ms ease both;
    }

@keyframes pdfSummaryFadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Paragraphs */

#pdfSummaryContent p,
.summary-accordion .accordion-body p {
    margin: 0 0 16px;
    color: #303030;
    font-family: "DIN", sans-serif;
    /*font-size: 19px;
    font-weight: 400;
    line-height: 1.65;
    letter-spacing: -0.01em;*/
}

    #pdfSummaryContent p:last-child {
        margin-bottom: 0;
    }

/* Headings */

#pdfSummaryContent h4 {
    margin: 0 0 18px;
    padding: 0;
    border: 0;
    color: #418397;
   /* font-family: "DIN", sans-serif;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.02em;*/
}

#pdfSummaryContent h5 {
    margin: 26px 0 12px;
    color: #418397;
   /* font-family: "DIN", sans-serif;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0;*/
}

    #pdfSummaryContent h5:first-child {
        margin-top: 0;
    }

/* Emphasis */

#pdfSummaryContent strong {
    color: #262425;
    font-weight: 700;
}

/* ---------- In-short summary card ---------- */

#pdfSummaryContent .ai-lead {
    margin: 0 0 24px;
    padding: 22px 26px;
    border-left: 4px solid #418397;
    border-radius: 4px;
    background: #edf7fa;
}

    #pdfSummaryContent .ai-lead p {
        margin: 0;
        color: #303030;
       /* font-size: 21px;
        line-height: 1.7;*/
    }

#pdfSummaryContent .ai-label {
    display: block;
    margin-bottom: 10px;
    color: #418397;
    font-family: "DIN", sans-serif;
    /*font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.1em;*/
    text-transform: uppercase;
}

/* ---------- Key points ---------- */

#pdfSummaryContent .ai-points {
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

    #pdfSummaryContent .ai-points li {
        position: relative;
        margin: 0;
        padding-left: 36px;
        color: #303030;
        /*font-family: "DIN", sans-serif;
        font-size: 19px;
        font-weight: 400;
        line-height: 1.7;
        letter-spacing: -0.01em;*/
        opacity: 0;
        animation: pdfSummaryFadeUp 450ms ease forwards;
        animation-delay: calc(var(--i, 0) * 80ms + 100ms);
    }

        #pdfSummaryContent .ai-points li::before {
            content: "";
            position: absolute;
            top: 0.65em;
            left: 4px;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: linear-gradient(135deg, #7fd1e6, #418397);
            box-shadow: 0 0 0 5px rgba(3, 151, 201, 0.13);
        }

        #pdfSummaryContent .ai-points li strong {
            color: #262425;
        }

/* ---------- Dates ---------- */

#pdfSummaryContent mark {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(3, 151, 201, 0.13);
    color: #0b6f92;
    font-weight: 700;
}

/* ---------- Copy summary footer ---------- */

#pdfSummaryContent .ai-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
   /* margin-top: 32px;*/
    padding-top: 22px;
    border-top: 1px solid #d5e8ee;
}

#pdfSummaryContent .ai-note {
    flex: 1 1 100%;
    margin: 0 0 10px;
    color: #667f89;
    font-size: small;
   /* font-size: 15px;
    line-height: 1.5;*/
    padding-bottom: unset;
}

#pdfSummaryContent .ai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 22px;
    border: 1px solid #5aacc1;
    border-radius: 4px;
    background: #ffffff;
    color: #418397;
    font-family: "DIN", sans-serif;
    /*font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.05em;*/
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

    #pdfSummaryContent .ai-btn:hover {
        border-color: #418397;
        background: #418397;
        color: #ffffff;
        transform: translateY(-1px);
    }

    #pdfSummaryContent .ai-btn:focus-visible {
        outline: 3px solid rgba(3, 151, 201, 0.35);
        outline-offset: 3px;
    }

/* ---------- Error state ---------- */

#pdfSummaryContent .ai-error {
    padding: 20px 24px;
    border-left: 4px solid #d9534f;
    border-radius: 4px;
    background: #fff5f3;
}

    #pdfSummaryContent .ai-error .ai-label {
        color: #b8403c;
    }

    #pdfSummaryContent .ai-error p {
        margin: 0;
        color: #59302e;
    }

/* ---------- Tablet ---------- */

@media (max-width: 991.98px) {
    .summary-accordion {
        padding-top: 28px;
    }

        .summary-accordion .accordion-button {
            min-height: 100px;
            padding: 20px 22px;
            gap: 14px;
        }

            .summary-accordion .accordion-button > span {
                font-size: 17px;
                line-height: 1.5;
            }

                .summary-accordion .accordion-button > span b {
                    margin-bottom: 6px;
                    padding-bottom: 7px;
                    font-size: 22px;
                    line-height: 1.4;
                }

            .summary-accordion .accordion-button .left-icon {
                flex-basis: 34px;
                width: 34px;
                height: 34px;
            }

                .summary-accordion .accordion-button .left-icon img {
                    width: 30px;
                    height: 30px;
                }

            .summary-accordion .accordion-button .right-icon {
                flex-basis: 50px;
                width: 50px;
                height: 50px;
            }

                .summary-accordion .accordion-button .right-icon img {
                    width: 28px;
                    height: 28px;
                }

        .summary-accordion .accordion-body {
            padding: 0 22px 22px;
        }

            .summary-accordion .accordion-body #pdfSummaryContent {
                padding-top: 20px;
            }

    #pdfSummaryContent {
        font-size: 17px;
    }

        #pdfSummaryContent p,
        .summary-accordion .accordion-body p,
        #pdfSummaryContent .ai-points li {
            font-size: 17px;
        }

        #pdfSummaryContent h4 {
            font-size: 22px;
        }

        #pdfSummaryContent h5 {
            margin: 22px 0 10px;
            font-size: 19px;
        }

        #pdfSummaryContent .ai-lead {
            padding: 18px 20px;
        }

            #pdfSummaryContent .ai-lead p {
                font-size: 18px;
            }

        #pdfSummaryContent .ai-points {
            gap: 14px;
        }

        #pdfSummaryContent .ai-note {
             font-size: small;
        }
}

/* ---------- Mobile ---------- */

@media (max-width: 576.98px) {
    .summary-accordion {
        padding-top: 20px;
    }

        .summary-accordion .accordion-item {
            border-width: 1px;
        }

        .summary-accordion .accordion-button {
            min-height: 88px;
            padding: 15px 14px;
            gap: 10px;
        }

            .summary-accordion .accordion-button > span {
                font-size: 15px;
                line-height: 1.5;
            }

                .summary-accordion .accordion-button > span b {
                    margin-bottom: 6px;
                    padding-bottom: 6px;
                    font-size: 17px;
                    line-height: 1.4;
                    letter-spacing: 0.02em;
                }

                    .summary-accordion .accordion-button > span b::after {
                        width: 56px;
                    }

            .summary-accordion .accordion-button .left-icon {
                flex-basis: 27px;
                width: 27px;
                height: 27px;
            }

                .summary-accordion .accordion-button .left-icon img {
                    width: 25px;
                    height: 25px;
                }

            .summary-accordion .accordion-button .right-icon {
                flex-basis: 36px;
                width: 36px;
                height: 36px;
            }

                .summary-accordion .accordion-button .right-icon img {
                    width: 23px;
                    height: 23px;
                }

        .summary-accordion .accordion-body {
            padding: 0 14px 18px;
        }

            .summary-accordion .accordion-body #pdfSummaryContent {
                padding-top: 16px;
            }

    #pdfSummaryContent {
        font-size: 16px;
        line-height: 1.65;
    }

        #pdfSummaryContent p,
        .summary-accordion .accordion-body p,
        #pdfSummaryContent .ai-points li {
            font-size: 16px;
            line-height: 1.65;
        }

        #pdfSummaryContent h4 {
            margin-bottom: 14px;
            font-size: 19px;
        }

        #pdfSummaryContent h5 {
            margin: 20px 0 8px;
            font-size: 17px;
        }

        #pdfSummaryContent .ai-lead {
            margin-bottom: 20px;
            padding: 15px 16px;
        }

            #pdfSummaryContent .ai-lead p {
                font-size: 16px;
            }

        #pdfSummaryContent .ai-label {
            margin-bottom: 8px;
            font-size: 12px;
        }

        #pdfSummaryContent .ai-points {
            gap: 12px;
        }

            #pdfSummaryContent .ai-points li {
                padding-left: 28px;
            }

                #pdfSummaryContent .ai-points li::before {
                    left: 3px;
                    width: 10px;
                    height: 10px;
                }

        #pdfSummaryContent .ai-actions {
            gap: 10px;
            margin-top: 24px;
            padding-top: 16px;
        }

        #pdfSummaryContent .ai-note {
             font-size: small;
        }

        #pdfSummaryContent .ai-btn {
            min-height: 40px;
            padding: 9px 15px;
            font-size: 13px;
        }

    #pdfSummaryLoader {
        padding: 20px 14px 24px;
    }

        #pdfSummaryLoader p {
            font-size: 15px;
        }
}

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
    .summary-accordion .accordion-item,
    .summary-accordion .accordion-button,
    .summary-accordion .accordion-button .right-icon,
    .summary-accordion .accordion-button .right-icon img,
    #pdfSummaryContent .ai-btn {
        transition: none !important;
    }

        .summary-accordion .accordion-button[aria-expanded="true"]::before,
        .summary-accordion .accordion-button > span b::after,
        .summary-accordion .accordion-button .left-icon img,
        .summary-accordion .accordion-button .left-icon::before,
        .summary-accordion .accordion-button .left-icon::after,
        #pdfSummaryLoader .spinner-border,
        #pdfSummaryLoader p,
        #pdfSummaryLoader .ai-skel i,
        #pdfSummaryContent.is-formatted,
        #pdfSummaryContent .ai-points li {
            animation: none !important;
        }

    #pdfSummaryContent .ai-points li {
        opacity: 1;
    }
}