:host {
    all: initial;
    display: block;
}

#isaforma-assistente {
    --isa-ink: #17241f;
    --isa-green: #184a39;
    --isa-soft: #e7f2eb;
    --isa-surface: #f5f8f5;
    --isa-line: #d7e4dc;
    visibility: visible !important;
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    z-index: 99999;
    align-items: flex-end;
    color: var(--isa-ink);
    font: 400 14px/1.5 system-ui, sans-serif;
    text-align: left;
}

#isaforma-assistente.left {
    right: auto;
    left: max(16px, env(safe-area-inset-left));
}

#isaforma-assistente *,
#isaforma-assistente *::before,
#isaforma-assistente *::after { box-sizing: border-box; }
#isaforma-assistente [hidden] { display: none !important; }

#isaforma-assistente button {
    appearance: none;
    cursor: pointer;
    margin: 0;
    border: 0;
    font: inherit;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
}
#isaforma-assistente button:disabled { cursor: default; opacity: .6; }
#isaforma-assistente :focus-visible { outline: 2px solid #197653; outline-offset: 3px; }

#isaforma-assistente .isaforma-launch,
#isaforma-assistente .isaforma-send {
    color: #fff;
    background: var(--isa-green);
    font-weight: 650;
}
#isaforma-assistente .isaforma-launch {
    padding: 14px 20px;
    min-height: 46px;
    border-radius: 999px;
    box-shadow: 0 6px 20px #14271e38;
}
#isaforma-assistente .isaforma-launch img {
    display: inline-block;
    vertical-align: middle;
    object-fit: cover;
    border-radius: 50%;
}

#isaforma-assistente .isaforma-panel {
    display: flex;
    flex-direction: column;
    width: min(450px, calc(100vw - 32px));
    height: min(680px, calc(100vh - 32px));
    height: min(680px, calc(100dvh - 32px));
    background: var(--isa-surface);
    border: 1px solid var(--isa-line);
    border-radius: 17px;
    overflow: hidden;
    box-shadow: 0 16px 48px #14271e3d;
}

#isaforma-assistente .isaforma-heading {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    gap: 12px;
    background: linear-gradient(110deg, #123b2d, var(--isa-green));
    color: #fff;
}
#isaforma-assistente .isaforma-identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}
#isaforma-assistente .isaforma-brand { min-width: 0; }
#isaforma-assistente h2 {
    margin: 0;
    color: #fff;
    overflow-wrap: anywhere;
    font: 650 17px/1.25 system-ui, sans-serif;
}
#isaforma-assistente .isaforma-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    overflow: hidden;
    border-radius: 50%;
    background: #d8f0df;
    color: var(--isa-green);
    font-size: 21px;
    font-weight: 750;
}
#isaforma-assistente .isaforma-avatar img { width: 100%; height: 100%; object-fit: cover; }
#isaforma-assistente .isaforma-role {
    display: block;
    margin-top: 2px;
    color: #e0f0e5;
    font-size: 12px;
}
#isaforma-assistente .isaforma-close {
    color: #fff;
    background: #ffffff19;
    flex: 0 0 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    font-size: 23px;
}
#isaforma-assistente .isaforma-close:focus-visible { outline-color: #fff; }

#isaforma-assistente .isaforma-conversation {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 16px 16px 5px;
}
#isaforma-assistente p { font-size: 14px; color: inherit; overflow-wrap: anywhere; }
#isaforma-assistente .isaforma-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}
#isaforma-assistente .isaforma-message .isaforma-avatar {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    margin-top: 2px;
    font-size: 15px;
}
#isaforma-assistente .isaforma-bubble {
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px 11px;
    border: 1px solid var(--isa-line);
    border-radius: 5px 13px 13px 13px;
    background: #fff;
    white-space: pre-wrap;
}
#isaforma-assistente .isaforma-own { justify-content: flex-end; }
#isaforma-assistente .isaforma-own .isaforma-bubble {
    max-width: 88%;
    border-color: transparent;
    border-radius: 13px 5px 13px 13px;
    background: var(--isa-soft);
}
#isaforma-assistente .isaforma-sources { margin: 0 0 10px 38px; padding: 0; list-style: none; }
#isaforma-assistente .isaforma-sources li {
    margin: 0 0 7px;
    padding: 10px 12px;
    border: 1px solid var(--isa-line);
    border-left: 3px solid #478369;
    border-radius: 8px 12px 12px 8px;
    background: #fff;
}
#isaforma-assistente a {
    color: var(--isa-green);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}
