:root {
    --ppas-primary: #0b5ed7;
    --ppas-primary-dark: #084db2;
    --ppas-dark: #17324d;
    --ppas-light: #f6f8fb;
    --ppas-border: #e4e8ee;
    --ppas-text: #1e293b;
    --ppas-muted: #64748b;
}


/* =========================================================
   ROOT
   ========================================================= */

#ppas-ai-root {
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    z-index: 2147483000;
}


/* =========================================================
   FLOATING LAUNCHER
   ========================================================= */

.ppas-ai-launcher {
    position: fixed !important;

    right: 22px !important;
    bottom: 22px !important;
    left: auto !important;
    top: auto !important;

    width: 78px;
    height: 78px;

    padding: 0;
    margin: 0;

    border: 0;
    border-radius: 50%;

    background: #ffffff;

    overflow: hidden;

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

    cursor: pointer;

    z-index: 2147483001;

    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.20),
        0 0 0 3px rgba(11, 94, 215, 0.10);

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.ppas-ai-launcher img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;
}

.ppas-ai-launcher:hover {
    transform: scale(1.08);

    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.25),
        0 0 0 4px rgba(11, 94, 215, 0.15);
}

.ppas-ai-launcher:active {
    transform: scale(0.96);
}


/* =========================================================
   CHAT PANEL
   ========================================================= */

.ppas-ai-panel {
    position: fixed;

    right: 22px;
    bottom: 112px;

    width: min(390px, calc(100vw - 28px));
    height: min(620px, calc(100vh - 120px));

    background: #ffffff;

    border-radius: 18px;

    box-shadow:
        0 18px 55px rgba(0, 0, 0, 0.20);

    overflow: hidden;

    display: none;
    flex-direction: column;

    border: 1px solid #dfe5ec;

    z-index: 2147483000;
}

.ppas-ai-panel.open {
    display: flex;
}


/* =========================================================
   HEADER
   ========================================================= */

.ppas-ai-header {
    background: var(--ppas-dark);
    color: #ffffff;

    padding: 13px 14px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    flex-shrink: 0;
}

.ppas-ai-profile {
    display: flex;
    align-items: center;

    gap: 10px;

    min-width: 0;
}

.ppas-ai-avatar {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    border-radius: 50%;

    background: #ffffff;

    overflow: hidden;

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

    border: 2px solid rgba(255, 255, 255, 0.85);

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15);
}

.ppas-ai-avatar img {
    width: 100%;
    height: 100%;

    object-fit: cover;

    display: block;
}

.ppas-ai-profile-info {
    min-width: 0;
}

.ppas-ai-name {
    font-size: 15px;
    font-weight: 700;

    line-height: 1.2;

    color: #ffffff;
}

.ppas-ai-status {
    display: flex;
    align-items: center;

    gap: 4px;

    margin-top: 3px;

    font-size: 10px;

    color: rgba(255, 255, 255, 0.78);

    white-space: nowrap;
}

.ppas-ai-status-dot {
    width: 7px;
    height: 7px;

    flex: 0 0 7px;

    border-radius: 50%;

    background: #22c55e;

    box-shadow:
        0 0 0 2px rgba(34, 197, 94, 0.18);
}

.ppas-ai-status-separator {
    opacity: 0.55;
}

.ppas-ai-close {
    border: 0;

    background: transparent;

    color: #ffffff;

    font-size: 23px;

    cursor: pointer;

    width: 32px;
    height: 32px;

    border-radius: 8px;

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

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.ppas-ai-close:hover {
    background: rgba(255, 255, 255, 0.10);

    transform: scale(1.05);
}


/* =========================================================
   MESSAGE AREA
   ========================================================= */

.ppas-ai-messages {
    flex: 1;

    overflow-y: auto;

    padding: 16px;

    background: var(--ppas-light);

    scroll-behavior: smooth;
}

.ppas-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ppas-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ppas-ai-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;

    border-radius: 10px;
}


