.chatbot-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    padding: 14px 20px;
    border: none;
    border-radius: 999px;
    background: var(--primary, #2563eb);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
    color: white;
    cursor: pointer;
    font-weight: 700;
    transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.chatbot-toggle:hover {
    background: var(--primary-2, #1d4ed8);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    transform: translateY(-1px);
}

.chatbot-nudge {
    display: none;
    position: fixed;
    right: 24px;
    bottom: 84px;
    z-index: 1000;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--border, rgba(15, 23, 42, 0.10));
    border-radius: 16px;
    background: white;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    color: #111827;
    font-size: 0.9rem;
}

.chatbot-nudge.show {
    display: block;
}

.chatbot-nudge-close {
    position: absolute;
    top: 6px;
    right: 10px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    font-size: 1.1rem;
}

.chatbot-panel {
    display: flex;
    position: fixed;
    right: 24px;
    bottom: 88px;
    z-index: 1001;
    flex-direction: column;
    width: min(400px, calc(100vw - 32px));
    height: min(600px, calc(100vh - 120px));
    overflow: hidden;
    border: 1px solid var(--border, rgba(15, 23, 42, 0.10));
    border-radius: 18px;
    background: white;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.hidden {
    display: none;
}

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 14px;
    background: linear-gradient(135deg, var(--primary, #2563eb), var(--primary-2, #1d4ed8));
    color: white;
}

.chatbot-identity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-identity > span:last-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chatbot-identity strong {
    font-size: 0.92rem;
    line-height: 1.25;
}

.chatbot-identity small {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.72rem;
    font-weight: 500;
}

.chatbot-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.9rem;
    font-weight: 800;
}

.chatbot-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #86efac;
    box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.18);
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-clear {
    padding: 7px 9px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: 700;
    transition: background 160ms ease, opacity 160ms ease;
}

.chatbot-clear:hover {
    background: rgba(255, 255, 255, 0.14);
}

.chatbot-clear:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.chatbot-confirm {
    display: grid;
    position: absolute;
    z-index: 5;
    inset: 0;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(2px);
}

.chatbot-confirm.hidden {
    display: none;
}

.chatbot-confirm-card {
    width: 100%;
    padding: 24px;
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: 18px;
    background: white;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.24);
    color: #111827;
    text-align: center;
}

.chatbot-confirm-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary, #2563eb);
    font-size: 1.45rem;
    font-weight: 800;
}

.chatbot-confirm-card h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.chatbot-confirm-card p {
    margin: 0;
    color: #64748b;
    font-size: 0.84rem;
    line-height: 1.5;
}

