.ia-bubble-chat {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1055;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ia-bubble-chat__toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent-dodger-blue, #5567ff);
    border: none;
    color: #ffffff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 18px 36px rgba(85, 103, 255, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ia-bubble-chat__toggle:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 24px 46px rgba(85, 103, 255, 0.45);
}

.ia-bubble-chat__toggle:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(85, 103, 255, 0.35);
}

.ia-bubble-chat__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #f97316;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 12px rgba(249, 115, 22, 0.35);
}

.ia-bubble-chat__panel {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: min(384px, 90vw);
    min-height: 360px;
    max-height: calc(100vh - 48px);
    height: auto;
    z-index: 1055;
    background: #ffffff;
    border-radius: 28px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
    display: none;
    flex-direction: column;
    overflow: visible;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.ia-bubble-chat__panel.is-visible {
    display: flex;
}

.ia-bubble-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    background: #fff;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    color: #0f172a;
    cursor: grab;
    user-select: none;
}
.ia-bubble-chat__panel.is-dragging .ia-bubble-chat__header {
    cursor: grabbing;
}
.ia-bubble-chat__header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}
.ia-bubble-chat__header p {
    margin: 2px 0 0;
    font-size: 0.83rem;
    color: #6b7280;
}
.ia-bubble-chat__header-actions {
    display: flex;
    gap: 4px;
}
.ia-bubble-chat__close,
.ia-bubble-chat__minimize {
    background: transparent;
    border: none;
    color: #6b7280;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}
.ia-bubble-chat__close:hover,
.ia-bubble-chat__minimize:hover {
    background: rgba(17, 24, 39, 0.08);
    color: #0f172a;
}

.ia-bubble-chat__close:focus-visible,
.ia-bubble-chat__minimize:focus-visible {
    outline: 2px solid rgba(17, 24, 39, 0.3);
    outline-offset: 2px;
}

.ia-bubble-chat__context {
    padding: 16px 20px 14px;
    background: #fff;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    z-index: 1;
}

.ia-bubble-chat__select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 11px 14px;
    font-size: 0.95rem;
    color: #0f172a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
    position: relative;
    z-index: 2;
}

.ia-bubble-chat__select:focus {
    border-color: #5865f2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.25);
}

.summary-accordion {
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: #ffffff;
}

.summary-accordion__toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1f2937;
    cursor: pointer;
    transition: background 0.2s ease;
}

.summary-accordion__toggle i {
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.summary-accordion__toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.summary-accordion__toggle:hover {
    background: rgba(85, 103, 255, 0.08);
}

.summary-accordion__toggle:focus-visible {
    outline: 2px solid rgba(85, 103, 255, 0.45);
    outline-offset: 2px;
}

.summary-accordion__panel {
    padding: 0 14px 14px;
}

.summary-accordion__empty {
    margin: 0;
    font-size: 0.85rem;
    color: #475569;
}

#ia-widget-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.8rem;
    color: #475569;
}

.summary-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: #312e81;
    letter-spacing: 0.01em;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
}

.summary-item {
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-item__label {
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    color: var(--accent-dodger-blue, #5567ff);
    letter-spacing: 0.02em;
}

.summary-item__value {
    font-size: 0.8rem;
    color: #1f2937;
}

.ia-bubble-chat__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 18px 20px 12px;
    gap: 14px;
    background: #fff;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.ia-bubble-chat__body::-webkit-scrollbar {
    width: 6px;
}

.ia-bubble-chat__body::-webkit-scrollbar-track {
    background: transparent;
}

.ia-bubble-chat__body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

.ia-bubble-chat__body:hover::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.5);
}

.ia-bubble-chat__empty {
    text-align: center;
    padding: 44px 24px;
    color: #64748b;
    font-size: 0.92rem;
}

.ia-bubble-chat__message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: none;
    position: relative;
    transition: background 0.2s ease;
}
.ia-bubble-chat__content p {
    margin: 0 0 8px;
}
.ia-bubble-chat__content ul {
    margin: 0 0 8px 16px;
    padding: 0;
}
.ia-bubble-chat__content code {
    background: rgba(226, 232, 240, 0.6);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: "Roboto Mono", monospace;
    font-size: 0.78rem;
}
.ia-table-wrapper {
    margin: 8px 0;
    overflow-x: auto;
}
.ia-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.ia-table th,
.ia-table td {
    border: 1px solid rgba(226, 232, 240, 0.9);
    padding: 6px 8px;
    text-align: left;
}
.ia-table th {
    background: rgba(85, 103, 255, 0.08);
    color: #1f2937;
    font-weight: 600;
}
.ia-list {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}
.ia-list li {
    margin-bottom: 6px;
}

.ia-bubble-chat__message.is-unread {
    box-shadow: 0 0 0 2px rgba(85, 103, 255, 0.25), 0 18px 36px rgba(15, 23, 42, 0.18);
}

.ia-bubble-chat__message.is-unread::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid rgba(85, 103, 255, 0.35);
    opacity: 0;
    animation: ia-unread-pulse 2.4s ease-out forwards;
    pointer-events: none;
}

@keyframes ia-unread-pulse {
    0% {
        opacity: 0;
        transform: scale(0.96);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.04);
    }
}