/* =========================================================
   MESSAGE ROW
   ========================================================= */

.ppas-ai-row {
    display: flex;

    align-items: flex-start;

    gap: 8px;

    width: 100%;

    margin-bottom: 12px;
}

.ppas-ai-row.bot {
    justify-content: flex-start;
}

.ppas-ai-row.user {
    justify-content: flex-end;
}


/* =========================================================
   MESSAGE AVATAR
   ========================================================= */

.ppas-ai-message-avatar {
    width: 30px;
    height: 30px;

    flex: 0 0 30px;

    border-radius: 50%;

    overflow: hidden;

    background: #ffffff;

    border: 1px solid #e1e7ef;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.12);

    display: flex;
    align-items: center;
    justify-content: center;
}

.ppas-ai-message-avatar img {
    width: 100%;
    height: 100%;

    object-fit: cover;

    display: block;
}


/* =========================================================
   MESSAGE CONTAINER
   ========================================================= */

.ppas-ai-row .ppas-ai-msg {
    margin: 0;

    max-width: calc(86% - 38px);

    padding: 0;

    background: transparent;

    border: 0;
}

.ppas-ai-row.user .ppas-ai-msg {
    max-width: 86%;
}


/* =========================================================
   MESSAGE BUBBLE
   ========================================================= */

.ppas-ai-bubble {
    padding: 11px 13px;

    border-radius: 14px;

    background: #ffffff;

    border: 1px solid var(--ppas-border);

    color: var(--ppas-text);

    line-height: 1.5;

    font-size: 14px;

    word-wrap: break-word;

    overflow-wrap: break-word;

    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.03);
}

.ppas-ai-row.bot .ppas-ai-bubble {
    border-radius: 4px 14px 14px 14px;
}

.ppas-ai-row.user .ppas-ai-bubble {
    background: var(--ppas-primary);

    color: #ffffff;

    border: 0;

    border-radius: 14px 14px 4px 14px;
}


/* =========================================================
   AI CONTENT / MARKDOWN
   ========================================================= */

.ppas-ai-content {
    line-height: 1.55;

    font-size: 14px;

    color: var(--ppas-text);
}

.ppas-ai-content strong {
    font-weight: 700;

    color: #172033;
}

.ppas-ai-content em {
    font-style: italic;
}

.ppas-ai-content code {
    background: #eef2f7;

    padding: 2px 5px;

    border-radius: 5px;

    font-family:
        Consolas,
        Monaco,
        monospace;

    font-size: 12px;
}

.ppas-ai-content a {
    color: var(--ppas-primary);

    text-decoration: underline;

    word-break: break-word;
}

.ppas-ai-content a:hover {
    color: var(--ppas-primary-dark);
}


/* =========================================================
   AI PARAGRAPH / LINE
   ========================================================= */

.ppas-ai-line {
    margin: 0 0 7px 0;
}

.ppas-ai-line:last-child {
    margin-bottom: 0;
}

.ppas-ai-space {
    height: 6px;
}


/* =========================================================
   BULLET LIST
   ========================================================= */

.ppas-ai-list {
    margin: 7px 0 9px 20px;

    padding: 0;
}

.ppas-ai-list li {
    margin-bottom: 5px;
}

.ppas-ai-bullet {
    margin: 4px 0;

    padding-left: 4px;
}


/* =========================================================
   NUMBERED LIST
   ========================================================= */

.ppas-ai-numbered {
    margin: 5px 0 8px 0;
}

.ppas-ai-number {
    margin: 4px 0;

    padding-left: 2px;
}


/* =========================================================
   OLD AI MESSAGE COMPATIBILITY
   ========================================================= */

.ppas-ai-msg {
    max-width: 86%;

    line-height: 1.45;

    font-size: 14px;

    word-wrap: break-word;
}


/* =========================================================
   QUICK QUESTIONS
   ========================================================= */

