/* ==========================================================================
   BASWOOL AI CHAT
   ========================================================================== */

.baswool-ai-chat,
.baswool-ai-chat *,
.baswool-ai-chat *::before,
.baswool-ai-chat *::after {
    box-sizing: border-box;
}

.baswool-ai-chat {
    --bw-green-deep: #1f3410;
    --bw-green-dark: #304d17;
    --bw-green: #5e7e29;
    --bw-green-light: #91b957;
    --bw-green-pale: #eaf3dc;
    --bw-orange: #e14d2a;
    --bw-orange-dark: #b83c20;
    --bw-text: #203016;
    --bw-muted: #718068;
    --bw-border: rgba(94, 126, 41, .2);

    position: fixed;
    right: calc(8px + env(safe-area-inset-right, 0px));
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: auto;
    z-index: 999999;

    display: flex;
    flex-direction: column;
    align-items: flex-end;

    width: auto;
    max-width: calc(100vw - 16px);

    color: var(--bw-text);
    font-family: Inter, Arial, Helvetica, sans-serif;

    pointer-events: none;
}

.baswool-ai-chat button,
.baswool-ai-chat input {
    font: inherit;
}

/* ==========================================================================
   BACKDROP
   ========================================================================== */

.baswool-ai-chat .bw-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1;

    visibility: hidden;
    opacity: 0;
    pointer-events: none;

    background: rgba(24, 38, 14, .18);

    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);

    transition:
        opacity .4s ease,
        visibility .4s ease,
        backdrop-filter .4s ease,
        -webkit-backdrop-filter .4s ease;
}

.baswool-ai-chat .bw-backdrop.is-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;

    backdrop-filter: blur(7px) saturate(90%);
    -webkit-backdrop-filter: blur(7px) saturate(90%);
}

/* ==========================================================================
   FRAME
   ========================================================================== */

.baswool-ai-chat .bw-frame {
    position: relative;
    z-index: 2;

    width: min(470px, calc(100vw - 16px));
    height: min(720px, calc(100vh - 92px));
    height: min(720px, calc(100dvh - 92px));

    margin: 0 0 12px;

    visibility: hidden;
    opacity: 0;
    pointer-events: none;

    transform: translateY(22px) scale(.96);
    transform-origin: right bottom;

    transition:
        opacity .3s ease,
        transform .4s cubic-bezier(.22, .8, .24, 1),
        visibility .3s ease;
}

.baswool-ai-chat .bw-frame.is-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;

    transform: translateY(0) scale(1);
}

.baswool-ai-chat .bw-frame.is-expanded {
    position: fixed;
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;

    width: min(1180px, calc(100vw - 96px));
    height: min(820px, calc(100vh - 48px));
    height: min(820px, calc(100dvh - 48px));

    margin: 0;
    overflow: visible;
    isolation: isolate;

    transform: translate(-50%, -50%);
    transform-origin: center;
}

.baswool-ai-chat .bw-frame.is-expanded.is-active {
    transform: translate(-50%, -50%);
}

/* ==========================================================================
   OUTER ORANGE PULSE
   ========================================================================== */

.baswool-ai-chat .bw-frame.is-expanded::before,
.baswool-ai-chat .bw-frame.is-expanded::after {
    position: absolute;
    top: 8%;
    bottom: 8%;
    z-index: -1;

    width: 82px;

    content: "";
    pointer-events: none;

    opacity: 0;

    border-radius: 50%;
    filter: blur(23px);
}

.baswool-ai-chat .bw-frame.is-expanded::before {
    left: -51px;

    background:
        radial-gradient(
            ellipse at right center,
            rgba(255, 117, 75, .94) 0%,
            rgba(225, 77, 42, .58) 30%,
            rgba(225, 77, 42, .16) 62%,
            transparent 84%
        );
}

.baswool-ai-chat .bw-frame.is-expanded::after {
    right: -51px;

    background:
        radial-gradient(
            ellipse at left center,
            rgba(255, 117, 75, .94) 0%,
            rgba(225, 77, 42, .58) 30%,
            rgba(225, 77, 42, .16) 62%,
            transparent 84%
        );
}

.baswool-ai-chat .bw-frame.is-expanded.is-active::before {
    animation: bwPulseLeft 4.8s ease-in-out infinite;
}

.baswool-ai-chat .bw-frame.is-expanded.is-active::after {
    animation: bwPulseRight 4.8s ease-in-out 2.4s infinite;
}

