/* EventPro AI Agent — Chat Widget Styles */

:root {
    --epai-color:         #4f46e5;
    --epai-color-light:   #ede9fe;
    --epai-text:          #1f2937;
    --epai-bg:            #ffffff;
    --epai-border:        #e5e7eb;
    --epai-shadow:        0 8px 32px rgba(0,0,0,0.18);
    --epai-radius:        16px;
    --epai-radius-msg:    12px;
    --epai-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --epai-z:             2147483647;
}

/* Root container */
#epai-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--epai-z);
    font-family: var(--epai-font);
    font-size: 15px;
}
#epai-chat-root.epai-left {
    right: auto;
    left: 24px;
}

/* ============================================================
   Bubble launcher
   ============================================================ */
.epai-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--epai-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--epai-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    color: #fff;
    padding: 0;
}
.epai-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.epai-bubble svg {
    width: 26px;
    height: 26px;
}

/* ============================================================
   Chat panel
   ============================================================ */
.epai-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--epai-bg);
    border-radius: var(--epai-radius);
    box-shadow: var(--epai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: var(--epai-z);
}
#epai-chat-root.epai-left .epai-panel {
    right: auto;
    left: 24px;
}
.epai-panel.epai-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Standalone mode */
.epai-panel.epai-standalone {
    position: relative;
    bottom: auto;
    right: auto;
    left: auto;
    width: 100%;
    max-width: 680px;
    height: calc(100vh - 40px);
    max-height: none;
    margin: 20px auto;
    opacity: 1;
    transform: none;
    pointer-events: all;
}

/* ============================================================
   Header
   ============================================================ */
.epai-header {
    background: var(--epai-color);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.epai-header-title {
    font-weight: 600;
    font-size: 16px;
}
.epai-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.epai-close:hover { opacity: 1; }

/* ============================================================
   Consent notice
   ============================================================ */
.epai-consent {
    padding: 20px 16px;
    background: var(--epai-color-light);
    border-bottom: 1px solid var(--epai-border);
    flex-shrink: 0;
}
.epai-consent p {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--epai-text);
    line-height: 1.5;
}

/* ============================================================
   Messages area
   ============================================================ */
.epai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.epai-messages::-webkit-scrollbar { width: 4px; }
.epai-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.epai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    max-width: 100%;
    animation: epai-fadein 0.2s ease;
}
@keyframes epai-fadein { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.epai-msg-user {
    flex-direction: row-reverse;
}
.epai-msg-user .epai-bubble-text {
    background: var(--epai-color);
    color: #fff;
    border-radius: var(--epai-radius-msg) var(--epai-radius-msg) 2px var(--epai-radius-msg);
}
.epai-msg-assistant .epai-bubble-text {
    background: #f3f4f6;
    color: var(--epai-text);
    border-radius: var(--epai-radius-msg) var(--epai-radius-msg) var(--epai-radius-msg) 2px;
}

.epai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
/* D) Assistant avatar: muted purple tint with white icon */
.epai-avatar-assistant {
    background: var(--epai-color-light);
    color: var(--epai-color);
}
.epai-avatar-assistant svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* ============================================================
   F) Guest login prompt
   ============================================================ */
.epai-login-prompt {
    padding: 4px 16px 8px;
}
.epai-login-prompt-inner {
    background: var(--epai-color-light);
    border: 1px solid rgba(79,70,229,0.2);
    border-radius: 10px;
    padding: 12px 14px;
}
.epai-login-prompt-text {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--epai-text);
    line-height: 1.4;
}
.epai-login-prompt-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.epai-login-btn {
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.epai-bubble-text {
    padding: 10px 14px;
    line-height: 1.55;
    font-size: 14px;
    max-width: calc(100% - 48px);
    word-break: break-word;
}
.epai-bubble-text a {
    color: inherit;
    text-decoration: underline;
}
.epai-msg-assistant .epai-bubble-text a {
    color: var(--epai-color);
}

/* Citations */
.epai-citations,
.epai-suggestions {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 12px;
}
.epai-citations strong,
.epai-suggestions strong {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}
.epai-cite-link,
.epai-suggest-link {
    display: inline-block;
    margin: 3px 4px 3px 0;
    padding: 3px 8px;
    background: rgba(79,70,229,0.1);
    color: var(--epai-color) !important;
    border-radius: 20px;
    font-size: 12px;
    text-decoration: none !important;
    transition: background 0.15s;
}
.epai-cite-link:hover,
.epai-suggest-link:hover {
    background: rgba(79,70,229,0.2);
}

/* Typing indicator */
.epai-typing-indicator .epai-bubble-text {
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}
.epai-typing-indicator .epai-bubble-text span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: epai-bounce 1.2s infinite;
}
.epai-typing-indicator .epai-bubble-text span:nth-child(2) { animation-delay: 0.2s; }
.epai-typing-indicator .epai-bubble-text span:nth-child(3) { animation-delay: 0.4s; }
@keyframes epai-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ============================================================
   Input row
   ============================================================ */
