/*
 * EA Mobile Connect — Chatbot Widget
 * Theme matches ea-converter-aff (green palette, Inter, pill buttons).
 * All selectors are scoped under #eac-chatbot to avoid clashes with host pages.
 */

#eac-chatbot {
    --eac-primary: #16A34A;
    --eac-primary-dark: #15803D;
    --eac-primary-light: #22C55E;
    --eac-primary-soft: #D1FAE5;
    --eac-primary-tint: #ECFDF5;
    --eac-primary-rgb: 22, 163, 74;
    --eac-bg: #F3FAF5;
    --eac-text: #0F172A;
    --eac-text-muted: #475569;
    --eac-text-dim: #64748B;
    --eac-border: #E2E8F0;
    --eac-border-subtle: #F1F5F9;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--eac-text);
}

#eac-chatbot *,
#eac-chatbot *::before,
#eac-chatbot *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== LAUNCHER (floating bubble) ===== */
#eac-chatbot .eac-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--eac-primary-light), var(--eac-primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(var(--eac-primary-rgb), 0.30);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 9998;
}
#eac-chatbot .eac-launcher:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(var(--eac-primary-rgb), 0.40);
}
#eac-chatbot .eac-launcher.is-open { display: none; }

/* ===== PANEL ===== */
#eac-chatbot .eac-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border: 1px solid var(--eac-border-subtle);
    border-radius: 20px;
    box-shadow: 0 16px 40px rgba(var(--eac-primary-rgb), 0.15), 0 4px 14px rgba(15, 23, 42, 0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform-origin: bottom right;
    animation: eac-pop 0.18s ease-out;
}
#eac-chatbot .eac-panel.is-open { display: flex; }
@keyframes eac-pop {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== HEADER ===== */
#eac-chatbot .eac-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--eac-primary-tint) 0%, #fff 100%);
    border-bottom: 1px solid var(--eac-border-subtle);
}
#eac-chatbot .eac-header-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--eac-primary-light), var(--eac-primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 4px 14px rgba(var(--eac-primary-rgb), 0.25);
    flex-shrink: 0;
}
#eac-chatbot .eac-header-text { flex: 1; min-width: 0; }
#eac-chatbot .eac-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--eac-text);
    line-height: 1.2;
}
#eac-chatbot .eac-header-status {
    font-size: 0.78rem;
    color: var(--eac-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
#eac-chatbot .eac-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--eac-primary-light);
    box-shadow: 0 0 0 3px rgba(var(--eac-primary-rgb), 0.22);
}
#eac-chatbot .eac-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--eac-text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
#eac-chatbot .eac-close:hover {
    background: var(--eac-primary-soft);
    color: var(--eac-primary-dark);
}

/* ===== MESSAGE LIST ===== */
#eac-chatbot .eac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 18px 8px;
    background: var(--eac-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--eac-border) transparent;
}
#eac-chatbot .eac-messages::-webkit-scrollbar { width: 6px; }
#eac-chatbot .eac-messages::-webkit-scrollbar-thumb {
    background: var(--eac-border);
    border-radius: 999px;
}

#eac-chatbot .eac-msg {
    max-width: 82%;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: eac-msg-in 0.18s ease-out;
}
@keyframes eac-msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
#eac-chatbot .eac-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: var(--eac-text);
    border: 1px solid var(--eac-border-subtle);
    border-bottom-left-radius: 6px;
}
#eac-chatbot .eac-msg-user {
    align-self: flex-end;
    background: var(--eac-primary);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(var(--eac-primary-rgb), 0.18);
}
#eac-chatbot .eac-msg-system {
    align-self: center;
    background: var(--eac-primary-tint);
    color: var(--eac-primary-dark);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 999px;
    max-width: 90%;
    text-align: center;
}

/* ===== QUICK-REPLY OPTIONS ===== */
#eac-chatbot .eac-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    max-width: 92%;
    margin-top: -2px;
    margin-bottom: 4px;
    animation: eac-msg-in 0.22s ease-out;
}
#eac-chatbot .eac-option {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--eac-border);
    background: #fff;
    color: var(--eac-text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
#eac-chatbot .eac-option:hover {
    border-color: var(--eac-primary);
    color: var(--eac-primary-dark);
    background: var(--eac-primary-tint);
    transform: translateY(-1px);
}
#eac-chatbot .eac-option:active {
    transform: translateY(0);
}

/* ===== ESCALATION FORM ===== */
#eac-chatbot .eac-form {
    align-self: stretch;
    background: #fff;
    border: 1px solid var(--eac-border-subtle);
    border-radius: 16px;
    padding: 16px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: eac-msg-in 0.22s ease-out;
}
#eac-chatbot .eac-form-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
#eac-chatbot .eac-form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--eac-text-muted);
    letter-spacing: 0.1px;
}
#eac-chatbot .eac-form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--eac-border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--eac-text);
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#eac-chatbot textarea.eac-form-control {
    resize: vertical;
    min-height: 70px;
    line-height: 1.5;
}
#eac-chatbot .eac-form-control:focus {
    border-color: var(--eac-primary);
    box-shadow: 0 0 0 3px var(--eac-primary-soft);
}
#eac-chatbot input[type="file"].eac-form-control {
    padding: 7px 10px;
    font-size: 0.82rem;
    color: var(--eac-text-muted);
    cursor: pointer;
}
#eac-chatbot input[type="file"].eac-form-control::file-selector-button {
    margin-right: 10px;
    padding: 5px 12px;
    border: none;
    border-radius: 999px;
    background: var(--eac-primary-soft);
    color: var(--eac-primary-dark);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
#eac-chatbot .eac-form-error {
    font-size: 0.82rem;
    color: #B91C1C;
    background: #FEE2E2;
    padding: 8px 12px;
    border-radius: 8px;
}
#eac-chatbot .eac-form-submit {
    margin-top: 4px;
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    background: var(--eac-primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(var(--eac-primary-rgb), 0.25);
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    align-self: stretch;
}
#eac-chatbot .eac-form-submit:hover:not(:disabled) {
    background: var(--eac-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(var(--eac-primary-rgb), 0.32);
}
#eac-chatbot .eac-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== TYPING ===== */
#eac-chatbot .eac-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--eac-border-subtle);
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    padding: 12px 14px;
    display: flex;
    gap: 4px;
}
#eac-chatbot .eac-typing span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--eac-text-dim);
    animation: eac-typing 1.2s infinite;
}
#eac-chatbot .eac-typing span:nth-child(2) { animation-delay: 0.15s; }
#eac-chatbot .eac-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes eac-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ===== INPUT BAR ===== */
#eac-chatbot .eac-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--eac-border-subtle);
    background: #fff;
}
#eac-chatbot .eac-input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid var(--eac-border);
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--eac-text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#eac-chatbot .eac-input:focus {
    border-color: var(--eac-primary);
    box-shadow: 0 0 0 3px var(--eac-primary-soft);
}
#eac-chatbot .eac-input::placeholder { color: var(--eac-text-dim); }

#eac-chatbot .eac-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: var(--eac-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(var(--eac-primary-rgb), 0.25);
}
#eac-chatbot .eac-send:hover:not(:disabled) {
    background: var(--eac-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(var(--eac-primary-rgb), 0.32);
}
#eac-chatbot .eac-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    #eac-chatbot .eac-panel {
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
        height: calc(100vh - 24px);
        max-height: none;
    }
    #eac-chatbot .eac-launcher {
        right: 16px;
        bottom: 16px;
        width: 54px;
        height: 54px;
    }
}
