.chatbot-panel {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 420px;
    height: min(38rem, 80vh);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.25);
    z-index: 1050;
    overflow: hidden;
}

.chatbot-panel--fullscreen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    border-radius: 0;
}

.chatbot-panel__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #212529;
    color: #fff;
}

.chatbot-panel__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.chatbot-panel__title {
    font-weight: 600;
    flex: 1;
}

.chatbot-panel__actions {
    display: flex;
    gap: 0.25rem;
}

.chatbot-panel__actions button {
    background: none;
    border: none;
    color: #fff;
    opacity: 0.8;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.chatbot-panel__actions button:hover {
    opacity: 1;
}

.chatbot-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chatbot-message {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
}

.chatbot-message--user {
    align-self: flex-end;
    background: #0d6efd;
    color: #fff;
}

.chatbot-message--assistant {
    align-self: flex-start;
    background: #f1f3f5;
    color: #212529;
}

.chatbot-message--assistant p {
    margin: 0 0 0.5rem;
}

.chatbot-message--assistant p:last-child {
    margin-bottom: 0;
}

.chatbot-message--assistant h1,
.chatbot-message--assistant h2,
.chatbot-message--assistant h3,
.chatbot-message--assistant h4,
.chatbot-message--assistant h5,
.chatbot-message--assistant h6 {
    margin: 0.75rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.chatbot-message--assistant h1:first-child,
.chatbot-message--assistant h2:first-child,
.chatbot-message--assistant h3:first-child {
    margin-top: 0;
}

.chatbot-message--assistant ul,
.chatbot-message--assistant ol {
    margin: 0 0 0.5rem;
    padding-left: 1.25rem;
}

.chatbot-message--assistant code {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 0.25rem;
    padding: 0.1rem 0.3rem;
    font-size: 0.85em;
}

.chatbot-message--assistant pre {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    margin: 0 0 0.5rem;
}

.chatbot-message--assistant pre code {
    background: none;
    padding: 0;
}

.chatbot-message--assistant a {
    color: #0d6efd;
    text-decoration: underline;
}

.chatbot-message--assistant table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0 0 0.5rem;
    font-size: 0.85em;
    white-space: normal;
}

.chatbot-message--assistant th,
.chatbot-message--assistant td {
    border: 1px solid rgba(0, 0, 0, 0.15);
    padding: 0.35rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.chatbot-message--assistant thead th {
    background: rgba(0, 0, 0, 0.06);
    font-weight: 600;
}

.chatbot-message--assistant tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

.chatbot-panel__form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e9ecef;
}

.chatbot-panel__input {
    flex: 1;
    resize: none;
    border: 1px solid #ced4da;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    max-height: 8rem;
    overflow-y: auto;
}

.chatbot-panel__send {
    background: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0 0.9rem;
}

.chatbot-panel__mic {
    background: #f1f3f5;
    color: #212529;
    border: none;
    border-radius: 0.5rem;
    padding: 0 0.9rem;
}

.chatbot-panel__mic--recording {
    background: #dc3545;
    color: #fff;
    animation: chatbot-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes chatbot-mic-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.chatbot-message--pending {
    opacity: 0.6;
    font-style: italic;
}

.chatbot-message--typing {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.65rem 0.9rem;
}

.chatbot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #868e96;
    opacity: 0.4;
    animation: chatbot-typing-bounce 1s infinite;
}

.chatbot-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.chatbot-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chatbot-typing-bounce {
    0%, 80%, 100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 576px) {
    .chatbot-panel {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: auto;
        height: auto;
        border-radius: 0;
    }
}
