/* Copyright 2026 Nexa Systems Inc. */
/* License OPL-1 (Odoo Proprietary License v1.0) */
/* Portal AI Chat Widget Styles */

/* ================================================================
   Container
   ================================================================ */
.fclk-ai-portal-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ================================================================
   Floating Bubble
   ================================================================ */
.fclk-ai-portal-bubble {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.fclk-ai-portal-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5), 0 3px 10px rgba(0, 0, 0, 0.2);
}

.fclk-ai-portal-bubble:active {
    transform: scale(0.95);
}

.fclk-ai-portal-bubble--open {
    background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
}

/* ================================================================
   Chat Panel
   ================================================================ */
.fclk-ai-portal-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 360px;
    max-height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.fclk-ai-portal-panel.fclk-ai-pp--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ================================================================
   Panel Header
   ================================================================ */
.fclk-ai-pp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    flex-shrink: 0;
}

.fclk-ai-pp-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fclk-ai-pp-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fclk-ai-pp-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
}

.fclk-ai-pp-subtitle {
    font-size: 11px;
    opacity: 0.85;
    line-height: 1.2;
    margin-top: 1px;
}

.fclk-ai-pp-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.fclk-ai-pp-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ================================================================
   Messages Area
   ================================================================ */
.fclk-ai-pp-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 180px;
    max-height: 280px;
    scroll-behavior: smooth;
}

.fclk-ai-pp-msgs::-webkit-scrollbar {
    width: 4px;
}

.fclk-ai-pp-msgs::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}

.fclk-ai-portal-msg {
    display: flex;
    max-width: 85%;
    animation: fclk-ai-msg-in 0.2s ease-out;
}

.fclk-ai-portal-msg--user {
    align-self: flex-end;
}

.fclk-ai-portal-msg--assistant {
    align-self: flex-start;
}

.fclk-ai-portal-msg-text {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.fclk-ai-portal-msg--user .fclk-ai-portal-msg-text {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.fclk-ai-portal-msg--assistant .fclk-ai-portal-msg-text {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

@keyframes fclk-ai-msg-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================================
   Typing Indicator
   ================================================================ */
.fclk-ai-portal-typing .fclk-ai-portal-dots {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    background: #f3f4f6;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.fclk-ai-portal-dots span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: fclk-ai-dot-bounce 1.2s infinite ease-in-out;
}

.fclk-ai-portal-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.fclk-ai-portal-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes fclk-ai-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* ================================================================
   Quick Actions
   ================================================================ */
.fclk-ai-pp-quick {
    display: flex;
    gap: 6px;
    padding: 8px 14px;
    flex-wrap: wrap;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.fclk-ai-pp-qbtn {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 11.5px;
    color: #7c3aed;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fclk-ai-pp-qbtn:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
    transform: translateY(-1px);
}

.fclk-ai-pp-qbtn:active {
    transform: translateY(0);
}

.fclk-ai-pp-qbtn .fa {
    font-size: 11px;
}

/* ================================================================
   Input Row
   ================================================================ */
.fclk-ai-pp-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 14px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.fclk-ai-pp-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #fafafa;
    color: #1f2937;
}

.fclk-ai-pp-input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
    background: #fff;
}

.fclk-ai-pp-input::placeholder {
    color: #9ca3af;
}

.fclk-ai-pp-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.fclk-ai-pp-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fclk-ai-pp-send:not(:disabled):hover {
    transform: scale(1.06);
}

.fclk-ai-pp-send:not(:disabled):active {
    transform: scale(0.95);
}

/* ================================================================
   Polish Overlay
   ================================================================ */
.fclk-ai-pp-polish-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.97);
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    gap: 14px;
    z-index: 5;
    border-radius: 16px;
}

.fclk-ai-pp-polish-title {
    font-weight: 600;
    font-size: 15px;
    color: #7c3aed;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fclk-ai-pp-polish-title .fa {
    font-size: 16px;
}

.fclk-ai-pp-polish-input {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    resize: none;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    color: #1f2937;
}

