/* CDIJUM Chatbot Widget */

/* Override Loquet theme global button styles (gt-style.css).
   Theme targets bare `button` — we use #id for higher specificity. */
#cdijum-chatbot button {
    font-size: inherit;
    font-weight: inherit;
    text-transform: none;
    letter-spacing: normal;
    min-height: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    border: none;
}
#cdijum-chatbot button:hover {
    background: transparent;
    color: inherit;
}

.cdijum-chatbot {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10001;
    font-family: inherit;
}

/* Toggle Button */
#cdijum-chatbot .cdijum-chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgb(17, 17, 17);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    position: relative;
}

#cdijum-chatbot .cdijum-chatbot-toggle:hover {
    background: rgb(173, 154, 109);
    color: #fff;
    transform: scale(1.08);
}

#cdijum-chatbot .cdijum-chatbot-toggle:focus-visible {
    outline: 2px solid rgb(173, 154, 109);
    outline-offset: 2px;
}

/* Make SVG icons larger so they're visible inside the circle */
#cdijum-chatbot .cdijum-chatbot-toggle svg {
    width: 28px;
    height: 28px;
}

.cdijum-chatbot-icon-close {
    display: none;
}

.cdijum-chatbot.is-open .cdijum-chatbot-icon-chat {
    display: none;
}

.cdijum-chatbot.is-open .cdijum-chatbot-icon-close {
    display: block;
}

/* Chat Window */
.cdijum-chatbot-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.cdijum-chatbot.is-open .cdijum-chatbot-window {
    display: flex;
}

/* Header */
.cdijum-chatbot-header {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    background: rgb(17, 17, 17);
    color: #fff;
    flex-shrink: 0;
    gap: 0.5rem;
}

.cdijum-chatbot-header-title {
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: 0.01em;
    flex: 1;
}

#cdijum-chatbot .cdijum-chatbot-new-chat {
    background: transparent;
    color: #fff;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

#cdijum-chatbot .cdijum-chatbot-new-chat:hover {
    background: transparent;
    color: #fff;
    opacity: 1;
}

#cdijum-chatbot .cdijum-chatbot-new-chat:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

#cdijum-chatbot .cdijum-chatbot-close {
    background: transparent;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
    min-height: 0;
}

#cdijum-chatbot .cdijum-chatbot-close:hover {
    background: transparent;
    color: #fff;
    opacity: 1;
}

#cdijum-chatbot .cdijum-chatbot-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

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

.cdijum-chatbot-message {
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-wrap: break-word;
    animation: cdijum-chat-fade-in 0.2s ease;
}

/* Suppress animations during session restore */
.cdijum-chatbot--restoring .cdijum-chatbot-message {
    animation: none;
}

@keyframes cdijum-chat-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cdijum-chatbot-message--user {
    align-self: flex-end;
    background: rgb(17, 17, 17);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cdijum-chatbot-message--assistant {
    align-self: flex-start;
    background: #f0f0f0;
    color: rgb(17, 17, 17);
    border-bottom-left-radius: 4px;
    position: relative;
}

/* Copy button on assistant messages */
#cdijum-chatbot .cdijum-chatbot-copy {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    background: transparent;
    color: #999;
    min-height: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

#cdijum-chatbot .cdijum-chatbot-copy:hover {
    background: transparent;
    color: #555;
}

.cdijum-chatbot-message--assistant:hover .cdijum-chatbot-copy {
    opacity: 1;
}

#cdijum-chatbot .cdijum-chatbot-copy:focus-visible {
    opacity: 1;
    outline: 2px solid rgb(173, 154, 109);
    outline-offset: 1px;
}

.cdijum-chatbot-message--assistant a {
    color: rgb(100, 88, 58);
    text-decoration: underline;
}

.cdijum-chatbot-message--assistant a:hover {
    color: rgb(70, 60, 40);
}

/* Error messages */
.cdijum-chatbot-message--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Lists in assistant messages */
.cdijum-chatbot-message--assistant ul,
.cdijum-chatbot-message--assistant ol {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}

.cdijum-chatbot-message--assistant li {
    margin-bottom: 0.125rem;
}

/* Tables in assistant messages */
.cdijum-chatbot-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.375rem 0;
    font-size: 0.8125rem;
}

.cdijum-chatbot-table th,
.cdijum-chatbot-table td {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.cdijum-chatbot-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: rgb(100, 100, 100);
}

/* Headers in assistant messages */
.cdijum-chatbot-message--assistant h4,
.cdijum-chatbot-message--assistant h5,
.cdijum-chatbot-message--assistant h6 {
    margin: 0.5rem 0 0.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.cdijum-chatbot-message--assistant h4 { font-size: 0.9375rem; }
.cdijum-chatbot-message--assistant h5 { font-size: 0.875rem; }
.cdijum-chatbot-message--assistant h6 { font-size: 0.8125rem; }

.cdijum-chatbot-message--assistant hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 0.5rem 0;
}

/* Suggested Starter Prompts (uses <span> to avoid theme button styles) */
.cdijum-chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.25rem 0;
}

.cdijum-chatbot-suggestion {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 999px;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-family: inherit;
    color: rgb(17, 17, 17);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    line-height: 1.4;
}

.cdijum-chatbot-suggestion:hover {
    border-color: rgb(173, 154, 109);
    background: rgba(173, 154, 109, 0.08);
}

.cdijum-chatbot-suggestion:focus-visible {
    outline: 2px solid rgb(173, 154, 109);
    outline-offset: 1px;
}

/* Typing Indicator */
.cdijum-chatbot-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    background: #f0f0f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.cdijum-chatbot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgb(150, 150, 150);
    animation: cdijum-typing-bounce 1.2s ease-in-out infinite;
}

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

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

@keyframes cdijum-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Form */
.cdijum-chatbot-form {
    display: flex;
    padding: 0.75rem;
    border-top: 1px solid #e6e6e6;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cdijum-chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.cdijum-chatbot-input:focus {
    border-color: rgb(173, 154, 109);
    outline: 2px solid rgb(173, 154, 109);
    outline-offset: 1px;
}

#cdijum-chatbot .cdijum-chatbot-send {
    width: 44px;
    height: 44px;
    min-height: 0;
    border-radius: 8px;
    background: transparent;
    color: rgb(17, 17, 17);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

#cdijum-chatbot .cdijum-chatbot-send:hover {
    background: transparent;
    color: rgb(173, 154, 109);
}

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

#cdijum-chatbot .cdijum-chatbot-send:focus-visible {
    outline: 2px solid rgb(173, 154, 109);
    outline-offset: 2px;
}

/* Markdown-like formatting in messages */
.cdijum-chatbot-message--assistant strong {
    font-weight: 600;
}

.cdijum-chatbot-message--assistant em {
    font-style: italic;
}

/* Mobile */
@media (max-width: 480px) {
    .cdijum-chatbot {
        bottom: 1rem;
        right: 1rem;
    }

    .cdijum-chatbot-window {
        width: calc(100vw - 2rem);
        max-height: calc(100dvh - 8rem);
        bottom: 64px;
        right: 0;
    }

    .cdijum-chatbot-messages {
        max-height: calc(100dvh - 16rem);
    }
}