#isaforma-assistente .isaforma-sources p { margin: 5px 0 0; }
#isaforma-assistente .isaforma-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 12px 38px;
    font-size: 12px;
    color: #3a594b;
}
#isaforma-assistente .isaforma-dots { display: flex; align-items: center; gap: 3px; }
#isaforma-assistente .isaforma-dots i {
    width: 5px;
    height: 5px;
    background: #3c795d;
    border-radius: 50%;
    animation: isaforma-typing 1s ease-in-out infinite;
}
#isaforma-assistente .isaforma-dots i:nth-child(2) { animation-delay: .14s; }
#isaforma-assistente .isaforma-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes isaforma-typing {
    0%, 60%, 100% { opacity: .45; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
    #isaforma-assistente .isaforma-dots i { animation: none; }
}

#isaforma-assistente .isaforma-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 16px 11px;
}
#isaforma-assistente .isaforma-suggestions button {
    background: var(--isa-soft);
    color: var(--isa-green);
    border-radius: 999px;
    padding: 7px 9px;
    font-size: 12px;
}

#isaforma-assistente .isaforma-composer {
    flex: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px 15px 11px;
    background: #fff;
    border-top: 1px solid var(--isa-line);
}
#isaforma-assistente .isaforma-actions,
#isaforma-assistente .isaforma-transcript-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
}
#isaforma-assistente .isaforma-actions button,
#isaforma-assistente .isaforma-actions a,
#isaforma-assistente .isaforma-transcript-options button,
#isaforma-assistente .isaforma-transcript-options a {
    display: inline-block;
    padding: 6px 8px;
    border-radius: 7px;
    color: var(--isa-green);
    background: var(--isa-soft);
    font: 600 12px/1.25 system-ui, sans-serif;
    text-decoration: none;
}
#isaforma-assistente .isaforma-actions .isaforma-contact {
    background: #fff;
    border: 1px solid var(--isa-line);
}
#isaforma-assistente .isaforma-transcript-options {
    padding: 7px;
    background: var(--isa-surface);
    border-radius: 8px;
}
#isaforma-assistente .isaforma-transcript-note { flex: 1 0 100%; margin: 0; font-size: 12px; }

#isaforma-assistente form { width: 100%; margin: 0; padding: 0; }
#isaforma-assistente .isaforma-input-row { display: flex; gap: 8px; align-items: stretch; }
#isaforma-assistente textarea {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 8px 10px;
    min-height: 48px;
    max-height: 96px;
    resize: none;
    border: 1px solid #99b4a4;
    border-radius: 10px;
    background: #fff;
    color: var(--isa-ink);
    font: 400 16px/1.35 system-ui, sans-serif;
    box-shadow: none;
}
#isaforma-assistente .isaforma-send { min-height: 44px; padding: 8px 13px; border-radius: 10px; }
#isaforma-assistente small { display: block; margin-top: 4px; font-size: 11px; }
#isaforma-assistente .isaforma-screen-reader {
    position: absolute;
    padding: 0;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
    width: 1px;
    height: 1px;
}
#isaforma-assistente .isaforma-launch-avatar {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    padding: 4px;
    border: 2px solid #fff;
}
#isaforma-assistente .isaforma-launch-avatar img {
    width: 52px;
    height: 52px;
}
#isaforma-assistente .isaforma-launch-avatar .isaforma-launch-label { display: none; }