.ia-bubble-chat__message--user {
    align-self: flex-end;
    background: #5865f2;
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.ia-bubble-chat__message--assistant {
    align-self: flex-start;
    background: #f4f5f8;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid transparent;
    color: #1f2937;
}

.ia-bubble-chat__timestamp {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    opacity: 0.65;
    text-align: right;
}

.typing-indicator {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 4px 0;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: var(--accent-dodger-blue, #5567ff);
    opacity: 0.78;
    border-radius: 50%;
    animation: ia-typing-bounce 1.1s infinite ease-in-out;
    box-shadow: 0 0 6px rgba(85, 103, 255, 0.35);
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.18s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes ia-typing-bounce {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

.ia-bubble-chat__footer {
    padding: 16px 20px 18px;
    background: #fff;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.ia-bubble-chat__input {
    flex: 1;
    border: 1px solid #cbd5f5;
    border-radius: 999px;
    padding: 11px 16px;
    font-size: 0.94rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.ia-bubble-chat__input:focus {
    border-color: #5865f2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

.ia-bubble-chat__send {
    background: #5865f2;
    border: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 22px;
    font-weight: 600;
    min-width: 110px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 12px 24px rgba(88, 101, 242, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ia-bubble-chat__send:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(88, 101, 242, 0.35);
}

.ia-bubble-chat__send:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.3);
}

.ia-bubble-chat__resize {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 0 12px;
    cursor: ns-resize;
}

.ia-bubble-chat__resize-handle {
    width: 48px;
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.5);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: background 0.2s ease;
}

.ia-bubble-chat__resize:hover .ia-bubble-chat__resize-handle,
.ia-bubble-chat__panel.is-resizing .ia-bubble-chat__resize-handle {
    background: rgba(88, 101, 242, 0.6);
}

.ia-bubble-chat__loading {
    text-align: center;
    padding: 24px 0;
    color: #64748b;
    font-size: 0.9rem;
}

.ia-bubble-chat__error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 12px;
    padding: 12px 14px;
    text-align: center;
    font-size: 0.85rem;
    margin: 0 18px 12px;
}

@media (max-width: 768px) {
    .ia-bubble-chat {
        bottom: 16px;
        left: 16px;
    }

    .ia-bubble-chat__panel {
        bottom: 90px;
        left: 16px;
        width: calc(100vw - 32px);
        max-height: calc(100vh - 40px);
        min-height: 320px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .ia-bubble-chat__panel {
        bottom: 72px;
        left: 12px;
        width: calc(100vw - 24px);
        border-radius: 16px;
        min-height: 280px;
        max-height: calc(100vh - 32px);
    }

    .ia-bubble-chat__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .ia-bubble-chat__send {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ia-bubble-chat__toggle,
    .ia-bubble-chat__send,
    .ia-bubble-chat__message {
        transition: none;
    }

    .ia-bubble-chat__message.is-unread::after,
    .typing-indicator span {
        animation: none;
    }
}

@media (prefers-color-scheme: dark) {
    .ia-bubble-chat__panel {
        background: rgba(15, 23, 42, 0.92);
        border-color: rgba(71, 85, 105, 0.55);
        box-shadow: 0 24px 64px rgba(8, 15, 26, 0.6);
    }

    .ia-bubble-chat__context {
        background: linear-gradient(180deg, rgba(30, 41, 59, 0.92) 0%, rgba(17, 24, 39, 0.92) 100%);
        border-color: rgba(51, 65, 85, 0.8);
    }

    .summary-accordion {
        background: rgba(30, 41, 59, 0.75);
        border-color: rgba(74, 85, 104, 0.65);
    }

    .summary-accordion__toggle {
        color: #e2e8f0;
    }

    .summary-accordion__toggle:hover {
        background: rgba(79, 70, 229, 0.15);
    }

    .summary-accordion__empty {
        color: #cbd5f5;
    }

    .summary-title {
        color: #e0e7ff;
    }

    .summary-item {
        background: rgba(79, 70, 229, 0.18);
        border-color: rgba(129, 140, 248, 0.35);
    }

    .summary-item__value {
        color: #ede9fe;
    }

    .ia-bubble-chat__body {
        background: rgba(15, 23, 42, 0.9);
        scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
    }

    .ia-bubble-chat__body::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.5);
    }

    .ia-bubble-chat__message--assistant {
        background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(17, 24, 39, 0.95) 100%);
        border-color: rgba(100, 116, 139, 0.45);
        color: #e2e8f0;
    }

    .ia-bubble-chat__message--user {
        background: linear-gradient(135deg, #5567ff 0%, #824ee1 100%);
    }

    .ia-bubble-chat__timestamp {
        color: rgba(226, 232, 240, 0.75);
    }

    .ia-bubble-chat__footer {
        background: rgba(15, 23, 42, 0.92);
        border-color: rgba(71, 85, 105, 0.6);
    }

    .ia-bubble-chat__input {
        background: rgba(15, 23, 42, 0.7);
        color: #e2e8f0;
        border-color: rgba(148, 163, 184, 0.55);
    }

    .ia-bubble-chat__input::placeholder {
        color: rgba(203, 213, 225, 0.6);
    }

    .ia-bubble-chat__send {
        box-shadow: 0 14px 28px rgba(79, 70, 229, 0.45);
    }

    .ia-bubble-chat__empty {
        color: rgba(203, 213, 225, 0.85);
    }

    .ia-bubble-chat__loading {
        color: rgba(203, 213, 225, 0.75);
    }

    .ia-bubble-chat__error {
        background: rgba(153, 27, 27, 0.35);
        color: #fecaca;
        border-color: rgba(248, 113, 113, 0.45);
    }

    .typing-indicator span {
        background: rgba(129, 140, 248, 0.8);
    }

    .ia-bubble-chat__resize-handle {
        background: rgba(148, 163, 184, 0.7);
    }
}