.ppas-ai-quick {
    margin: 5px 0 15px;

    display: flex;

    flex-direction: column;

    gap: 8px;
}

.ppas-ai-quick-title {
    font-size: 12px;

    font-weight: 600;

    color: var(--ppas-muted);

    margin-bottom: 2px;
}

.ppas-ai-quick-btn {
    display: block;

    width: 100%;

    box-sizing: border-box;

    padding: 10px 12px;

    border: 1px solid #d7dee8;

    border-radius: 10px;

    background: #ffffff;

    color: var(--ppas-dark);

    text-align: left;

    font-family: inherit;

    font-size: 13px;

    line-height: 1.35;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.ppas-ai-quick-btn:hover {
    background: #f0f6ff;

    border-color: var(--ppas-primary);

    color: var(--ppas-primary);

    transform: translateY(-1px);

    box-shadow:
        0 2px 7px rgba(11, 94, 215, 0.08);
}

.ppas-ai-quick-btn:active {
    transform: scale(0.98);
}


/* =========================================================
   FEEDBACK
   ========================================================= */

.ppas-ai-feedback {
    display: flex;

    align-items: center;

    flex-wrap: wrap;

    gap: 6px;

    margin-top: 7px;

    padding: 0 2px;

    border: 0;

    font-size: 11px;

    color: var(--ppas-muted);
}

.ppas-ai-feedback > span:first-child {
    margin-right: 2px;

    white-space: nowrap;
}


/* Feedback buttons */

.ppas-feedback-btn {
    display: inline-flex;

    align-items: center;

    justify-content: center;

    gap: 4px;

    border: 1px solid #dfe5ec;

    background: #ffffff;

    color: #475569;

    padding: 4px 9px;

    min-height: 27px;

    border-radius: 999px;

    font-family: inherit;

    font-size: 11px;

    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04);

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.ppas-feedback-btn:hover {
    background: #f8fafc;

    border-color: #94a3b8;

    color: var(--ppas-dark);

    transform: translateY(-1px);

    box-shadow:
        0 3px 8px rgba(15, 23, 42, 0.08);
}

.ppas-feedback-btn:active {
    transform: translateY(0);

    box-shadow: none;
}

.ppas-feedback-btn:disabled {
    opacity: 0.55;

    cursor: default;

    transform: none;

    box-shadow: none;
}


/* Feedback icon */

.ppas-feedback-icon {
    font-size: 13px;

    line-height: 1;
}


/* Feedback label */

.ppas-feedback-label {
    font-size: 11px;

    line-height: 1;
}


/* Thank you */

.ppas-feedback-thanks {
    display: inline-flex;

    align-items: center;

    padding: 5px 9px;

    background: #f8fafc;

    border: 1px solid #e2e8f0;

    border-radius: 999px;

    font-size: 11px;

    color: #64748b;
}


/* =========================================================
   SOURCES
   ========================================================= */

.ppas-ai-source,
.ppas-ai-sources {
    margin-top: 9px;

    padding-top: 8px;

    border-top: 1px solid #e5e7eb;

    font-size: 11px;
}

.ppas-ai-source-title {
    font-weight: 600;

    color: #64748b;

    margin-bottom: 4px;
}

.ppas-ai-source a,
.ppas-ai-sources a {
    display: block;

    color: var(--ppas-primary);

    text-decoration: none;

    margin-top: 4px;

    word-break: break-word;
}

.ppas-ai-source a:hover,
.ppas-ai-sources a:hover {
    text-decoration: underline;
}


/* =========================================================
   TYPING INDICATOR
   ========================================================= */

.ppas-ai-typing .ppas-ai-bubble {
    padding: 9px 11px;
}

.ppas-ai-typing-text {
    display: flex;

    align-items: center;

    gap: 4px;

    color: var(--ppas-muted);

    font-size: 11px;
}

.ppas-ai-typing-dot {
    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: #94a3b8;

    animation:
        ppasAiTyping 1.2s infinite ease-in-out;
}

.ppas-ai-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.ppas-ai-typing-dot:nth-child(3) {
    animation-delay: 0.30s;
}

.ppas-ai-typing-label {
    margin-left: 5px;
}

@keyframes ppasAiTyping {

    0%,
    60%,
    100% {
        transform: translateY(0);

        opacity: 0.35;
    }

    30% {
        transform: translateY(-3px);

        opacity: 1;
    }
}


/* =========================================================
   COMPOSER
   ========================================================= */

.ppas-ai-composer {
    padding: 10px;

    background: #ffffff;

    border-top: 1px solid #e1e5ea;

    display: flex;

    gap: 8px;

    flex-shrink: 0;
}


/* Input */

.ppas-ai-input {
    flex: 1;

    min-width: 0;

    border:
        1px solid #ccd3dc;

    border-radius: 12px;

    padding:
        10px
        12px;

    resize: none;

    max-height: 100px;

    font-family: inherit;

    font-size: 14px;

    line-height: 1.4;

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.ppas-ai-input:focus {
    border-color: var(--ppas-primary);

    box-shadow:
        0 0 0 3px rgba(11, 94, 215, 0.10);
}

.ppas-ai-input::placeholder {
    color: #94a3b8;
}


/* Send */

.ppas-ai-send {
    border: 0;

    border-radius: 12px;

    background: var(--ppas-primary);

    color: #ffffff;

    padding:
        0
        16px;

    min-width: 76px;

    font-family: inherit;

    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.ppas-ai-send:hover {
    background: var(--ppas-primary-dark);

    box-shadow:
        0 3px 8px rgba(11, 94, 215, 0.20);
}

.ppas-ai-send:active {
    transform: scale(0.97);
}

.ppas-ai-send:disabled {
    opacity: 0.60;

    cursor: not-allowed;

    transform: none;

    box-shadow: none;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 480px) {

    .ppas-ai-launcher {
        right: 14px !important;

        bottom: 14px !important;

        left: auto !important;

        top: auto !important;

        width: 64px;

        height: 64px;
    }

    .ppas-ai-panel {
        right: 7px;

        bottom: 86px;

        width: calc(100vw - 14px);

        height: calc(100vh - 100px);

        border-radius: 16px;
    }

    .ppas-ai-header {
        padding: 12px 13px;
    }

    .ppas-ai-avatar {
        width: 38px;

        height: 38px;

        flex-basis: 38px;
    }

    .ppas-ai-name {
        font-size: 14px;
    }

    .ppas-ai-status {
        font-size: 9px;
    }

    .ppas-ai-messages {
        padding: 12px;
    }

    .ppas-ai-bubble {
        font-size: 13px;

        padding: 10px 11px;
    }

    .ppas-ai-row .ppas-ai-msg {
        max-width: calc(90% - 36px);
    }

    .ppas-ai-row.user .ppas-ai-msg {
        max-width: 90%;
    }

    .ppas-ai-feedback {
        font-size: 10px;

        gap: 5px;
    }

    .ppas-feedback-btn {
        min-height: 26px;

        padding: 4px 8px;
    }

    .ppas-feedback-label {
        font-size: 10px;
    }

    .ppas-ai-composer {
        padding: 8px;
    }

    .ppas-ai-input {
        font-size: 13px;

        padding:
            9px
            10px;
    }

    .ppas-ai-send {
        min-width: 68px;

        padding:
            0
            12px;

        font-size: 13px;
    }
}


/* =========================================================
   ACCESSIBILITY
   ========================================================= */

.ppas-ai-launcher:focus-visible,
.ppas-ai-close:focus-visible,
.ppas-ai-quick-btn:focus-visible,
.ppas-feedback-btn:focus-visible,
.ppas-ai-send:focus-visible,
.ppas-ai-input:focus-visible {
    outline: 3px solid rgba(11, 94, 215, 0.30);

    outline-offset: 2px;
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

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

    .ppas-ai-launcher,
    .ppas-ai-close,
    .ppas-ai-quick-btn,
    .ppas-feedback-btn,
    .ppas-ai-send {
        transition: none;
    }

    .ppas-ai-typing-dot {
        animation: none;
    }
}

.ppas-feedback-error {
    display: inline-flex;
    align-items: center;

    padding: 5px 9px;

    background: #fff7ed;
    border: 1px solid #fed7aa;

    border-radius: 999px;

    font-size: 11px;

    color: #c2410c;
}

/* =========================================================
   AI ANSWER FORMATTING
   ========================================================= */

.ppas-ai-content {
    width: 100%;
    line-height: 1.55;
}

.ppas-ai-line {
    margin: 0 0 6px 0;
}

.ppas-ai-space {
    height: 6px;
}

.ppas-ai-heading {
    display: block;
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 700;
    color: #17324d;
}

.ppas-ai-list {
    margin: 5px 0 10px 0;
    padding-left: 24px;
}

.ppas-ai-list li {
    margin-bottom: 5px;
    padding-left: 3px;
}

.ppas-ai-list ol,
.ppas-ai-list ul {
    margin-top: 5px;
}

.ppas-ai-content strong {
    font-weight: 700;
}

.ppas-ai-content a {
    color: #0b5ed7;
    text-decoration: underline;
    word-break: break-word;
}

.ppas-ai-content a:hover {
    color: #084298;
}

/* =========================================================
   PPAS AI ANSWER FORMAT
   ========================================================= */

.ppas-ai-content {
    width: 100%;
    font-size: 14px;
    line-height: 1.55;
    color: #1e293b;
}

.ppas-ai-line {
    margin: 0 0 7px 0;
}

.ppas-ai-space {
    height: 7px;
}


/* Heading */

.ppas-ai-heading {
    display: block;
    margin: 2px 0 9px 0;
    color: #17324d;
    font-size: 14px;
    line-height: 1.4;
}


/* Lists */

.ppas-ai-list {
    margin: 5px 0 10px 0;
    padding-left: 25px;
}

.ppas-ai-list li {
    margin: 0 0 6px 0;
    padding-left: 3px;
    line-height: 1.5;
}


/* Bold */

.ppas-ai-content strong {
    font-weight: 700;
    color: #17324d;
}


/* Links */

.ppas-ai-content a {
    color: #0b5ed7;
    text-decoration: underline;
    word-break: break-word;
}


/* Feedback */

.ppas-ai-feedback {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
    padding-top: 7px;
    border-top: 1px solid #eef1f5;
    font-size: 11px;
    color: #64748b;
}

.ppas-feedback-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    border: 1px solid #dbe2ea;
    background: #fff;
    color: #334155;
    padding: 4px 9px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
}

.ppas-feedback-btn:hover {
    background: #f8fafc;
    border-color: #0b5ed7;
}

.ppas-feedback-btn:disabled {
    opacity: .5;
    cursor: default;
}


/* Sources */

.ppas-ai-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #eef1f5;
}

.ppas-ai-source-title {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 5px;
}

.ppas-ai-sources a {
    display: block;
    font-size: 11px;
    color: #0b5ed7;
    text-decoration: none;
    margin-top: 4px;
}

.ppas-ai-sources a:hover {
    text-decoration: underline;
}

/* =========================================================
   AI ACTION BUTTONS
   ========================================================= */

.ppas-ai-actions {
    margin-top: 10px;
    width: 100%;
}

.ppas-ai-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    box-sizing: border-box;

    padding: 10px 12px;

    background: #f0f7ff;

    border: 1px solid #0b5ed7;

    border-radius: 10px;

    color: #0b5ed7;

    text-decoration: none;

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;
}

.ppas-ai-action-btn:hover {
    background: #0b5ed7;
    color: #fff;
}