/* ── AI Floating Bubble ──────────────────────────────────── */
.ai-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(187,17,0,0.4), 0 4px 20px rgba(187,17,0,0.3), 0 2px 8px rgba(0,0,0,0.6);
    z-index: 9999;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    animation: hal-pulse 3s ease-in-out infinite;
}
.ai-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px rgba(187,17,0,0.6), 0 4px 28px rgba(187,17,0,0.5), 0 2px 8px rgba(0,0,0,0.6);
    animation: none;
}
.ai-bubble--hidden { opacity: 0; pointer-events: none; animation: none; }

@keyframes hal-pulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(187,17,0,0.4), 0 4px 20px rgba(187,17,0,0.3), 0 2px 8px rgba(0,0,0,0.6); }
    50% { box-shadow: 0 0 0 2px rgba(187,17,0,0.55), 0 4px 28px rgba(187,17,0,0.45), 0 2px 8px rgba(0,0,0,0.6); }
}

.ai-bubble__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e63757;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── AI Chat Panel ───────────────────────────────────────── */
.ai-panel {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 380px;
    height: 520px;
    background: var(--bs-body-bg, #fff);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(.34,1.56,.64,1), opacity 0.18s;
}
.ai-panel--open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.ai-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #6b5eae;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.ai-panel__header-left, .ai-panel__header-right { display: flex; align-items: center; gap: 8px; }

.ai-icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}
.ai-icon-btn:hover { background: rgba(255,255,255,0.28); }

.ai-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.ai-messages { display: flex; flex-direction: column; gap: 10px; }

/* ── Messages ────────────────────────────────────────────── */
.ai-message { display: flex; flex-direction: column; max-width: 85%; }
.ai-message--user { align-self: flex-end; align-items: flex-end; }
.ai-message--assistant { align-self: flex-start; align-items: flex-start; }

.ai-message__bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}
.ai-message--user .ai-message__bubble {
    background: #6b5eae;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-message--assistant .ai-message__bubble {
    background: var(--bs-light, #f2f2f5);
    color: var(--bs-body-color, #12263f);
    border-bottom-left-radius: 4px;
}
.ai-message__time { font-size: 0.7rem; color: #95aac9; margin-top: 3px; }

/* Thinking dots */
.ai-message__bubble--thinking {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
}
.ai-message__bubble--thinking span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #95aac9;
    animation: thinking 1.2s infinite;
}
.ai-message__bubble--thinking span:nth-child(2) { animation-delay: 0.2s; }
.ai-message__bubble--thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking { 0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ── Empty State ─────────────────────────────────────────── */
.ai-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px 16px;
    color: #95aac9;
}
.ai-empty__icon { font-size: 2.2rem; margin-bottom: 10px; }
.ai-empty__sub { font-size: 0.8rem; color: #b0bec9; margin-bottom: 0; }
.ai-empty__welcome {
    font-size: 0.95rem;
    font-weight: 600;
    color: #12263f;
    margin-bottom: 0;
    min-height: 1.5em;
}
.ai-empty__cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background: #6b5eae;
    margin-left: 2px;
    vertical-align: middle;
    border-radius: 1px;
    animation: ai-blink 0.8s step-end infinite;
}
@keyframes ai-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Footer / Input ──────────────────────────────────────── */
.ai-panel__footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--bs-border-color, #e3ebf6);
    flex-shrink: 0;
}
.ai-input {
    flex: 1;
    border: 1px solid var(--bs-border-color, #d2ddec);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.875rem;
    resize: none;
    max-height: 100px;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #12263f);
    outline: none;
    transition: border-color 0.15s;
}
.ai-input:focus { border-color: #6b5eae; }
.ai-send-btn {
    background: #6b5eae;
    border: none;
    color: #fff;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.ai-send-btn:hover:not(:disabled) { background: #5a4d9a; }
.ai-send-btn:disabled { background: #95aac9; cursor: not-allowed; }

/* ── History Page ────────────────────────────────────────── */
.ai-history-body { max-height: calc(100vh - 300px); overflow-y: auto; }

.ai-history-message { margin-bottom: 20px; }
.ai-history-message__label { font-weight: 600; font-size: 0.8rem; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.ai-history-message--user .ai-history-message__label { color: #6b5eae; }
.ai-history-message--assistant .ai-history-message__label { color: #6e84a3; }
.ai-history-message__content {
    background: var(--bs-light, #f2f2f5);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.875rem;
    line-height: 1.6;
}
.ai-history-message--user .ai-history-message__content {
    background: #f0eeff;
}

/* Dark mode overrides */
.dark-mode .ai-panel { background: #1e2e42; }
.dark-mode .ai-message--assistant .ai-message__bubble { background: #233044; color: #e3ebf6; }
.dark-mode .ai-input { background: #1e2e42; color: #e3ebf6; border-color: #344a60; }
.dark-mode .ai-suggestion { background: #233044; border-color: #344a60; color: #e3ebf6; }
.dark-mode .ai-history-message__content { background: #233044; color: #e3ebf6; }
.dark-mode .ai-history-message--user .ai-history-message__content { background: #2d2659; }
