/* =========================================================
   ABA Intelligence — Ask the PA Coach
   Final Interface v1.2
   ========================================================= */

body.aba-pa-coach-open {
    overflow: hidden;
}

/* ---------------------------------------------------------
   Practice-exam launch button
   --------------------------------------------------------- */

.aba-pa-coach-btn {
    display: none;
    margin-top: 14px;
    padding: 11px 18px;
    border: 0;
    border-radius: 999px;
    background: #006b61;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.aba-pa-coach-btn:hover {
    background: #00534b;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
}

.aba-pa-coach-btn:focus-visible {
    outline: 3px solid rgba(0, 107, 97, 0.3);
    outline-offset: 3px;
}

/* ---------------------------------------------------------
   Backdrop
   --------------------------------------------------------- */

.aba-pa-coach-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99998;
    visibility: hidden;
    background: rgba(15, 28, 26, 0.43);
    opacity: 0;
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.aba-pa-coach-backdrop.open {
    visibility: visible;
    opacity: 1;
}

/* ---------------------------------------------------------
   Main panel
   --------------------------------------------------------- */

.aba-pa-coach-panel {
    position: fixed;
    top: 0;
    right: -550px;
    z-index: 99999;
    display: flex;
    width: 520px;
    max-width: calc(100vw - 18px);
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid #d5e2df;
    background: #ffffff;
    box-shadow: -14px 0 40px rgba(0, 0, 0, 0.2);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
    transition: right 0.28s ease;
}

.aba-pa-coach-panel.open {
    right: 0;
}

/* ---------------------------------------------------------
   Full-width PA Coach banner
   --------------------------------------------------------- */

.aba-pa-coach-hero {
    position: relative;
    display: none;
    width: 100%;
    height: 170px;
    flex: 0 0 170px;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-bottom: 1px solid #d7e3e0;
    background: #004f49;
    text-align: initial;
}

.aba-pa-coach-avatar {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    object-fit: cover;
    object-position: center top;
}

/* Close button placed over banner */

.aba-pa-coach-close-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
}

/* ---------------------------------------------------------
   Fallback header
   Appears only when no banner URL is available
   --------------------------------------------------------- */

.aba-pa-coach-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #006b61;
    color: #ffffff;
}

.aba-pa-coach-fallback-header {
    min-height: 62px;
}

.aba-pa-coach-heading {
    min-width: 0;
}

.aba-pa-coach-title {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.15;
}

.aba-pa-coach-subtitle {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
    opacity: 0.92;
}

.aba-pa-coach-close {
    display: inline-flex;
    width: 36px;
    height: 36px;
    margin-left: auto;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.17);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 25px;
    line-height: 1;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.aba-pa-coach-close:hover {
    background: rgba(255, 255, 255, 0.29);
    transform: scale(1.04);
}

.aba-pa-coach-close:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* ---------------------------------------------------------
   Current-question context
   --------------------------------------------------------- */

.aba-pa-coach-context {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 15px 11px;
    border-bottom: 1px solid #d8e6e2;
    background: #edf7f4;
    color: #27423d;
}

.aba-pa-coach-context-dot {
    width: 10px;
    height: 10px;
    margin-top: 5px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: #16a36a;
    box-shadow: 0 0 0 3px rgba(22, 163, 106, 0.14);
}

.aba-pa-coach-context-content {
    min-width: 0;
    flex: 1;
    font-size: 12px;
    line-height: 1.35;
}

.aba-pa-coach-context-content strong {
    display: block;
    margin-bottom: 6px;
    color: #006b61;
    font-size: 13px;
    font-weight: 850;
}

/*
 * JavaScript will convert the three context values into pills.
 * Flex-wrap prevents words such as "Discrete" from being clipped.
 */

.aba-pa-coach-context-meta {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
    color: #365c55;
}

.aba-pa-coach-context-meta span {
    display: inline-flex;
    min-width: 0;
    max-width: 100%;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid #c4dcd6;
    border-radius: 999px;
    background: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
}

.aba-pa-coach-context-meta span:empty {
    display: none;
}

/* Remove old bullet separators */

.aba-pa-coach-context-meta span::before {
    display: none !important;
    content: none !important;
}

/* ---------------------------------------------------------
   Scrollable conversation
   --------------------------------------------------------- */

.aba-pa-coach-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 17px 14px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        linear-gradient(
            rgba(247, 250, 249, 0.97),
            rgba(247, 250, 249, 0.97)
        ),
        radial-gradient(
            circle at top right,
            #dcecea,
            transparent 42%
        );
    scroll-behavior: smooth;
}

.aba-pa-coach-body::-webkit-scrollbar {
    width: 8px;
}

.aba-pa-coach-body::-webkit-scrollbar-track {
    background: transparent;
}

.aba-pa-coach-body::-webkit-scrollbar-thumb {
    border: 2px solid #f7faf9;
    border-radius: 999px;
    background: #b8cbc7;
}