.epai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--epai-border);
    flex-shrink: 0;
    background: var(--epai-bg);
}
.epai-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--epai-border);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.15s;
}
.epai-input:focus {
    border-color: var(--epai-color);
}
.epai-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--epai-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    transition: background 0.15s, transform 0.15s;
    padding: 0;
}
.epai-send:hover { background: color-mix(in srgb, var(--epai-color) 85%, black); transform: scale(1.05); }
.epai-send svg { width: 18px; height: 18px; }

/* ============================================================
   Footer  (C: hint text; F: login prompt)
   ============================================================ */
.epai-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--epai-border);
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    background: var(--epai-bg);
}
.epai-footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.epai-escalate-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.epai-escalate-btn:hover {
    color: var(--epai-color);
    background: var(--epai-color-light);
}
/* C) Hint text beneath escalate button */
.epai-escalate-hint {
    margin: 0;
    font-size: 10px;
    color: #9ca3af;
    text-align: center;
    line-height: 1.3;
}

/* ============================================================
   Escalation form
   ============================================================ */
.epai-escalate-form {
    padding: 16px;
    background: #fafafa;
    border-bottom: 1px solid var(--epai-border);
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 320px;
}
.epai-escalate-form h3 {
    margin: 0 0 6px;
    font-size: 15px;
    color: var(--epai-text);
}
.epai-escalate-form p {
    margin: 0 0 12px;
    font-size: 13px;
    color: #6b7280;
}
/* C) Intro text has slightly different emphasis */
.epai-escalate-form .epai-esc-intro {
    font-size: 12px;
    color: #374151;
    background: #f0fdf4;
    border-left: 3px solid #16a34a;
    padding: 8px 10px;
    border-radius: 0 6px 6px 0;
    line-height: 1.45;
    margin-bottom: 14px;
}
.epai-form-group {
    margin-bottom: 10px;
}
.epai-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
.epai-form-group input,
.epai-form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--epai-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.epai-form-group input:focus,
.epai-form-group select:focus {
    border-color: var(--epai-color);
}
.epai-consent-check {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.epai-consent-check label {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-weight: normal;
    font-size: 12px;
    line-height: 1.4;
}
.epai-consent-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}
.epai-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ============================================================
   Escalation prompt in chat
   ============================================================ */
.epai-escalate-prompt {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    flex-shrink: 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.epai-btn-primary {
    background: var(--epai-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.15s;
}
.epai-btn-primary:hover {
    background: color-mix(in srgb, var(--epai-color) 85%, black);
}
.epai-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.epai-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid var(--epai-border);
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.epai-btn-secondary:hover { background: #e5e7eb; }

/* Status messages */
#esc-status {
    margin-top: 8px;
    font-size: 13px;
}
#esc-status.epai-error   { color: #dc2626; }
#esc-status.epai-success { color: #16a34a; }

/* Blocker 3: Consent hint text shown below composer when not yet accepted */
.epai-consent-hint {
    margin: 0 16px 8px;
    font-size: 12px;
    color: #dc2626;
    text-align: center;
}
/* Disabled composer state while consent not given */
.epai-input:disabled {
    background: #f9fafb;
    cursor: not-allowed;
    color: #9ca3af;
}
.epai-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
    #epai-chat-root {
        bottom: 12px;
        right: 12px;
    }
    .epai-panel {
        right: 0;
        bottom: 76px;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        height: 85vh;
    }
    #epai-chat-root.epai-left .epai-panel {
        left: 0;
        right: 0;
    }
}
