/* DSE AI Chat Widget */

.dse-ai-chat,
.dse-ai-chat * {
    box-sizing: border-box;
}

.dse-ai-chat {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2147481000;
    font-family: Arial, Helvetica, sans-serif;
}

.dse-ai-chat-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    width: 68px;
    height: 64px;
    border: 0;
    border-radius: 18px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, .28), transparent 38%),
        #2563eb;
    color: #ffffff;
    box-shadow: 0 16px 34px rgba(15, 23, 42, .28);
    cursor: pointer;
}

.dse-ai-chat.is-thinking .dse-ai-chat-launcher {
    box-shadow: 0 16px 34px rgba(37, 99, 235, .34);
}

.dse-ai-chat-launcher-label {
    color: #ffffff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
}

.dse-ai-robot {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #ffffff;
}

.dse-ai-robot-face {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    align-items: center;
    justify-items: center;
    width: 34px;
    height: 28px;
    padding: 9px 7px 7px;
    border: 1px solid rgba(255, 255, 255, .62);
    border-radius: 12px;
    background:
        radial-gradient(circle at 25% 15%, rgba(255, 255, 255, .54), transparent 22%),
        linear-gradient(135deg, #eaf6ff 0%, #91d5ff 38%, #1d8bd8 100%);
    box-shadow:
        inset 0 -8px 12px rgba(15, 23, 42, .16),
        0 7px 15px rgba(15, 23, 42, .22);
}

.dse-ai-robot-face::before,
.dse-ai-robot-face::after {
    content: "";
    position: absolute;
    top: 11px;
    width: 4px;
    height: 8px;
    border-radius: 999px;
    background: #0f172a;
    opacity: .88;
}

.dse-ai-robot-face::before {
    left: -4px;
}

.dse-ai-robot-face::after {
    right: -4px;
}

.dse-ai-robot-eye {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #0f172a;
    box-shadow: 0 0 8px rgba(255, 255, 255, .72);
}

.dse-ai-robot-mouth {
    grid-column: 1 / -1;
    width: 16px;
    height: 3px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .72);
}

.dse-ai-robot-antenna {
    position: absolute;
    top: 1px;
    left: 50%;
    width: 2px;
    height: 8px;
    border-radius: 999px;
    background: #ffffff;
    transform: translateX(-50%);
    box-shadow: 0 -2px 0 1px #a7f3d0;
}

.dse-ai-robot-badge {
    position: absolute;
    right: 1px;
    bottom: 1px;
    min-width: 19px;
    padding: 2px 3px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 6px;
    background: #0f172a;
    color: #ffffff;
    font-size: 7px;
    font-weight: 900;
    line-height: 1;
    text-align: center;
}

.dse-ai-robot.is-header {
    width: 38px;
    height: 38px;
}

.dse-ai-robot.is-header .dse-ai-robot-face {
    width: 32px;
    height: 27px;
}

.dse-ai-robot.is-header .dse-ai-robot-badge {
    font-size: 6px;
}

.dse-ai-chat.is-thinking .dse-ai-robot-eye {
    animation: dse-ai-robot-blink 1.15s ease-in-out infinite;
}

@keyframes dse-ai-robot-blink {
    0%, 72%, 100% {
        transform: scaleY(1);
    }

    84% {
        transform: scaleY(.25);
    }
}

.dse-ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    display: none;
    width: min(480px, calc(100vw - 32px));
    height: min(720px, calc(100vh - 112px));
    border: 1px solid #c8d5e6;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .32);
    overflow: hidden;
}

.dse-ai-chat.is-open .dse-ai-chat-panel {
    display: grid;
    grid-template-rows: auto auto auto 1fr auto;
}

.dse-ai-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .22), transparent 36%),
        linear-gradient(135deg, #0f172a 0%, #111c31 100%);
    color: #ffffff;
}

.dse-ai-chat-title {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.dse-ai-chat-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #2563eb;
    color: #ffffff;
}

.dse-ai-chat-title strong {
    display: block;
    color: #ffffff;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.15;
}

.dse-ai-chat-title > div > span {
    display: block;
    margin-top: 3px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.dse-ai-chat-head-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.dse-ai-chat-close,
.dse-ai-chat-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 12px;
    background: rgba(255, 255, 255, .08);
    color: #ffffff;
    cursor: pointer;
}

