/*
 * VOGO eBS Public AI Chat — floating chat widget.
 * @file_version 1.0.4
 *
 * Rendered by [vogo_ebs_ai_assistant]. Position configurable via admin
 * AI Provider page → 9 anchor variants (sus/mijloc/jos × stanga/mijloc/dreapta).
 */

/* ── Fixed-position wrap (base — no anchor yet) ──────────────────────── */
.vogo-public-ai-fixed-wrap {
    position: fixed;
    z-index: 99999;
    max-width: 380px;
    width: calc(100vw - 40px);
    /* `pointer-events: none` on the wrap + auto on the widget = wrap doesn't block
       page clicks on areas where the widget doesn't draw anything. */
    pointer-events: none;
}

/* ── 8 position variants — driven by admin setting "chatbot_position" ── */
.vogo-public-ai-fixed-wrap--jos-dreapta    { bottom: 20px; right: 20px; }
.vogo-public-ai-fixed-wrap--jos-stanga     { bottom: 20px; left: 20px; }
.vogo-public-ai-fixed-wrap--jos-mijloc     { bottom: 20px; left: 50%; transform: translateX(-50%); }
.vogo-public-ai-fixed-wrap--sus-dreapta    { top: 20px; right: 20px; }
.vogo-public-ai-fixed-wrap--sus-stanga     { top: 20px; left: 20px; }
.vogo-public-ai-fixed-wrap--sus-mijloc     { top: 20px; left: 50%; transform: translateX(-50%); }
.vogo-public-ai-fixed-wrap--mijloc-dreapta { top: 50%; right: 20px; transform: translateY(-50%); }
.vogo-public-ai-fixed-wrap--mijloc-stanga  { top: 50%; left: 20px; transform: translateY(-50%); }

.vogo-public-ai {
    pointer-events: auto;
    display: flex;
    /* Default: panel grows UP above the trigger button (correct for "jos-*" anchors). */
    flex-direction: column-reverse;
    align-items: flex-end;
    font-family: inherit;
}
/* For top + middle anchors, panel grows DOWN below the trigger button. */
.vogo-public-ai-fixed-wrap--sus-stanga .vogo-public-ai,
.vogo-public-ai-fixed-wrap--sus-mijloc .vogo-public-ai,
.vogo-public-ai-fixed-wrap--sus-dreapta .vogo-public-ai,
.vogo-public-ai-fixed-wrap--mijloc-stanga .vogo-public-ai,
.vogo-public-ai-fixed-wrap--mijloc-dreapta .vogo-public-ai {
    flex-direction: column;
}
/* Left-anchored variants: align the column to the left edge of the wrap. */
.vogo-public-ai-fixed-wrap--jos-stanga    .vogo-public-ai,
.vogo-public-ai-fixed-wrap--sus-stanga    .vogo-public-ai,
.vogo-public-ai-fixed-wrap--mijloc-stanga .vogo-public-ai {
    align-items: flex-start;
}
.vogo-public-ai-fixed-wrap--jos-mijloc    .vogo-public-ai,
.vogo-public-ai-fixed-wrap--sus-mijloc    .vogo-public-ai {
    align-items: center;
}

/* ── Trigger button (closed state — pill) ────────────────────────────── */
.vogo-public-ai__banner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 14px;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #3b82f6 100%);
    color: #fff;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .28);
    transition: transform .15s ease, box-shadow .15s ease;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.2;
}
.vogo-public-ai__banner:hover,
.vogo-public-ai__banner:focus {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, .35);
    outline: none;
}
.vogo-public-ai__banner-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, .18);
    border-radius: 50%;
}
.vogo-public-ai__banner-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}
.vogo-public-ai__banner-text {
    display: inline-flex;
    align-items: center;
}
.vogo-public-ai__banner-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