/* ---------------------------------------------------------
   Conversation messages
   --------------------------------------------------------- */

.aba-pa-coach-message-row {
    display: flex;
    width: 100%;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 17px;
}

.aba-pa-coach-message-row.coach {
    justify-content: flex-start;
}

.aba-pa-coach-message-row.student {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* Circular speaker avatars */

.aba-pa-coach-speaker-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    overflow: hidden;
    border-radius: 50%;
    box-shadow:
        0 0 0 2px #ffffff,
        0 2px 8px rgba(0, 0, 0, 0.13);
}

.aba-pa-coach-speaker-avatar.coach {
    border: 1px solid #b9d3cd;
    background-color: #006b61;
    background-position: 42% 20%;
    background-repeat: no-repeat;
    background-size: 330% auto;
}

.aba-pa-coach-speaker-avatar.student {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #005b53;
    background: #006b61;
    color: #ffffff;
    font-size: 16px;
    font-weight: 850;
    text-transform: uppercase;
}

/* Speaker name and message stack */

.aba-pa-coach-message-stack {
    display: flex;
    min-width: 0;
    max-width: calc(100% - 49px);
    flex-direction: column;
}

.aba-pa-coach-message-row.student .aba-pa-coach-message-stack {
    align-items: flex-end;
}

.aba-pa-coach-speaker-name {
    margin: 0 4px 5px;
    color: #006b61;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.2;
}

.aba-pa-coach-message-row.student .aba-pa-coach-speaker-name {
    text-align: right;
}

/* Bubble styles */

.aba-pa-coach-message {
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.52;
    overflow-wrap: anywhere;
}

.aba-pa-coach-message.coach {
    border: 1px solid #d8e5e2;
    border-bottom-left-radius: 5px;
    background: #ffffff;
    color: #20312e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.055);
}

.aba-pa-coach-message.student {
    min-width: 74px;
    border: 1px solid #006b61;
    border-bottom-right-radius: 5px;
    background: #006b61;
    color: #ffffff;
    box-shadow: 0 3px 9px rgba(0, 107, 97, 0.2);
    text-align: left;
}

.aba-pa-coach-message p:first-child {
    margin-top: 0;
}

.aba-pa-coach-message p:last-child {
    margin-bottom: 0;
}

.aba-pa-coach-message ul,
.aba-pa-coach-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.aba-pa-coach-message strong {
    font-weight: 800;
}

/* Optional timestamp */

.aba-pa-coach-message-time {
    margin: 5px 4px 0;
    color: #7a8c88;
    font-size: 10px;
    line-height: 1.2;
}

.aba-pa-coach-message-row.student .aba-pa-coach-message-time {
    text-align: right;
}

/* ---------------------------------------------------------
   Suggested prompts
   --------------------------------------------------------- */

.aba-pa-coach-prompt-heading {
    margin: 4px 0 8px;
    color: #006b61;
    font-size: 13px;
    font-weight: 850;
}

.aba-pa-coach-prompts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 20px;
}

.aba-pa-coach-prompt {
    display: flex;
    min-height: 41px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid #9fc8c0;
    border-radius: 999px;
    background: #ffffff;
    color: #006b61;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.25;
    text-align: left;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.aba-pa-coach-prompt:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.aba-pa-coach-prompt:hover {
    border-color: #006b61;
    background: #edf7f4;
    box-shadow: 0 2px 7px rgba(0, 107, 97, 0.1);
    transform: translateY(-1px);
}

.aba-pa-coach-prompt:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    transform: none;
}

/* ---------------------------------------------------------
   Thinking indicator
   --------------------------------------------------------- */

.aba-pa-coach-thinking {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.aba-pa-coach-thinking-text {
    color: #536763;
    font-size: 13px;
    font-style: italic;
    font-weight: 650;
}

.aba-pa-coach-thinking-dots {
    display: inline-flex;
    gap: 4px;
}

.aba-pa-coach-thinking-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #006b61;
    animation: abaCoachThinking 1.2s infinite ease-in-out;
}

.aba-pa-coach-thinking-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.aba-pa-coach-thinking-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes abaCoachThinking {
    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}


/* ---------------------------------------------------------
   Sample Exam upgrade card
   These classes are used only by the limited Sample preview.
   --------------------------------------------------------- */

.aba-pa-coach-upgrade-card {
    padding: 2px 1px 1px;
}

.aba-pa-coach-upgrade-eyebrow {
    display: inline-flex;
    margin-bottom: 9px;
    padding: 5px 9px;
    border: 1px solid #b8d8d1;
    border-radius: 999px;
    background: #edf7f4;
    color: #006b61;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.aba-pa-coach-upgrade-card h3 {
    margin: 0 0 8px;
    color: #006b61;
    font-size: 18px;
    line-height: 1.25;
}

.aba-pa-coach-upgrade-card p {
    margin: 0 0 12px;
}