.dse-ai-chat-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.dse-ai-chat-status span {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 5px 8px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.dse-ai-chat-actions {
    display: flex;
    gap: 8px;
    padding: 11px 12px;
    overflow-x: auto;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.dse-ai-chat-actions button,
.dse-ai-chat-card a {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 11px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.dse-ai-chat-actions button {
    gap: 6px;
}

.dse-ai-chat-actions button i {
    font-size: 12px;
}

.dse-ai-chat-log {
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    background:
        radial-gradient(circle at 12% 0%, rgba(37, 99, 235, .06), transparent 32%),
        #ffffff;
}

.dse-ai-chat-message {
    display: grid;
    gap: 8px;
    margin-bottom: 13px;
}

.dse-ai-chat-bubble {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
    white-space: pre-wrap;
}

.dse-ai-chat-message.is-assistant .dse-ai-chat-bubble {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #0f172a;
}

.dse-ai-chat-message.is-user {
    justify-items: end;
}

.dse-ai-chat-message.is-user .dse-ai-chat-bubble {
    background: #2563eb;
    color: #ffffff;
}

.dse-ai-chat-cards {
    display: grid;
    gap: 8px;
    max-width: 96%;
}

.dse-ai-chat-card {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
}

.dse-ai-chat-card strong {
    color: #0f172a;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.25;
}

.dse-ai-chat-card p {
    margin: 0;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

.dse-ai-chat-card a {
    width: fit-content;
    border-radius: 10px;
}

.dse-ai-chat-signals {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    max-width: 96%;
}

.dse-ai-chat-signals span {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 5px;
    align-items: center;
    min-height: 30px;
    padding: 7px 9px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    font-size: 11px;
    line-height: 1;
}

.dse-ai-chat-signals b,
.dse-ai-chat-signals em {
    font-style: normal;
    line-height: 1;
}

.dse-ai-chat-signals b {
    color: #64748b;
    font-weight: 900;
    text-transform: uppercase;
}

.dse-ai-chat-signals em {
    color: #0f172a;
    font-weight: 900;
}

.dse-ai-chat-signals .tone-info {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.dse-ai-chat-signals .tone-good {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.dse-ai-chat-signals .tone-warning {
    border-color: #fed7aa;
    background: #fff7ed;
}

.dse-ai-chat-signals .tone-danger {
    border-color: #fecaca;
    background: #fff1f2;
}

.dse-ai-chat-model {
    width: fit-content;
    max-width: 96%;
    padding: 6px 9px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #f8fbff;
    color: #475569;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.2;
}

.dse-ai-chat-context,
.dse-ai-chat-drafts {
    display: grid;
    gap: 8px;
    max-width: 96%;
}

.dse-ai-chat-context-card,
.dse-ai-chat-draft {
    display: grid;
    gap: 7px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #2563eb;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .04);
}

.dse-ai-chat-context-card.is-missing {
    border-left-color: #f59e0b;
    background: #fffaf0;
}

.dse-ai-chat-context-card.is-page {
    border-left-color: #0f9f9a;
}

.dse-ai-chat-context-card strong,
.dse-ai-chat-draft strong {
    color: #0f172a;
    font-size: 12.5px;
    font-weight: 900;
    line-height: 1.2;
}

.dse-ai-chat-context-card p,
.dse-ai-chat-draft p {
    margin: 0;
    color: #475569;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.42;
}

.dse-ai-chat-context-card a {
    width: fit-content;
    min-height: 30px;
    padding: 7px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    text-decoration: none;
}

.dse-ai-chat-draft {
    border-left-color: #7c3aed;
    background: #fbfaff;
}

.dse-ai-chat-draft-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.dse-ai-chat-draft-tools button {
    min-height: 30px;
    padding: 7px 10px;
    border: 1px solid #ddd6fe;
    border-radius: 9px;
    background: #ffffff;
    color: #5b21b6;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.dse-ai-chat-steps {
    display: grid;
    gap: 6px;
    max-width: 96%;
    margin: 0;
    padding: 10px 10px 10px 30px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.38;
}

.dse-ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    max-width: 96%;
}

.dse-ai-chat-suggestions button {
    min-height: 32px;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #ffffff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.dse-ai-chat-typing .dse-ai-chat-bubble {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    min-width: 58px;
}

.dse-ai-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2563eb;
    opacity: .42;
    animation: dse-ai-typing 1s ease-in-out infinite;
}

.dse-ai-chat-typing span:nth-child(2) {
    animation-delay: .12s;
}

.dse-ai-chat-typing span:nth-child(3) {
    animation-delay: .24s;
}

@keyframes dse-ai-typing {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: .34;
    }

    40% {
        transform: translateY(-4px);
        opacity: .92;
    }
}

.dse-ai-chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

.dse-ai-chat-form textarea {
    width: 100%;
    min-height: 42px;
    max-height: 120px;
    resize: none;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 13px;
    background: #ffffff;
    color: #0f172a;
    padding: 11px 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.dse-ai-chat-form textarea:focus {
    outline: 2px solid rgba(37, 99, 235, .24);
    outline-offset: 2px;
}

.dse-ai-chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 13px;
    background: #2563eb;
    color: #ffffff;
    cursor: pointer;
}

.dse-ai-chat-send[disabled] {
    opacity: .62;
    cursor: wait;
}

@media (max-width: 560px) {
    .dse-ai-chat {
        right: 16px;
        bottom: 16px;
    }

    .dse-ai-chat-panel {
        right: -6px;
        bottom: 70px;
        width: calc(100vw - 20px);
        height: min(620px, calc(100vh - 100px));
    }
}
