/* Custom CloudPOS Chatbot UI following ui-ux-pro-max guidelines */

/* Container and Toggle Button */
.chatbot-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: var(--font-main, 'Nunito Sans', sans-serif);
}

.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--color-primary, #07354C);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(7, 53, 76, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: transform 0.3s ease, background-color 0.2s;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.05);
    background-color: var(--color-secondary, #2C576A);
}

/* Chat Window Modal */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background-color: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chatbot-window.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(20px);
}

/* Header */
.chatbot-header {
    background-color: var(--color-primary, #07354C);
    color: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.chatbot-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.chatbot-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.chatbot-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.chatbot-btn:hover {
    opacity: 1;
}

/* Messages Area */
.chatbot-messages {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #F8FAFC;
    scroll-behavior: smooth;
}

/* Scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 4px;
}

/* Bubbles */
.bot-message,
.user-message {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message {
    align-self: flex-start;
    background-color: #FFFFFF;
    color: #1E293B;
    border: 1px solid #E2E8F0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.user-message {
    align-self: flex-end;
    background-color: var(--color-primary, #07354C);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(7, 53, 76, 0.15);
}

/* Markdown formatting inside bubbles */
.bot-message strong {
    font-weight: 700;
    color: #0F172A;
}

.bot-message li {
    margin-left: 1rem;
    list-style-type: disc;
    margin-bottom: 0.25rem;
}

.bot-message.bot-error {
    background-color: #FEF2F2;
    color: #991B1B;
    border-color: #FECACA;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 1rem;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: #94A3B8;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.chatbot-input-area {
    padding: 1rem;
    background-color: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#chatbot-input {
    flex-grow: 1;
    border: 1px solid #CBD5E1;
    background-color: #F8FAFC;
    border-radius: 24px;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    color: #0F172A;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

#chatbot-input:focus {
    border-color: var(--color-primary, #07354C);
    background-color: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(7, 53, 76, 0.1);
}

#chatbot-input::placeholder {
    color: #94A3B8;
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--color-primary, #07354C);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    background-color: var(--color-secondary, #2C576A);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

/* Responsive constraints */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 40px);
        right: -10px;
        bottom: 70px;
        height: calc(100vh - 140px);
    }
}

/* --- Dark Mode Overrides --- */
.chatbot-container.chatbot-dark-mode {
    --color-primary: #06B6D4;
    /* Cyan accent from ui-ux-pro-max saas dark theme */
    --color-secondary: #0891B2;
}

.chatbot-container.chatbot-dark-mode .chatbot-window {
    background-color: #111827;
    /* Gray-900 */
    border-color: rgba(255, 255, 255, 0.1);
}

.chatbot-container.chatbot-dark-mode .chatbot-header {
    background-color: #1F2937;
    /* Gray-800 */
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.chatbot-container.chatbot-dark-mode .chatbot-messages {
    background-color: #111827;
}

.chatbot-container.chatbot-dark-mode .bot-message {
    background-color: #1F2937;
    color: #F9FAFB;
    border-color: rgba(255, 255, 255, 0.1);
}

.chatbot-container.chatbot-dark-mode .bot-message strong {
    color: #FFFFFF;
}

.chatbot-container.chatbot-dark-mode .user-message {
    background-color: var(--color-primary);
    color: #111827;
}

.chatbot-container.chatbot-dark-mode .chatbot-input-area {
    background-color: #1F2937;
    border-top-color: rgba(255, 255, 255, 0.05);
}

.chatbot-container.chatbot-dark-mode #chatbot-input {
    background-color: #374151;
    /* Gray-700 */
    border-color: rgba(255, 255, 255, 0.1);
    color: #F9FAFB;
}

.chatbot-container.chatbot-dark-mode #chatbot-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

.chatbot-container.chatbot-dark-mode #chatbot-input::placeholder {
    color: #9CA3AF;
}

.chatbot-container.chatbot-dark-mode .chatbot-send-btn {
    color: #111827;
}

.chatbot-container.chatbot-dark-mode .chatbot-toggle-btn {
    background-color: #1F2937;
    color: #F9FAFB;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-container.chatbot-dark-mode .chatbot-toggle-btn:hover {
    background-color: #374151;
}