.aba-pa-coach-upgrade-list {
    margin: 0 0 15px !important;
    padding-left: 20px !important;
}

.aba-pa-coach-upgrade-list li {
    margin-bottom: 5px;
}

.aba-pa-coach-upgrade-button {
    display: inline-flex;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: 11px 14px;
    border-radius: 10px;
    background: #006b61;
    color: #ffffff !important;
    font-weight: 850;
    line-height: 1.25;
    text-align: center;
    text-decoration: none !important;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.aba-pa-coach-upgrade-button:hover {
    background: #00534b;
    color: #ffffff !important;
    transform: translateY(-1px);
}

.aba-pa-coach-upgrade-button:focus-visible {
    outline: 3px solid rgba(0, 107, 97, 0.25);
    outline-offset: 3px;
}

/* ---------------------------------------------------------
   Message composer
   --------------------------------------------------------- */

.aba-pa-coach-input-wrap {
    flex: 0 0 auto;
    padding: 11px 13px 10px;
    border-top: 1px solid #d8e5e2;
    background: #ffffff;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.045);
}

.aba-pa-coach-textarea {
    display: block;
    width: 100%;
    min-height: 72px;
    max-height: 150px;
    box-sizing: border-box;
    padding: 11px 12px;
    resize: vertical;
    border: 1px solid #9fc8c0;
    border-radius: 12px;
    background: #ffffff;
    color: #20312e;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.aba-pa-coach-textarea:focus {
    border-color: #006b61;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(0, 107, 97, 0.13);
}

.aba-pa-coach-textarea::placeholder {
    color: #758681;
}

.aba-pa-coach-textarea:disabled {
    background: #f2f5f4;
    cursor: not-allowed;
}

.aba-pa-coach-send {
    width: 100%;
    margin-top: 8px;
    padding: 11px 14px;
    border: 0;
    border-radius: 10px;
    background: #006b61;
    color: #ffffff;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 850;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.aba-pa-coach-send:hover:not(:disabled) {
    background: #00534b;
    transform: translateY(-1px);
}

.aba-pa-coach-send:disabled {
    background: #6caaa2;
    cursor: not-allowed;
    opacity: 1;
}

.aba-pa-coach-privacy {
    margin-top: 7px;
    color: #657773;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
}

.aba-pa-coach-privacy::before {
    margin-right: 5px;
    content: "🔒";
    font-size: 10px;
}

/* ---------------------------------------------------------
   Tablet and mobile
   --------------------------------------------------------- */

@media (max-width: 600px) {
    .aba-pa-coach-panel {
        right: -100%;
        width: 100%;
        max-width: 100%;
        border-left: 0;
    }

    .aba-pa-coach-hero {
        height: 145px;
        flex-basis: 145px;
    }

    .aba-pa-coach-avatar {
        object-position: center top;
    }

    .aba-pa-coach-close-overlay {
        top: max(10px, env(safe-area-inset-top));
        right: 10px;
    }

    .aba-pa-coach-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .aba-pa-coach-context {
        padding: 9px 12px 10px;
    }

    .aba-pa-coach-context-content strong {
        margin-bottom: 5px;
    }

    .aba-pa-coach-context-meta {
        gap: 5px;
    }

    .aba-pa-coach-context-meta span {
        padding: 4px 7px;
        font-size: 10px;
    }

    .aba-pa-coach-body {
        padding: 14px 11px 19px;
    }

    .aba-pa-coach-speaker-avatar {
        width: 35px;
        height: 35px;
        flex-basis: 35px;
    }

    .aba-pa-coach-message-stack {
        max-width: calc(100% - 44px);
    }

    .aba-pa-coach-message {
        font-size: 13px;
    }

    .aba-pa-coach-prompts {
        grid-template-columns: 1fr;
    }

    .aba-pa-coach-prompt:last-child:nth-child(odd) {
        grid-column: auto;
    }

    .aba-pa-coach-input-wrap {
        padding-bottom: max(
            10px,
            env(safe-area-inset-bottom)
        );
    }

    .aba-pa-coach-textarea {
        min-height: 64px;
    }
}

@media (max-height: 700px) and (min-width: 601px) {
    .aba-pa-coach-hero {
        height: 112px;
        flex-basis: 112px;
    }

    .aba-pa-coach-context {
        padding-top: 7px;
        padding-bottom: 8px;
    }

    .aba-pa-coach-body {
        padding-top: 12px;
    }

    .aba-pa-coach-textarea {
        min-height: 58px;
    }
}

/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .aba-pa-coach-panel,
    .aba-pa-coach-backdrop,
    .aba-pa-coach-btn,
    .aba-pa-coach-close,
    .aba-pa-coach-prompt,
    .aba-pa-coach-send,
    .aba-pa-coach-upgrade-button {
        transition: none;
    }

    .aba-pa-coach-thinking-dots span {
        animation: none;
    }
}