/* ============================================================
   chatbot.css — "Ask the Act" Floating Chat Widget
   CahillNXT Design System
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --cb-navy: #002857;
    --cb-navy-light: #003d7a;
    --cb-orange: #e04403;
    --cb-orange-hover: #c73a00;
    --cb-bg: #ffffff;
    --cb-bg-alt: #f8f7f5;
    --cb-border: #e0dcd8;
    --cb-text: #4d423d;
    --cb-text-muted: rgba(0, 40, 87, 0.55);
    --cb-radius: 12px;
    --cb-shadow: 0 12px 48px rgba(0, 40, 87, 0.18), 0 0 0 1px rgba(0, 40, 87, 0.06);
    --cb-font: 'Lato', Arial, Helvetica, sans-serif;
    --cb-z: 500;
}

/* ---- Floating Bubble ---- */
.chatbot-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cb-orange);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(224, 68, 3, 0.35), 0 0 0 0 rgba(224, 68, 3, 0);
    z-index: var(--cb-z);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.2s ease;
}

.chatbot-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(224, 68, 3, 0.45), 0 0 0 4px rgba(224, 68, 3, 0.1);
    background: var(--cb-orange-hover);
}

.chatbot-bubble:active {
    transform: scale(0.96);
}

.chatbot-bubble svg {
    width: 26px;
    height: 26px;
    fill: #ffffff;
    transition: transform 0.2s ease;
}

.chatbot-bubble.open svg.icon-chat { display: none; }
.chatbot-bubble:not(.open) svg.icon-close { display: none; }
.chatbot-bubble.open svg.icon-close { display: block; }

/* Pulse animation on first load */
@keyframes chatbot-pulse {
    0%   { box-shadow: 0 4px 20px rgba(224, 68, 3, 0.35), 0 0 0 0 rgba(224, 68, 3, 0.25); }
    70%  { box-shadow: 0 4px 20px rgba(224, 68, 3, 0.35), 0 0 0 12px rgba(224, 68, 3, 0); }
    100% { box-shadow: 0 4px 20px rgba(224, 68, 3, 0.35), 0 0 0 0 rgba(224, 68, 3, 0); }
}

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


/* ---- Chat Panel ---- */
.chatbot-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 400px;
    height: 540px;
    background: var(--cb-bg);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    z-index: var(--cb-z);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.2s ease;
}

.chatbot-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}


/* ---- Panel Header ---- */
.chatbot-header {
    padding: 16px 18px;
    background: var(--cb-navy);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chatbot-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-icon svg {
    width: 18px;
    height: 18px;
    fill: var(--cb-orange);
}

.chatbot-header-text {
    flex: 1;
}

.chatbot-header-title {
    font-family: var(--cb-font);
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.chatbot-header-sub {
    font-family: var(--cb-font);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 1px;
}


/* ---- Messages Area ---- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 40, 87, 0.15) transparent;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 40, 87, 0.15);
    border-radius: 3px;
}


/* ---- Message Bubbles ---- */
.chatbot-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 10px;
    font-family: var(--cb-font);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--cb-text);
    animation: chatbot-msg-in 0.25s ease-out both;
}

@keyframes chatbot-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chatbot-msg.user {
    align-self: flex-end;
    background: var(--cb-navy);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}

.chatbot-msg.assistant {
    align-self: flex-start;
    background: var(--cb-bg-alt);
    border: 1px solid var(--cb-border);
    border-bottom-left-radius: 3px;
}


/* ---- Reference Chips ---- */
.chatbot-refs {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chatbot-ref {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 6px;
    background: rgba(224, 68, 3, 0.08);
    border: 1px solid rgba(224, 68, 3, 0.2);
    color: var(--cb-orange);
    font-family: var(--cb-font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.chatbot-ref:hover {
    background: rgba(224, 68, 3, 0.14);
    box-shadow: 0 0 12px rgba(224, 68, 3, 0.15);
}

.chatbot-ref svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
    flex-shrink: 0;
}

.chatbot-ref-path {
    font-size: 11px;
    color: var(--cb-text-muted);
    font-weight: 400;
    margin-left: 4px;
}


/* ---- Typing Indicator ---- */
.chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: var(--cb-bg-alt);
    border: 1px solid var(--cb-border);
    border-radius: 10px;
    border-bottom-left-radius: 3px;
}

.chatbot-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(0, 40, 87, 0.3);
    animation: chatbot-bounce 1.4s ease-in-out infinite;
}

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

@keyframes chatbot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}


/* ---- Input Area ---- */
.chatbot-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--cb-border);
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--cb-bg);
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: var(--cb-font);
    font-size: 13.5px;
    color: var(--cb-text);
    background: var(--cb-bg-alt);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    resize: none;
    max-height: 72px;
    line-height: 1.4;
}

.chatbot-input:focus {
    border-color: var(--cb-orange);
    box-shadow: 0 0 0 3px rgba(224, 68, 3, 0.08);
}

.chatbot-input::placeholder {
    color: rgba(0, 40, 87, 0.35);
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: var(--cb-orange);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: var(--cb-orange-hover);
}

.chatbot-send:active {
    transform: scale(0.92);
}

.chatbot-send:disabled {
    background: rgba(0, 40, 87, 0.15);
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}


/* ---- Error/Info Messages ---- */
.chatbot-error {
    align-self: center;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(224, 68, 3, 0.08);
    border: 1px solid rgba(224, 68, 3, 0.2);
    font-family: var(--cb-font);
    font-size: 12px;
    color: var(--cb-orange);
    text-align: center;
}

.chatbot-error button {
    background: none;
    border: none;
    color: var(--cb-orange);
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    font-family: var(--cb-font);
    font-size: 12px;
}


/* ---- Responsive ---- */
@media (max-width: 768px) {
    .chatbot-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 140px);
        right: 12px;
        bottom: 80px;
        border-radius: 10px;
    }

    .chatbot-bubble {
        bottom: 18px;
        right: 18px;
        width: 50px;
        height: 50px;
    }

    .chatbot-bubble svg {
        width: 22px;
        height: 22px;
    }
}

/* ---- Footer spacing ---- */
.site-footer ~ .chatbot-bubble {
    /* Adjust if footer is present */
}
