/**
 * WHOI Ocean Learning Hub - RAG Chatbot Widget
 * Floating chat widget styles
 */

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes whoi-chatbot-pulse {
    0% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
    50% { box-shadow: 0 4px 20px rgba(0, 169, 224, 0.4); }
    100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
}

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

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

/* ==========================================================================
   Toggle Button
   ========================================================================== */

#whoi-chatbot-toggle,
.whoi-chatbot-toggle {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    top: auto !important;
    left: auto !important;
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    border-radius: 50% !important;
    background: #00A9E0 !important;
    border: none !important;
    color: #ffffff !important;
    cursor: pointer;
    z-index: 99999 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    float: none !important;
    animation: whoi-chatbot-pulse 2s ease-in-out 1;
    line-height: 1 !important;
    text-indent: 0 !important;
    text-align: center !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-size: 0 !important;
    outline: none;
}

#whoi-chatbot-toggle.whoi-chatbot-toggle--hidden,
.whoi-chatbot-toggle.whoi-chatbot-toggle--hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0) !important;
}

#whoi-chatbot-toggle:hover,
.whoi-chatbot-toggle:hover {
    background: #0090c0 !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#whoi-chatbot-toggle svg,
.whoi-chatbot-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* ==========================================================================
   Container
   ========================================================================== */

.whoi-chatbot-container {
    position: fixed !important;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 99998 !important;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #dcdcde;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.whoi-chatbot-container.whoi-chatbot-container--open {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

/* ==========================================================================
   Header
   ========================================================================== */

.whoi-chatbot-header {
    background: #00A9E0;
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.whoi-chatbot-header-info {
    display: flex;
    flex-direction: column;
}

.whoi-chatbot-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.whoi-chatbot-subtitle {
    font-size: 11px;
    opacity: 0.8;
    display: block;
    line-height: 1.3;
}

.whoi-chatbot-header-actions {
    display: flex;
    gap: 4px;
}

.whoi-chatbot-header-actions button {
    background: transparent;
    border: none;
    color: #ffffff;
    opacity: 0.8;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.whoi-chatbot-header-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.whoi-chatbot-header-actions button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ==========================================================================
   Messages Area
   ========================================================================== */

.whoi-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Webkit scrollbar */
.whoi-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.whoi-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* ==========================================================================
   Messages
   ========================================================================== */

.whoi-chatbot-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

.whoi-chatbot-message--bot {
    align-self: flex-start;
}

.whoi-chatbot-message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.whoi-chatbot-message--error .whoi-chatbot-bubble {
    border-left: 3px solid #d63638;
}

/* ==========================================================================
   Avatar
   ========================================================================== */

.whoi-chatbot-avatar {
    width: 28px;
    height: 28px;
    font-size: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Bubbles
   ========================================================================== */

.whoi-chatbot-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.whoi-chatbot-message--bot .whoi-chatbot-bubble {
    background: #f0f4f8;
    color: #1d2327;
    border-radius: 12px 12px 12px 4px;
}

.whoi-chatbot-message--user .whoi-chatbot-bubble {
    background: #00A9E0;
    color: #ffffff;
    border-radius: 12px 12px 4px 12px;
}

.whoi-chatbot-message-content {
    word-wrap: break-word;
}

/* ==========================================================================
   Markdown in Messages
   ========================================================================== */

.whoi-chatbot-message-content strong {
    font-weight: 600;
}

.whoi-chatbot-message-content em {
    font-style: italic;
}

.whoi-chatbot-message-content p {
    margin: 0 0 8px 0;
}

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

/* ==========================================================================
   Citations & Sources
   ========================================================================== */

.whoi-chatbot-citation {
    color: #0077b6;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.whoi-chatbot-citation:hover {
    text-decoration: underline;
}

.whoi-chatbot-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.whoi-chatbot-source {
    font-size: 12px;
    color: #0077b6;
    text-decoration: none;
    display: block;
    padding: 4px 8px;
    background: rgba(0, 119, 182, 0.06);
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.whoi-chatbot-source:hover {
    background: rgba(0, 119, 182, 0.12);
}

/* ==========================================================================
   Conversation Starters
   ========================================================================== */

.whoi-chatbot-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 4px 36px;
}

.whoi-chatbot-starter {
    background: #ffffff;
    border: 1px solid #00A9E0;
    color: #00A9E0;
    border-radius: 18px;
    padding: 7px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1.3;
    white-space: nowrap;
}

.whoi-chatbot-starter:hover {
    background: #00A9E0;
    color: #ffffff;
}

.whoi-chatbot-starter:focus {
    outline: 2px solid #00A9E0;
    outline-offset: 2px;
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.whoi-chatbot-typing {
    display: flex;
    gap: 8px;
    align-self: flex-start;
}

.whoi-chatbot-typing .whoi-chatbot-bubble {
    background: #f0f4f8;
    border-radius: 12px 12px 12px 4px;
    display: flex;
    align-items: center;
    padding: 10px 14px;
}

.whoi-chatbot-dot {
    width: 8px;
    height: 8px;
    background: #a0aec0;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: whoi-chatbot-bounce 1.2s ease-in-out infinite;
}

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

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

/* ==========================================================================
   Input Area
   ========================================================================== */

.whoi-chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid #dcdcde;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

/* ==========================================================================
   Textarea Input
   ========================================================================== */

.whoi-chatbot-input {
    flex: 1;
    border: 1px solid #dcdcde;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 38px;
    outline: none;
    line-height: 1.4;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    background: #ffffff;
    color: #1d2327;
}

.whoi-chatbot-input:focus {
    border-color: #0077b6;
}

.whoi-chatbot-input::placeholder {
    color: #646970;
}

/* ==========================================================================
   Send Button
   ========================================================================== */

.whoi-chatbot-send {
    width: 36px;
    height: 36px;
    background: #00A9E0;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.whoi-chatbot-send:hover:not(:disabled) {
    background: #0090c0;
}

.whoi-chatbot-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.whoi-chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ==========================================================================
   Responsive (Mobile)
   ========================================================================== */

@media (max-width: 480px) {
    .whoi-chatbot-container {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
    }

    .whoi-chatbot-header {
        border-radius: 0;
    }

    .whoi-chatbot-input-area {
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .whoi-chatbot-toggle,
    .whoi-chatbot-container,
    .whoi-chatbot-dot {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    .whoi-chatbot-toggle,
    .whoi-chatbot-container {
        display: none !important;
    }
}
