/* ===== Chatbot Widget ===== */
/* Note: Uses outline/box-shadow instead of border on divs because of the global
   "div { border: initial !important; }" reset in this stylesheet. */

.chatbot-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.chatbot-buttons {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

/* -- Panel -- */
.chatbot-panel {
    width: 380px;
    max-height: 500px;
    margin-bottom: 0;
    background: #111827;
    outline: 1px solid #374151;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatbot-slide-up 0.2s ease-out;
}

@keyframes chatbot-slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -- Header -- */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #1f2937;
    box-shadow: inset 0 -1px 0 #374151;
}

.chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
}

.chatbot-close-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 0;
    transition: color 0.2s;
}

.chatbot-close-btn:hover {
    color: #fff;
}

/* -- Messages area -- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 200px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

.chatbot-welcome {
    color: #9ca3af;
    font-size: 0.875rem;
    text-align: center;
    margin-top: 1rem;
}

.chatbot-welcome p + p {
    margin-top: 0.5rem;
}

/* -- Message rows -- */
.chatbot-msg-row {
    display: flex;
}

.chatbot-msg-row-end {
    justify-content: flex-end;
}

.chatbot-msg-row-start {
    justify-content: flex-start;
}

.chatbot-msg {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.625;
    word-wrap: break-word;
}

.chatbot-msg-user {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.chatbot-msg-assistant {
    background: #1f2937;
    color: #e5e7eb;
    outline: 1px solid #374151;
    border-bottom-left-radius: 0.25rem;
}

.chatbot-msg a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.chatbot-msg a:hover {
    color: #93bbfd;
}

/* -- Typing indicator -- */
.chatbot-typing {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem 0;
}

.chatbot-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: #9ca3af;
    border-radius: 50%;
    animation: chatbot-bounce 1.4s infinite ease-in-out both;
}

@keyframes chatbot-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* -- Input area -- */
.chatbot-input-area {
    box-shadow: inset 0 1px 0 #374151;
    padding: 0.75rem;
    background: #1f2937;
}

.chatbot-input-form {
    display: flex;
    gap: 0.5rem;
}

.chatbot-input {
    flex: 1;
    background: #111827;
    color: #fff;
    font-size: 0.875rem;
    outline: 1px solid #4b5563;
    outline-offset: -1px;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: outline-color 0.2s;
}

.chatbot-input:focus {
    outline-color: #3b82f6;
}

.chatbot-input::placeholder {
    color: #6b7280;
}

.chatbot-input:disabled {
    opacity: 0.5;
}

.chatbot-send-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    line-height: 0;
    transition: background 0.2s;
}

.chatbot-send-btn:hover {
    background: #1d4ed8;
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* -- Floating bubble -- */
.chatbot-bubble {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: none;
    background: linear-gradient(to right, #4ade80, #3b82f6);
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.3s, transform 0.3s;
}

.chatbot-bubble:hover {
    background: linear-gradient(to right, #22c55e, #2563eb);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

.chatbot-bubble-pulse {
    animation: chatbot-pulse 2s ease-in-out 3;
}

@keyframes chatbot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
    50%      { box-shadow: 0 0 0 12px rgba(74, 222, 128, 0); }
}

/* -- Icon sizes -- */
.chatbot-icon-xs {
    width: 1rem;
    height: 1rem;
}

.chatbot-icon-sm {
    width: 1.25rem;
    height: 1.25rem;
}

.chatbot-icon-green {
    color: #4ade80;
}

.chatbot-icon-md {
    width: 1.5rem;
    height: 1.5rem;
}

/* -- Scroll to top button -- */
.chatbot-scroll-top {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    background: #1f2937;
    color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, background 0.2s, color 0.2s, transform 0.2s;
}

.chatbot-scroll-top-visible {
    opacity: 1;
    pointer-events: auto;
}

.chatbot-scroll-top:hover {
    background: #374151;
    color: #fff;
    transform: scale(1.05);
}

/* -- Rate limit notice -- */\n.chatbot-rate-limit {\n    padding: 0.375rem 0.75rem;\n    margin-bottom: 0.5rem;\n    font-size: 0.8125rem;\n    color: #fbbf24;\n    background: rgba(251, 191, 36, 0.1);\n    border-radius: 0.375rem;\n    text-align: center;\n}\n\n/* -- Mobile responsive -- */
@media (max-width: 480px) {
    .chatbot-panel {
        width: calc(100vw - 2rem);
        max-height: 70vh;
    }

    .chatbot-container {
        bottom: 1rem;
        right: 1rem;
    }
}