@keyframes bwPulseLeft {
    0%,
    100% {
        opacity: .2;
        transform: translateX(10px) scaleX(.72) scaleY(.85);
        filter: blur(28px);
    }

    50% {
        opacity: .96;
        transform: translateX(-13px) scaleX(1.3) scaleY(1.06);
        filter: blur(17px);
    }
}

@keyframes bwPulseRight {
    0%,
    100% {
        opacity: .2;
        transform: translateX(-10px) scaleX(.72) scaleY(.85);
        filter: blur(28px);
    }

    50% {
        opacity: .96;
        transform: translateX(13px) scaleX(1.3) scaleY(1.06);
        filter: blur(17px);
    }
}

/* ==========================================================================
   WINDOW
   ========================================================================== */

.baswool-ai-chat .bw-window {
    position: relative;

    display: flex;
    flex-direction: column;

    width: 100%;
    height: 100%;

    overflow: hidden;

    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, .91),
            rgba(235, 245, 224, .78)
        );

    border: 1px solid rgba(255, 255, 255, .92);
    border-radius: 28px;

    box-shadow:
        0 30px 90px rgba(28, 55, 13, .3),
        0 8px 24px rgba(27, 42, 15, .12);

    backdrop-filter: blur(30px) saturate(145%);
    -webkit-backdrop-filter: blur(30px) saturate(145%);
}

.baswool-ai-chat .bw-frame.is-expanded .bw-window {
    box-shadow:
        0 36px 110px rgba(20, 37, 10, .4),
        0 0 0 1px rgba(255, 255, 255, .48);
}

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

.baswool-ai-chat .bw-header {
    position: relative;

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

    flex: 0 0 auto;

    min-height: 106px;
    padding: 20px 22px;

    overflow: hidden;

    color: #fff;

    background:
        linear-gradient(
            135deg,
            var(--bw-green-deep),
            var(--bw-green-dark) 54%,
            var(--bw-green)
        );

    border-bottom: 1px solid rgba(255, 255, 255, .24);
}

.baswool-ai-chat .bw-header::before {
    position: absolute;
    inset: 0;

    content: "";
    pointer-events: none;

    background:
        linear-gradient(
            100deg,
            transparent 15%,
            rgba(255, 255, 255, .11) 50%,
            transparent 75%
        );

    transform: translateX(-100%);
    animation: bwHeaderLight 7s ease-in-out infinite;
}

@keyframes bwHeaderLight {
    0%,
    25% {
        transform: translateX(-100%);
    }

    55%,
    100% {
        transform: translateX(100%);
    }
}

.baswool-ai-chat .bw-brand,
.baswool-ai-chat .bw-actions {
    position: relative;
    z-index: 1;
}