#isaforma-assistente .isaforma-source-type {
    display: block;
    margin-bottom: 4px;
    color: #426251;
    font-size: 11px;
    font-weight: 650;
}
#isaforma-assistente .isaforma-sources h3 {
    margin: 0 0 4px;
    color: var(--isa-ink);
    font-size: 14px;
    line-height: 1.4;
    font-weight: 700;
}
#isaforma-assistente .isaforma-source-facts {
    display: grid;
    gap: 5px;
    margin: 8px 0;
    padding: 8px;
    border-radius: 6px;
    background: var(--isa-surface);
}
#isaforma-assistente .isaforma-source-facts div { min-width: 0; }
#isaforma-assistente .isaforma-source-facts dt {
    color: #426251;
    font-size: 11px;
    font-weight: 650;
}
#isaforma-assistente .isaforma-source-facts dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 640px), (pointer: coarse) and (max-height: 520px) {
    #isaforma-assistente[data-open="true"] {
        top: var(--isa-viewport-top, 0px);
        left: var(--isa-viewport-left, 0px);
        right: auto;
        bottom: auto;
        width: var(--isa-viewport-width, 100%);
        height: 100vh;
        height: var(--isa-viewport-height, 100dvh);
    }

    #isaforma-assistente .isaforma-panel {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    #isaforma-assistente .isaforma-heading {
        padding: calc(9px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 9px max(12px, env(safe-area-inset-left));
    }

    #isaforma-assistente .isaforma-close {
        flex-basis: 44px;
        height: 44px;
    }

    #isaforma-assistente .isaforma-conversation {
        padding-inline: max(11px, env(safe-area-inset-left)) max(11px, env(safe-area-inset-right));
        touch-action: pan-y pinch-zoom;
    }

    #isaforma-assistente .isaforma-conversation:focus-visible {
        outline-offset: -3px;
    }

    #isaforma-assistente .isaforma-bubble {
        font-size: 15px;
        line-height: 1.45;
    }

    #isaforma-assistente .isaforma-sources { margin-left: 0; }
    #isaforma-assistente .isaforma-sources h3 a {
        display: block;
        min-height: 44px;
        padding-block: 9px;
    }

    #isaforma-assistente .isaforma-suggestions {
        flex-wrap: nowrap;
        padding: 4px max(11px, env(safe-area-inset-right)) 7px max(11px, env(safe-area-inset-left));
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    #isaforma-assistente .isaforma-suggestions button {
        flex: 0 0 auto;
        min-height: 44px;
    }

    #isaforma-assistente .isaforma-composer {
        gap: 6px;
        padding: 7px max(11px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(11px, env(safe-area-inset-left));
    }

    #isaforma-assistente .isaforma-actions {
        flex-wrap: nowrap;
        align-items: stretch;
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    #isaforma-assistente .isaforma-actions button,
    #isaforma-assistente .isaforma-actions a,
    #isaforma-assistente .isaforma-transcript-options button,
    #isaforma-assistente .isaforma-transcript-options a {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        white-space: nowrap;
    }

    #isaforma-assistente .isaforma-send { min-width: 54px; }
    #isaforma-assistente button,
    #isaforma-assistente a { touch-action: manipulation; }

    #isaforma-assistente[data-compact="true"] .isaforma-suggestions { display: none; }
    #isaforma-assistente[data-compact="true"] .isaforma-heading { padding-block-start: calc(4px + env(safe-area-inset-top)); padding-block-end: 4px; }
    #isaforma-assistente[data-keyboard="true"] .isaforma-composer { padding-bottom: 8px; }
    #isaforma-assistente[data-keyboard="true"][data-short="true"] .isaforma-actions,
    #isaforma-assistente[data-keyboard="true"][data-short="true"] .isaforma-transcript-options { display: none; }
}
