/*
 * Audit AI Assistant — Public Stylesheet  v3.0.0
 * Plugin: evoke-chat-ai
 * Author: EVOKE (Janelle Mason & Twanna Finch)
 * Colors: Navy #001f3f | Gold #B59410 | White text
 */

/* ── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
    --aca-primary:      #001f3f;
    --aca-primary-dark: #00152a;
    --aca-accent:       #B59410;
    --aca-accent-dark:  #9a7d0a;
    --aca-white:        #ffffff;
    --aca-bg:           #f6f8fc;
    --aca-border:       #dde2ef;
    --aca-text:         #1a1a2e;
    --aca-text-muted:   #6b7280;
    --aca-shadow:       0 4px 24px rgba(0,31,63,0.18);
    --aca-radius:       14px;
    --aca-radius-sm:    8px;
    --aca-transition:   all 0.25s ease;
    --aca-bubble-size:  60px;
    --aca-panel-width:  380px;
    --aca-panel-height: 540px;
}


/* ══════════════════════════════════════════════════════════════════════════
   FLOATING TRIGGER BUTTON
══════════════════════════════════════════════════════════════════════════ */

.aca-floating-wrap {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.aca-bubble-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--aca-primary);
    color: var(--aca-white);
    border: none;
    border-radius: 50px;
    padding: 0 20px 0 16px;
    height: var(--aca-bubble-size);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: var(--aca-shadow);
    transition: var(--aca-transition);
    white-space: nowrap;
}

.aca-bubble-btn:hover,
.aca-bubble-btn:focus-visible {
    background: var(--aca-accent);
    outline: 3px solid rgba(181,148,16,0.4);
    outline-offset: 2px;
}

.aca-bubble-btn svg {
    flex-shrink: 0;
}

.aca-bubble-close {
    display: none;
    font-size: 1rem;
    margin-left: 2px;
}

.aca-bubble-btn.aca-open .aca-bubble-label {
    display: none;
}

.aca-bubble-btn.aca-open .aca-bubble-close {
    display: inline;
}

/* gold accent strip on bottom of bubble */
.aca-bubble-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 3px;
    background: var(--aca-accent);
    border-radius: 2px;
    opacity: 0;
    transition: var(--aca-transition);
}
.aca-floating-wrap {
    position: fixed;
}
.aca-bubble-btn {
    position: relative;
}


/* ══════════════════════════════════════════════════════════════════════════
   CHAT PANEL — shared styles
══════════════════════════════════════════════════════════════════════════ */

.aca-chat-panel {
    background: var(--aca-white);
    border-radius: var(--aca-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
}


/* ── Floating panel ──────────────────────────────────────────────────────── */

.aca-panel-floating {
    position: fixed;
    bottom: calc(var(--aca-bubble-size) + 44px);
    right: 28px;
    width: var(--aca-panel-width);
    height: var(--aca-panel-height);
    z-index: 99989;
    box-shadow: var(--aca-shadow);
    border: 1px solid var(--aca-border);

    /* Animation */
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
    pointer-events: none;
}

.aca-panel-floating.aca-panel-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.aca-panel-floating[hidden] {
    display: flex !important;  /* keep in DOM for animation; hidden via opacity/pointer-events */
}


/* ── Inline panel ────────────────────────────────────────────────────────── */

.aca-inline-wrap {
    margin: 2rem 0;
}

.aca-panel-inline {
    width: 100%;
    max-width: 700px;
    height: 520px;
    border: 1px solid var(--aca-border);
    box-shadow: 0 2px 12px rgba(0,31,63,0.09);
}


/* ── Panel header ────────────────────────────────────────────────────────── */

.aca-panel-header {
    background: var(--aca-primary);
    color: var(--aca-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    flex-shrink: 0;
    border-bottom: 3px solid var(--aca-accent);
}

.aca-panel-header-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.aca-panel-icon {
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aca-panel-title {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.aca-panel-subtitle {
    display: block;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.65);
    line-height: 1;
}

.aca-panel-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: var(--aca-transition);
}
.aca-panel-close:hover { color: var(--aca-white); background: rgba(255,255,255,0.12); }


/* ── Preset prompts ──────────────────────────────────────────────────────── */

.aca-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.75rem 1rem;
    background: var(--aca-bg);
    border-bottom: 1px solid var(--aca-border);
    flex-shrink: 0;
}

.aca-preset-btn {
    background: var(--aca-white);
    border: 1px solid var(--aca-border);
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--aca-primary);
    font-weight: 500;
    transition: var(--aca-transition);
    white-space: nowrap;
}