.baswool-ai-chat .bw-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.baswool-ai-chat .bw-logo {
    display: grid;
    place-items: center;

    width: 51px;
    height: 51px;
    flex: 0 0 51px;

    color: var(--bw-green-dark);

    font-size: 23px;
    font-weight: 900;

    background: linear-gradient(145deg, #fff, #dcebc3);

    border: 2px solid rgba(255, 255, 255, .72);
    border-radius: 16px;

    box-shadow:
        0 8px 20px rgba(0, 0, 0, .2),
        inset 0 1px 0 rgba(255, 255, 255, .9);
}

.baswool-ai-chat .bw-title {
    min-width: 0;
}

.baswool-ai-chat .bw-title strong {
    display: block;

    color: #fff;

    font-size: 18px;
    font-weight: 800;
    letter-spacing: .7px;
}

.baswool-ai-chat .bw-status {
    display: flex;
    align-items: center;
    gap: 7px;

    margin-top: 7px;

    color: rgba(255, 255, 255, .75);

    font-size: 10px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.baswool-ai-chat .bw-status::before {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;

    content: "";

    background: #baf276;
    border-radius: 50%;

    box-shadow:
        0 0 0 4px rgba(186, 242, 118, .15),
        0 0 13px #baf276;
}

.baswool-ai-chat .bw-actions {
    display: flex;
    gap: 7px;
    align-items: center;

    margin-left: 12px;
}

.baswool-ai-chat .bw-icon-button {
    display: grid;
    place-items: center;

    width: 36px;
    height: 36px;
    flex: 0 0 36px;

    padding: 0;

    color: #fff;

    cursor: pointer;

    background: rgba(255, 255, 255, .14);

    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 50%;
    outline: none;

    transition:
        background .2s ease,
        transform .2s ease;
}

.baswool-ai-chat .bw-icon-button:hover,
.baswool-ai-chat .bw-icon-button:focus-visible {
    background: rgba(255, 255, 255, .3);
    transform: translateY(-2px);
}

.baswool-ai-chat .bw-icon-button svg {
    display: block;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* ==========================================================================
   CONTEXT
   ========================================================================== */

.baswool-ai-chat .bw-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    flex: 0 0 auto;

    min-height: 40px;
    padding: 0 18px;

    color: var(--bw-muted);

    font-size: 10px;
    letter-spacing: .5px;
    text-transform: uppercase;

    background: rgba(255, 255, 255, .5);
    border-bottom: 1px solid rgba(94, 126, 41, .18);
}

.baswool-ai-chat .bw-context-label {
    display: flex;
    align-items: center;
    gap: 7px;
}

.baswool-ai-chat .bw-context-label::before {
    width: 6px;
    height: 6px;
    flex: 0 0 6px;

    content: "";

    background: var(--bw-orange);
    border-radius: 50%;

    box-shadow: 0 0 9px var(--bw-orange);
}

.baswool-ai-chat .bw-context-code {
    color: var(--bw-green);
    font-size: 9px;
    font-weight: 700;
}

/* ==========================================================================
   BODY / MESSAGES
   ========================================================================== */

.baswool-ai-chat .bw-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 14px;

    min-height: 0;
    padding: 22px;

    overflow-x: hidden;
    overflow-y: auto;

    background:
        linear-gradient(
            rgba(255, 255, 255, .2) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(94, 126, 41, .06) 1px,
            transparent 1px
        ),
        rgba(245, 249, 241, .5);

    background-size:
        100% 34px,
        34px 100%;

    scrollbar-color: #a9bd91 transparent;
    scrollbar-width: thin;
}

.baswool-ai-chat .bw-frame.is-expanded .bw-body {
    padding: 30px 38px;
}

.baswool-ai-chat .bw-welcome,
.baswool-ai-chat .bw-message {
    max-width: 91%;

    padding: 15px 17px;

    font-size: 13.5px;
    line-height: 1.58;

    overflow-wrap: anywhere;

    animation: bwMessageAppear .25s ease both;
}

@keyframes bwMessageAppear {
    from {
        opacity: 0;
        transform: translateY(7px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.baswool-ai-chat .bw-welcome,
.baswool-ai-chat .bw-message.bot {
    align-self: flex-start;

    color: var(--bw-text);

    background: rgba(255, 255, 255, .84);

    border: 1px solid rgba(255, 255, 255, .96);
    border-radius: 19px 19px 19px 6px;

    box-shadow:
        0 8px 24px rgba(46, 80, 24, .08);
}

.baswool-ai-chat .bw-welcome {
    max-width: 360px;
    padding: 18px 19px;
}

.baswool-ai-chat .bw-welcome::before {
    display: block;

    margin-bottom: 9px;

    color: var(--bw-green);

    content: "BASWOOL AI / READY";

    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.2px;
}

.baswool-ai-chat .bw-welcome strong {
    display: block;

    margin-bottom: 7px;

    color: var(--bw-green-dark);
    font-size: 15px;
}

.baswool-ai-chat .bw-message.user {
    align-self: flex-end;

    color: #fff;

    background:
        linear-gradient(
            135deg,
            var(--bw-green),
            var(--bw-green-dark)
        );

    border-radius: 19px 19px 6px 19px;

    box-shadow:
        0 9px 23px rgba(63, 100, 30, .22);
}

.baswool-ai-chat .bw-message p {
    padding: 0;
    margin: 0 0 10px;
}

.baswool-ai-chat .bw-message p:last-child {
    margin-bottom: 0;
}

.baswool-ai-chat .bw-message h2,
.baswool-ai-chat .bw-message h3,
.baswool-ai-chat .bw-message h4 {
    padding: 0;
    margin: 14px 0 8px;

    color: var(--bw-green-dark);

    font-size: 16px;
    line-height: 1.3;
}

.baswool-ai-chat .bw-message ul,
.baswool-ai-chat .bw-message ol {
    padding-left: 22px;
    margin: 8px 0 11px;
}

.baswool-ai-chat .bw-message li {
    margin: 5px 0;
}

.baswool-ai-chat .bw-message strong {
    color: var(--bw-green-dark);
    font-weight: 700;
}

.baswool-ai-chat .bw-message.user strong {
    color: #fff;
}

.baswool-ai-chat .bw-message a {
    color: #1468a8;
    text-decoration: underline;
    overflow-wrap: anywhere;
}

.baswool-ai-chat .bw-message a:hover,
.baswool-ai-chat .bw-message a:focus-visible {
    color: var(--bw-orange);
}

/* ==========================================================================
   TABLES
   ========================================================================== */

.baswool-ai-chat .bw-table-wrapper {
    display: block;

    width: 100%;
    max-width: 100%;

    margin: 12px 0;

    overflow-x: auto;
    overflow-y: hidden;

    background: rgba(255, 255, 255, .86);

    border: 1px solid rgba(94, 126, 41, .24);
    border-radius: 14px;

    box-shadow: 0 5px 16px rgba(45, 74, 25, .06);

    -webkit-overflow-scrolling: touch;
}

.baswool-ai-chat .bw-markdown-table {
    display: table;

    width: max-content;
    min-width: 100%;

    border-collapse: collapse;
    border-spacing: 0;

    color: var(--bw-text);

    font-size: 12px;
    line-height: 1.45;
}

.baswool-ai-chat .bw-markdown-table th,
.baswool-ai-chat .bw-markdown-table td {
    min-width: 100px;
    max-width: 310px;

    padding: 10px 11px;

    text-align: left;
    vertical-align: top;

    border-right: 1px solid rgba(94, 126, 41, .17);
    border-bottom: 1px solid rgba(94, 126, 41, .17);

    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.baswool-ai-chat .bw-markdown-table th:last-child,
.baswool-ai-chat .bw-markdown-table td:last-child {
    border-right: 0;
}

.baswool-ai-chat .bw-markdown-table tbody tr:last-child td {
    border-bottom: 0;
}

.baswool-ai-chat .bw-markdown-table th {
    color: var(--bw-green-dark);

    font-weight: 800;
    white-space: nowrap;

    background:
        linear-gradient(
            135deg,
            #dcebc3,
            #eef6e5
        );
}

.baswool-ai-chat .bw-markdown-table tbody tr:nth-child(even) td {
    background: rgba(250, 252, 248, .8);
}

.baswool-ai-chat .bw-markdown-table tbody tr:hover td {
    background: rgba(234, 243, 220, .82);
}

.baswool-ai-chat .bw-markdown-table a {
    color: #1468a8;
    text-decoration: underline;
}

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

.baswool-ai-chat .bw-typing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;

    width: 70px;
    min-height: 44px;
}

.baswool-ai-chat .bw-typing span {
    width: 7px;
    height: 7px;

    background: var(--bw-green);
    border-radius: 50%;

    animation:
        bwTypingDot
        1.1s
        infinite
        ease-in-out;
}

.baswool-ai-chat .bw-typing span:nth-child(2) {
    animation-delay: .15s;
}

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

@keyframes bwTypingDot {
    0%,
    60%,
    100% {
        opacity: .3;
        transform: translateY(0);
    }

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

/* ==========================================================================
   FOOTER
   ========================================================================== */

.baswool-ai-chat .bw-footer {
    display: flex;
    align-items: center;
    gap: 10px;

    flex: 0 0 auto;

    padding: 14px 16px 16px;

    background: rgba(255, 255, 255, .64);
    border-top: 1px solid rgba(94, 126, 41, .18);

    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.baswool-ai-chat .bw-frame.is-expanded .bw-footer {
    padding: 18px 38px;
}

.baswool-ai-chat .bw-input {
    display: block;
    flex: 1 1 auto;

    width: 100%;
    min-width: 0;
    height: 49px;

    padding: 0 18px;

    color: var(--bw-text);

    background: rgba(255, 255, 255, .88);

    border: 1px solid rgba(94, 126, 41, .2);
    border-radius: 25px;
    outline: none;

    transition:
        border-color .2s ease,
        box-shadow .2s ease,
        background .2s ease;
}

.baswool-ai-chat .bw-input::placeholder {
    color: #91a085;
}

.baswool-ai-chat .bw-input:focus {
    background: #fff;
    border-color: var(--bw-green-light);

    box-shadow:
        0 0 0 4px rgba(94, 126, 41, .13);
}

.baswool-ai-chat .bw-send-button {
    display: grid;
    place-items: center;

    width: 49px;
    height: 49px;
    flex: 0 0 49px;

    padding: 0;

    color: #fff;

    cursor: pointer;

    background:
        linear-gradient(
            145deg,
            #eb704b,
            var(--bw-orange-dark)
        );

    border: 0;
    border-radius: 50%;
    outline: none;

    box-shadow:
        0 8px 19px rgba(197, 62, 30, .28);

    transition:
        transform .2s ease,
        box-shadow .2s ease;
}

.baswool-ai-chat .bw-send-button:hover,
.baswool-ai-chat .bw-send-button:focus-visible {
    transform: translateY(-2px) scale(1.04);

    box-shadow:
        0 12px 26px rgba(197, 62, 30, .38);
}

.baswool-ai-chat .bw-send-button svg {
    display: block;
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.baswool-ai-chat button:disabled,
.baswool-ai-chat input:disabled {
    cursor: wait;
    opacity: .65;
}

/* ==========================================================================
   TRIGGER
   ========================================================================== */

.baswool-ai-chat .bw-trigger {
    position: relative;
    z-index: 3;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    min-width: 184px;
    min-height: 56px;

    padding: 0 22px;

    color: #fff;

    font-size: 12px;
    font-weight: 800;
    letter-spacing: .45px;
    text-transform: uppercase;

    cursor: pointer;
    pointer-events: auto;

    background:
        linear-gradient(
            135deg,
            var(--bw-green),
            var(--bw-green-dark)
        );

    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 30px;
    outline: none;

    box-shadow:
        0 14px 32px rgba(63, 100, 30, .32),
        0 0 0 5px rgba(94, 126, 41, .08);

    transition:
        opacity .25s ease,
        visibility .25s ease,
        transform .25s ease,
        box-shadow .25s ease;
}

.baswool-ai-chat .bw-trigger:hover,
.baswool-ai-chat .bw-trigger:focus-visible {
    transform: translateY(-3px);

    box-shadow:
        0 18px 40px rgba(63, 100, 30, .4),
        0 0 0 7px rgba(94, 126, 41, .1);
}

.baswool-ai-chat .bw-trigger svg {
    display: block;
    width: 20px;
    height: 20px;
}

.baswool-ai-chat .bw-frame.is-expanded ~ .bw-trigger {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

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

@media (max-width: 600px) {
    .baswool-ai-chat {
        right: calc(6px + env(safe-area-inset-right, 0px));
        bottom: calc(6px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 12px);
    }

    .baswool-ai-chat .bw-frame {
        width: calc(100vw - 12px);
        height: calc(100dvh - 82px);

        margin-bottom: 10px;
    }

    .baswool-ai-chat .bw-window {
        border-radius: 22px;
    }

    .baswool-ai-chat .bw-header {
        min-height: 94px;
        padding: 15px;
    }

    .baswool-ai-chat .bw-logo {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
        border-radius: 15px;
    }

    .baswool-ai-chat .bw-title strong {
        font-size: 16px;
    }

    .baswool-ai-chat .bw-status {
        font-size: 9px;
    }

    .baswool-ai-chat .bw-context {
        padding: 0 15px;
    }

    .baswool-ai-chat .bw-context-code {
        display: none;
    }

    .baswool-ai-chat .bw-body,
    .baswool-ai-chat .bw-frame.is-expanded .bw-body {
        padding: 17px;
    }

    .baswool-ai-chat .bw-message,
    .baswool-ai-chat .bw-welcome {
        max-width: 95%;
        font-size: 13px;
    }

    .baswool-ai-chat .bw-footer,
    .baswool-ai-chat .bw-frame.is-expanded .bw-footer {
        padding: 12px;
    }

    .baswool-ai-chat .bw-trigger {
        width: 56px;
        height: 56px;
        min-width: 56px;
        min-height: 56px;

        padding: 0;

        border-radius: 50%;
    }

    .baswool-ai-chat .bw-trigger span {
        display: none;
    }

    .baswool-ai-chat .bw-frame.is-expanded {
        width: calc(100vw - 20px);
        height: calc(100dvh - 20px);
    }

    .baswool-ai-chat .bw-frame.is-expanded::before,
    .baswool-ai-chat .bw-frame.is-expanded::after {
        width: 38px;
        filter: blur(14px);
    }

    .baswool-ai-chat .bw-frame.is-expanded::before {
        left: -18px;
    }

    .baswool-ai-chat .bw-frame.is-expanded::after {
        right: -18px;
    }

    .baswool-ai-chat .bw-markdown-table {
        min-width: 850px;
        font-size: 11px;
    }

    .baswool-ai-chat .bw-markdown-table th,
    .baswool-ai-chat .bw-markdown-table td {
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .baswool-ai-chat *,
    .baswool-ai-chat *::before,
    .baswool-ai-chat *::after {
        animation: none !important;
        transition: none !important;
    }
}