// Copyright 2026 Nexa Systems Inc.
// License OPL-1 (Odoo Proprietary License v1.0)
//
// Fusion Clock AI - Systray + Manager Chat styles
// All colors use Odoo/Bootstrap CSS variables for dark mode support

// AI brand color tokens (adapt to dark mode)
:root {
    --fclk-ai-brand: #764ba2;
    --fclk-ai-brand-light: #8b5fbf;
    --fclk-ai-brand-bg: rgba(118, 75, 162, 0.08);
}

html.o_dark {
    --fclk-ai-brand: #a87fd4;
    --fclk-ai-brand-light: #c4a6e6;
    --fclk-ai-brand-bg: rgba(168, 127, 212, 0.12);
}

// Systray icon
.fclk-ai-systray-btn {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.fclk-ai-systray-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    transition: transform 0.2s;

    .fclk-ai-systray-btn:hover & {
        transform: scale(1.15);
    }
}

// Dropdown container
.fclk-ai-systray-dropdown {
    width: 380px;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
}

html.o_dark .fclk-ai-systray-dropdown {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
}

// Panel inside dropdown
.fclk-ai-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 520px;
    background: var(--o-view-background-color, var(--bs-body-bg, #fff));
}

.fclk-ai-panel-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--o-border-color, var(--bs-border-color, #dee2e6));
    gap: 8px;
    flex-shrink: 0;
}

.fclk-ai-panel-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--o-main-text-color, var(--bs-body-color, #212529));
    white-space: nowrap;
}

.fclk-ai-tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.fclk-ai-tab {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--o-border-color, var(--bs-border-color, #dee2e6));
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    color: var(--o-main-text-color, var(--bs-body-color, #212529));
    transition: background 0.15s;

    &.active {
        background: var(--fclk-ai-brand);
        color: #fff;
        border-color: transparent;
    }
}

.fclk-ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 300px;
    max-height: 380px;
}

.fclk-ai-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--o-main-text-color, var(--bs-body-color, #212529));
    opacity: 0.6;
    text-align: center;
    padding: 24px;
}

.fclk-ai-empty-icon {
    font-size: 40px;
    opacity: 0.3;
}

.fclk-ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.fclk-ai-suggestion {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--o-border-color, var(--bs-border-color, #dee2e6));
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    color: var(--o-main-text-color, var(--bs-body-color, #212529));
    transition: background 0.15s, border-color 0.15s;

    &:hover {
        background: var(--fclk-ai-brand);
        color: #fff;
        border-color: transparent;
    }
}

.fclk-ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;

    &--user {
        flex-direction: row-reverse;

        .fclk-ai-msg-content {
            background: var(--fclk-ai-brand);
            color: #fff;
            border-radius: 16px 16px 4px 16px;
        }

        .fclk-ai-msg-avatar {
            background: var(--fclk-ai-brand);
            color: #fff;
        }
    }

    &--assistant {
        .fclk-ai-msg-content {
            background: var(--o-action-color-light, var(--bs-tertiary-bg, #f0f0f0));
            color: var(--o-main-text-color, var(--bs-body-color, #212529));
            border-radius: 16px 16px 16px 4px;
        }
    }
}

.fclk-ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    background: var(--o-action-color-light, var(--bs-tertiary-bg, #e9ecef));
    color: var(--o-main-text-color, var(--bs-body-color, #212529));
}

.fclk-ai-msg-content {
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 80%;
    white-space: pre-wrap;
    word-break: break-word;
}

.fclk-ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px !important;

    span {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--o-main-text-color, var(--bs-body-color, #212529));
        opacity: 0.4;
        animation: fclk-ai-bounce 1.4s infinite ease-in-out both;

        &:nth-child(1) { animation-delay: 0s; }
        &:nth-child(2) { animation-delay: 0.16s; }
        &:nth-child(3) { animation-delay: 0.32s; }
    }
}

@keyframes fclk-ai-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.fclk-ai-chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--o-border-color, var(--bs-border-color, #dee2e6));
    flex-shrink: 0;

    textarea {
        flex: 1;
        border: 1px solid var(--o-border-color, var(--bs-border-color, #dee2e6));
        border-radius: 20px;
        padding: 8px 14px;
        font-size: 13px;
        resize: none;
        outline: none;
        background: var(--o-view-background-color, var(--bs-body-bg, #fff));
        color: var(--o-main-text-color, var(--bs-body-color, #212529));
        max-height: 80px;
        min-height: 36px;

        &:focus {
            border-color: var(--fclk-ai-brand);
        }
    }
}

.fclk-ai-new-chat,
.fclk-ai-send {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 14px;
    transition: opacity 0.15s;
}

.fclk-ai-new-chat {
    background: var(--o-action-color-light, var(--bs-tertiary-bg, #e9ecef));
    color: var(--o-main-text-color, var(--bs-body-color, #212529));

    &:hover { opacity: 0.8; }
}

.fclk-ai-send {
    background: var(--fclk-ai-brand);
    color: #fff;

    &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
}

.fclk-ai-tools-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 300px;
    max-height: 380px;
}

.fclk-ai-tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.fclk-ai-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    border-radius: 12px;
    border: 1px solid var(--o-border-color, var(--bs-border-color, #dee2e6));
    background: var(--o-view-background-color, var(--bs-body-bg, #fff));
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    color: var(--o-main-text-color, var(--bs-body-color, #212529));

    i {
        font-size: 22px;
        color: var(--fclk-ai-brand);
    }

    span {
        font-size: 12px;
        font-weight: 500;
    }

    &:hover {
        border-color: var(--fclk-ai-brand);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
}

.fclk-ai-analysis-loading {
    text-align: center;
    padding: 20px;
    color: var(--o-main-text-color, var(--bs-body-color, #212529));
    opacity: 0.6;
    font-size: 13px;

    i { margin-right: 6px; }
}

.fclk-ai-analysis-result {
    pre {
        background: var(--o-action-color-light, var(--bs-tertiary-bg, #f8f9fa));
        color: var(--o-main-text-color, var(--bs-body-color, #212529));
        padding: 14px;
        border-radius: 10px;
        font-size: 12px;
        line-height: 1.6;
        white-space: pre-wrap;
        word-break: break-word;
        max-height: 300px;
        overflow-y: auto;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .fclk-ai-systray-dropdown {
        width: calc(100vw - 32px);
    }
}
