#ecb-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle button */
#ecb-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #2d6a4f;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 22px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(45,106,79,.45);
    transition: background .2s, transform .2s, box-shadow .2s;
    white-space: nowrap;
}
#ecb-toggle:hover {
    background: #1b4332;
    transform: translateY(-2px);
    box-shadow: 0 6px 26px rgba(45,106,79,.55);
}
.ecb-icon { font-size: 20px; }

/* Chat window */
#ecb-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 48px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s cubic-bezier(.34,1.56,.64,1);
}
#ecb-window.ecb-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
#ecb-header {
    background: linear-gradient(135deg, #2d6a4f 0%, #40916c 100%);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ecb-hinfo { display: flex; align-items: center; gap: 10px; }
.ecb-avatar {
    width: 42px; height: 42px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.ecb-hname   { font-weight: 700; font-size: 15px; line-height: 1.2; }
.ecb-hstatus { font-size: 11px; opacity: .82; margin-top: 2px; }
#ecb-close {
    background: none; border: none; color: #fff;
    font-size: 18px; cursor: pointer; padding: 4px 8px;
    border-radius: 50%; opacity: .75; transition: opacity .15s;
    line-height: 1;
}
#ecb-close:hover { opacity: 1; }

/* Messages */
#ecb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#ecb-messages::-webkit-scrollbar { width: 4px; }
#ecb-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.ecb-msg {
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    animation: ecbIn .28s ease both;
}
@keyframes ecbIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ecb-bot {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.ecb-user {
    background: #2d6a4f;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.ecb-done {
    background: #d1fae5;
    color: #065f46;
    border-radius: 14px;
    align-self: center;
    max-width: 92%;
    text-align: center;
    font-weight: 500;
}

/* Typing indicator */
.ecb-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 13px 16px;
    background: #f3f4f6;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: 56px;
}
.ecb-typing span {
    width: 7px; height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ecbDot 1.2s infinite;
}
.ecb-typing span:nth-child(2) { animation-delay: .2s; }
.ecb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ecbDot {
    0%,60%,100% { transform: translateY(0); opacity: .4; }
    30%          { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
#ecb-footer {
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}
#ecb-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    resize: none;
    max-height: 96px;
    line-height: 1.45;
    outline: none;
    font-family: inherit;
    transition: border-color .2s;
    color: #1f2937;
}
#ecb-input:focus  { border-color: #2d6a4f; }
#ecb-input:disabled { background: #f9fafb; color: #9ca3af; }

#ecb-send {
    width: 38px; height: 38px;
    background: #2d6a4f;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .15s;
}
#ecb-send:hover    { background: #1b4332; transform: scale(1.07); }
#ecb-send:disabled { background: #d1d5db; cursor: not-allowed; transform: none; }

/* Telegram button — головна (і єдина) дія після завершення розмови */
.ecb-bot-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    color: #fff;
    text-align: center;
    padding: 15px 22px;
    border-radius: 28px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    align-self: center;
    width: 90%;
    box-shadow: 0 4px 14px rgba(34, 158, 217, .45);
    transition: box-shadow .2s, transform .15s, background .2s;
    animation: ecbIn .28s ease both, ecbPulse 2.2s ease-in-out .9s 3;
    margin-bottom: 8px;
}
.ecb-bot-btn:hover {
    background: linear-gradient(135deg, #229ED9 0%, #1B8DC4 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 7px 20px rgba(34, 158, 217, .6);
    color: #fff;
}
.ecb-bot-btn svg { flex: 0 0 auto; }
@keyframes ecbPulse {
    0%, 100% { transform: scale(1);    box-shadow: 0 4px 14px rgba(34, 158, 217, .45); }
    50%      { transform: scale(1.05); box-shadow: 0 7px 24px rgba(34, 158, 217, .7); }
}

/* =============================================
   MOBILE — widget mode
   ============================================= */
@media (max-width: 480px) {
    #ecb-widget { bottom: 0; right: 0; left: 0; }

    #ecb-toggle {
        width: 100%;
        border-radius: 0;
        justify-content: center;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    /* JS controls top + height via visualViewport to survive iOS keyboard */
    #ecb-window {
        position: fixed;
        top: 0; left: 0; right: 0;
        bottom: auto;
        width: 100%;
        height: 100vh; /* JS overrides on open */
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }
    #ecb-window.ecb-open { transform: translateY(0); }

    #ecb-footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    /* Prevent iOS auto-zoom on input focus */
    #ecb-input { font-size: 16px; }
}

/* =============================================
   FORM MODE (з 3.0.0) — форма підбору консультанта
   ============================================= */
button.ecb-bot-btn {
    border: none;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    line-height: 1.35;
}
button.ecb-bot-btn:disabled {
    opacity: .65;
    cursor: not-allowed;
    animation: none;
    transform: none;
}

#ecb-form-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
}
#ecb-form-area::-webkit-scrollbar { width: 4px; }
#ecb-form-area::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.ecb-form-title {
    font-size: 15px;
    font-weight: 700;
    color: #1b4332;
    line-height: 1.45;
    text-align: center;
    padding: 2px 4px 0;
}

#ecb-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ecb-f-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.ecb-f-label input {
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 16px; /* prevents iOS auto-zoom */
    font-family: inherit;
    font-weight: 400;
    outline: none;
    color: #1f2937;
    width: 100%;
    transition: border-color .2s;
    background: #fff;
}
.ecb-f-label input:focus { border-color: #2d6a4f; }

.ecb-f-topics {
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}
.ecb-f-topics legend {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    padding: 0 4px;
}
.ecb-f-topic {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: #1f2937;
    background: #f3f4f6;
    border-radius: 16px;
    padding: 7px 12px;
    cursor: pointer;
    user-select: none;
    transition: background .15s, color .15s;
}
.ecb-f-topic input { accent-color: #2d6a4f; margin: 0; }
.ecb-f-topic.ecb-on {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
}

.ecb-f-consent {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    font-size: 12.5px;
    color: #4b5563;
    line-height: 1.45;
    cursor: pointer;
}
.ecb-f-consent input {
    margin-top: 2px;
    accent-color: #2d6a4f;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

#ecb-f-error {
    background: #fee2e2;
    color: #991b1b;
    font-size: 13px;
    border-radius: 10px;
    padding: 9px 12px;
}

#ecb-form-done {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 4px;
}
#ecb-form-done .ecb-msg { max-width: 100%; }

.ecb-redirect-hint {
    font-size: 12.5px;
    color: #6b7280;
    animation: ecbIn .28s ease both;
}

/* =============================================
   LANDING PAGE MODE  (data-ecb-mode="landing")
   Layout is fully controlled by landing.php inline styles.
   This file only provides the base widget/window styles.
   ============================================= */