.chatbot-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.chatbot-confirm-actions button {
    padding: 10px 12px;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 700;
    transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.chatbot-confirm-cancel {
    border: 1px solid #dbe2ea;
    background: white;
    color: #334155;
}

.chatbot-confirm-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.chatbot-confirm-submit {
    border: 1px solid var(--primary, #2563eb);
    background: var(--primary, #2563eb);
    color: white;
}

.chatbot-confirm-submit:hover {
    background: var(--primary-2, #1d4ed8);
    border-color: var(--primary-2, #1d4ed8);
}

.chatbot-confirm-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.chatbot-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: white;
    cursor: pointer;
    font-size: 1.4rem;
    transition: background 160ms ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.14);
}

.chatbot-disclaimer {
    padding: 9px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.76rem;
    line-height: 1.4;
}

.chatbot-access-note {
    padding: 8px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: rgba(37, 99, 235, 0.06);
    color: #475569;
    font-size: 0.75rem;
    line-height: 1.35;
}

.chatbot-access-note a {
    color: var(--primary-2, #1d4ed8);
    font-weight: 700;
    text-underline-offset: 2px;
}

.chatbot-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 18px 16px;
    background: #ffffff;
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-width: thin;
}

.chatbot-message {
    max-width: 88%;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.bot-message {
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    background: #f1f5f9;
    color: #111827;
}

.user-message {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: var(--primary, #2563eb);
    color: white;
}

.bot-message p,
.bot-message ul,
.bot-message ol,
.bot-message pre,
.bot-message h4,
.bot-message h5,
.bot-message h6 {
    margin: 0 0 8px;
}

.bot-message > :last-child {
    margin-bottom: 0;
}

.bot-message ul,
.bot-message ol {
    padding-left: 20px;
}

.bot-message li + li {
    margin-top: 4px;
}

.bot-message h4,
.bot-message h5,
.bot-message h6 {
    color: #0f172a;
    font-size: 0.92rem;
}

.bot-message a {
    color: var(--primary-2, #1d4ed8);
    font-weight: 650;
    text-underline-offset: 2px;
}

.bot-message code {
    padding: 2px 5px;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.84em;
}

.bot-message pre {
    overflow-x: auto;
    padding: 10px;
    border-radius: 9px;
    background: #0f172a;
    color: #e2e8f0;
}

.bot-message pre code {
    padding: 0;
    background: transparent;
    color: inherit;
}

.chatbot-table-wrapper {
    max-width: 100%;
    margin: 2px 0 10px;
    overflow-x: auto;
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    background: white;
}

.chatbot-table-wrapper table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.8rem;
    line-height: 1.4;
}

.chatbot-table-wrapper th,
.chatbot-table-wrapper td {
    padding: 8px 10px;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
    overflow-wrap: break-word;
    word-break: normal;
}

.chatbot-table-wrapper th {
    background: #eaf0f8;
    color: #0f172a;
    font-weight: 700;
}

.chatbot-table-wrapper th:last-child,
.chatbot-table-wrapper td:last-child {
    border-right: none;
}

.chatbot-table-wrapper tbody tr:last-child td {
    border-bottom: none;
}

.chatbot-table-message {
    width: 100%;
    max-width: 100%;
}

.chatbot-table-wrapper:has(.chatbot-table-stacked) {
    overflow: visible;
    border: none;
    background: transparent;
}

.chatbot-table-stacked,
.chatbot-table-stacked tbody {
    display: block;
}

.chatbot-table-stacked thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.chatbot-table-stacked tbody {
    display: grid;
    gap: 9px;
}

.chatbot-table-stacked tr {
    display: block;
    overflow: hidden;
    border: 1px solid #dbe3ee;
    border-radius: 9px;
    background: white;
}

.chatbot-table-stacked td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) 1fr;
    gap: 10px;
    width: auto;
    padding: 8px 10px;
    border-right: none;
    text-align: left !important;
}

.chatbot-table-stacked td::before {
    content: attr(data-label);
    color: #334155;
    font-weight: 700;
}

.chatbot-table-stacked td:last-child {
    border-bottom: none;
}

.chatbot-error {
    background: #fef2f2;
    color: #991b1b;
}

.chatbot-login-prompt {
    border: 1px solid rgba(37, 99, 235, 0.18);
    background: #eff6ff;
}

.chatbot-login-link {
    display: inline-flex;
    margin-top: 2px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--primary, #2563eb);
    color: white !important;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
}

.chatbot-login-link:hover {
    background: var(--primary-2, #1d4ed8);
}

.chatbot-thinking {
    display: flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    color: #64748b;
}

.chatbot-thinking-label {
    font-size: 0.78rem;
    font-weight: 650;
}

.chatbot-thinking-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: chatbot-dot-pulse 1.2s infinite ease-in-out;
}

.chatbot-thinking-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.chatbot-thinking-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes chatbot-dot-pulse {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.chatbot-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.chatbot-example {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    color: #111827;
    cursor: pointer;
    text-align: left;
    transition: background 160ms ease, border-color 160ms ease;
}

.chatbot-example:hover {
    border-color: rgba(37, 99, 235, 0.28);
    background: rgba(37, 99, 235, 0.06);
}

.chatbot-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chatbot-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 13px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.chatbot-form input:focus {
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 3px var(--ring, rgba(37, 99, 235, 0.18));
}

.chatbot-form button {
    padding: 10px 16px;
    border: none;
    border-radius: 999px;
    background: var(--primary, #2563eb);
    color: white;
    cursor: pointer;
    font-weight: 700;
}

.chatbot-form button:hover {
    background: var(--primary-2, #1d4ed8);
}

.chatbot-form button:disabled,
.chatbot-example:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

@media (max-width: 480px) {
    .chatbot-panel {
        right: 12px;
        bottom: 80px;
        left: 12px;
        width: auto;
        height: min(600px, calc(100vh - 104px));
    }

    .chatbot-toggle {
        right: 16px;
        bottom: 16px;
    }

    .chatbot-nudge {
        right: 16px;
        bottom: 76px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-thinking-dots span {
        animation: none;
        opacity: 0.7;
    }
}