.fclk-ai-pp-polish-input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.fclk-ai-pp-polish-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.fclk-ai-pp-polish-cancel {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.fclk-ai-pp-polish-cancel:hover {
    background: #f3f4f6;
}

.fclk-ai-pp-polish-send {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.fclk-ai-pp-polish-send:hover {
    opacity: 0.9;
}

.fclk-ai-pp-polish-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ================================================================
   Dark Theme Support (Odoo portal dark mode)
   ================================================================ */
html[data-color-scheme="dark"] .fclk-ai-portal-panel,
.o_dark .fclk-ai-portal-panel {
    background: #1e1e2e;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
}

html[data-color-scheme="dark"] .fclk-ai-portal-msg--assistant .fclk-ai-portal-msg-text,
.o_dark .fclk-ai-portal-msg--assistant .fclk-ai-portal-msg-text {
    background: #2a2a3e;
    color: #e5e7eb;
}

html[data-color-scheme="dark"] .fclk-ai-portal-typing .fclk-ai-portal-dots,
.o_dark .fclk-ai-portal-typing .fclk-ai-portal-dots {
    background: #2a2a3e;
}

html[data-color-scheme="dark"] .fclk-ai-portal-dots span,
.o_dark .fclk-ai-portal-dots span {
    background: #6b7280;
}

html[data-color-scheme="dark"] .fclk-ai-pp-quick,
.o_dark .fclk-ai-pp-quick {
    border-top-color: #333;
}

html[data-color-scheme="dark"] .fclk-ai-pp-qbtn,
.o_dark .fclk-ai-pp-qbtn {
    background: #2a2a3e;
    border-color: #444;
    color: #c4b5fd;
}

html[data-color-scheme="dark"] .fclk-ai-pp-qbtn:hover,
.o_dark .fclk-ai-pp-qbtn:hover {
    background: #333;
    border-color: #7c3aed;
}

html[data-color-scheme="dark"] .fclk-ai-pp-input-row,
.o_dark .fclk-ai-pp-input-row {
    border-top-color: #333;
}

html[data-color-scheme="dark"] .fclk-ai-pp-input,
.o_dark .fclk-ai-pp-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e5e7eb;
}

html[data-color-scheme="dark"] .fclk-ai-pp-input:focus,
.o_dark .fclk-ai-pp-input:focus {
    background: #1e1e2e;
    border-color: #7c3aed;
}

html[data-color-scheme="dark"] .fclk-ai-pp-input::placeholder,
.o_dark .fclk-ai-pp-input::placeholder {
    color: #6b7280;
}

html[data-color-scheme="dark"] .fclk-ai-pp-polish-overlay,
.o_dark .fclk-ai-pp-polish-overlay {
    background: rgba(30, 30, 46, 0.97);
}

html[data-color-scheme="dark"] .fclk-ai-pp-polish-input,
.o_dark .fclk-ai-pp-polish-input {
    background: #2a2a3e;
    border-color: #444;
    color: #e5e7eb;
}

html[data-color-scheme="dark"] .fclk-ai-pp-polish-cancel,
.o_dark .fclk-ai-pp-polish-cancel {
    background: #2a2a3e;
    border-color: #444;
    color: #9ca3af;
}

html[data-color-scheme="dark"] .fclk-ai-pp-polish-cancel:hover,
.o_dark .fclk-ai-pp-polish-cancel:hover {
    background: #333;
}

/* ================================================================
   Responsive: Full-width below 480px
   ================================================================ */
@media (max-width: 480px) {
    .fclk-ai-portal-chat {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }

    .fclk-ai-portal-bubble {
        position: fixed;
        bottom: 16px;
        right: 16px;
    }

    .fclk-ai-portal-panel {
        position: fixed;
        bottom: 80px;
        right: 16px;
        left: 16px;
        width: auto;
        max-height: calc(100dvh - 120px);
    }

    .fclk-ai-pp-msgs {
        max-height: none;
        flex: 1;
    }
}