/* ── Chat panel (open state) ─────────────────────────────────────────── */
.vogo-public-ai__panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    /* margin-bottom = gap between panel (above) and button (below) for "jos-*" anchors. */
    margin-bottom: 8px;
    max-height: min(70vh, 540px);
}
/* For top + middle anchors, panel sits BELOW the button → gap goes on top instead. */
.vogo-public-ai-fixed-wrap--sus-stanga .vogo-public-ai__panel,
.vogo-public-ai-fixed-wrap--sus-mijloc .vogo-public-ai__panel,
.vogo-public-ai-fixed-wrap--sus-dreapta .vogo-public-ai__panel,
.vogo-public-ai-fixed-wrap--mijloc-stanga .vogo-public-ai__panel,
.vogo-public-ai-fixed-wrap--mijloc-dreapta .vogo-public-ai__panel {
    margin-bottom: 0;
    margin-top: 8px;
}
.vogo-public-ai__panel[hidden] {
    display: none;
}
.vogo-public-ai__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 220px;
    max-height: min(50vh, 380px);
    background: #f8fafc;
}

/* ── Chat bubbles ───────────────────────────────────────────────────── */
.vogo-public-ai__msg {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.vogo-public-ai__msg--assistant {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}
.vogo-public-ai__msg--citizen {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.vogo-public-ai__msg--typing {
    color: #94a3b8;
    font-style: italic;
}

/* ── Service link list inside an assistant message ──────────────────── */
.vogo-public-ai__services {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vogo-public-ai__service-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1e40af;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: background .15s ease, border-color .15s ease;
}
.vogo-public-ai__service-link:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.vogo-public-ai__service-link::before {
    content: '→';
    font-weight: 700;
}

/* ── Yes/No transfer prompt buttons ──────────────────────────────────── */
.vogo-public-ai__transfer-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}
.vogo-public-ai__transfer-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #1e293b;
    transition: all .15s ease;
}
.vogo-public-ai__transfer-btn--yes {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}
.vogo-public-ai__transfer-btn--yes:hover {
    background: #15803d;
    border-color: #15803d;
}
.vogo-public-ai__transfer-btn--no:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

/* ── Composer (input + send button) ──────────────────────────────────── */
.vogo-public-ai__composer {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    align-items: flex-end;
}
.vogo-public-ai__input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
    font-family: inherit;
    resize: vertical;
    min-height: 44px;
    max-height: 140px;
    background: #fff;
    color: #1e293b;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
}
.vogo-public-ai__input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.vogo-public-ai__send {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(37, 99, 235, .25);
    transition: background .15s ease, transform .15s ease;
    flex-shrink: 0;
}
.vogo-public-ai__send:hover,
.vogo-public-ai__send:focus {
    background: #1d4ed8;
    transform: translateY(-1px);
    outline: none;
}
.vogo-public-ai__send:disabled {
    opacity: .55;
    cursor: wait;
    transform: none;
}
.vogo-public-ai__send svg {
    width: 18px;
    height: 18px;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    /* Don't override position here — keep whatever anchor variant is active.
       Just shrink edge offsets + relax max-width so the widget fits portrait phones. */
    .vogo-public-ai-fixed-wrap--jos-dreapta,
    .vogo-public-ai-fixed-wrap--sus-dreapta,
    .vogo-public-ai-fixed-wrap--mijloc-dreapta { right: 10px; }
    .vogo-public-ai-fixed-wrap--jos-stanga,
    .vogo-public-ai-fixed-wrap--sus-stanga,
    .vogo-public-ai-fixed-wrap--mijloc-stanga { left: 10px; }
    .vogo-public-ai-fixed-wrap--jos-dreapta,
    .vogo-public-ai-fixed-wrap--jos-stanga,
    .vogo-public-ai-fixed-wrap--jos-mijloc { bottom: 10px; }
    .vogo-public-ai-fixed-wrap--sus-dreapta,
    .vogo-public-ai-fixed-wrap--sus-stanga,
    .vogo-public-ai-fixed-wrap--sus-mijloc { top: 10px; }
    .vogo-public-ai-fixed-wrap { max-width: calc(100vw - 20px); }
    .vogo-public-ai__messages { max-height: 45vh; }
}