.aca-preset-btn:hover {
    background: var(--aca-primary);
    border-color: var(--aca-primary);
    color: var(--aca-white);
}


/* ── Chat messages ───────────────────────────────────────────────────────── */

.aca-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    scroll-behavior: smooth;
}

.aca-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.aca-msg-ai  { align-self: flex-start; }
.aca-msg-user { align-self: flex-end; align-items: flex-end; }

.aca-msg-label {
    font-size: 0.68rem;
    color: var(--aca-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.aca-msg-bubble {
    padding: 0.65rem 0.9rem;
    border-radius: var(--aca-radius-sm);
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.aca-msg-ai .aca-msg-bubble {
    background: var(--aca-bg);
    border: 1px solid var(--aca-border);
    color: var(--aca-text);
    border-top-left-radius: 2px;
}

.aca-msg-user .aca-msg-bubble {
    background: var(--aca-primary);
    color: var(--aca-white);
    border-top-right-radius: 2px;
}

/* Markdown-ish formatting inside AI bubbles */
.aca-msg-ai .aca-msg-bubble h2,
.aca-msg-ai .aca-msg-bubble h3 {
    margin: 0.6em 0 0.3em;
    font-size: 0.9rem;
    color: var(--aca-primary);
}
.aca-msg-ai .aca-msg-bubble ul,
.aca-msg-ai .aca-msg-bubble ol {
    padding-left: 1.3em;
    margin: 0.4em 0;
}
.aca-msg-ai .aca-msg-bubble li {
    margin-bottom: 0.2em;
}
.aca-msg-ai .aca-msg-bubble p {
    margin: 0.3em 0;
}
.aca-msg-ai .aca-msg-bubble strong {
    color: var(--aca-primary);
}


/* ── Thinking indicator ──────────────────────────────────────────────────── */

.aca-thinking {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.aca-thinking[hidden] { display: none; }

.aca-thinking-dot {
    width: 7px;
    height: 7px;
    background: var(--aca-primary);
    border-radius: 50%;
    animation: aca-bounce 1.2s infinite ease-in-out;
    opacity: 0.6;
}
.aca-thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.aca-thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aca-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}


/* ── Follow-up suggestions ───────────────────────────────────────────────── */

.aca-followups {
    padding: 0 1rem 0.5rem;
    flex-shrink: 0;
}

.aca-followups[hidden] { display: none; }

.aca-followups-label {
    font-size: 0.7rem;
    color: var(--aca-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.4rem;
}

.aca-followup-btn {
    display: inline-block;
    background: transparent;
    border: 1px solid var(--aca-accent);
    color: var(--aca-accent-dark);
    border-radius: 20px;
    padding: 0.28rem 0.65rem;
    font-size: 0.73rem;
    cursor: pointer;
    margin: 0 0.3rem 0.3rem 0;
    transition: var(--aca-transition);
    font-weight: 500;
}
.aca-followup-btn:hover {
    background: var(--aca-accent);
    color: var(--aca-white);
    border-color: var(--aca-accent);
}


/* ── Input area ──────────────────────────────────────────────────────────── */

.aca-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--aca-border);
    background: var(--aca-white);
    flex-shrink: 0;
}

.aca-input {
    flex: 1;
    border: 1px solid var(--aca-border);
    border-radius: var(--aca-radius-sm);
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.15s;
    color: var(--aca-text);
}

.aca-input:focus {
    border-color: var(--aca-primary);
    box-shadow: 0 0 0 3px rgba(0,31,63,0.1);
}

.aca-input::placeholder { color: var(--aca-text-muted); }

.aca-send-btn {
    background: var(--aca-accent);
    color: var(--aca-white);
    border: none;
    border-radius: var(--aca-radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--aca-transition);
}
.aca-send-btn:hover  { background: var(--aca-accent-dark); }
.aca-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.aca-disclaimer {
    font-size: 0.65rem;
    color: var(--aca-text-muted);
    text-align: center;
    padding: 0 1rem 0.6rem;
    margin: 0;
    flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    :root {
        --aca-panel-width: calc(100vw - 24px);
    }

    .aca-floating-wrap {
        right: 12px;
        bottom: 16px;
    }

    .aca-panel-floating {
        right: 12px;
        bottom: calc(var(--aca-bubble-size) + 32px);
        left: 12px;
        width: auto;
    }

    .aca-bubble-btn {
        padding: 0 14px 0 12px;
        height: 52px;
    }

    .aca-presets {
        gap: 0.35rem;
        padding: 0.6rem 0.75rem;
    }

    .aca-preset-btn {
        font-size: 0.72rem;
        padding: 0.28rem 0.6rem;
    }
}
