/* ==========================================================================
   BongaBonga Chat — beautiful mobile-first widget.
   ========================================================================== */

#bbc-chat,
#bbc-chat *,
#bbc-chat *::before,
#bbc-chat *::after {
    box-sizing: border-box;
}

#bbc-chat {
    --bbc-accent: #FFC107;
    --bbc-accent-dark: #FFA000;
    --bbc-accent-soft: #FFF8E1;
    --bbc-text: #1A202C;
    --bbc-text-secondary: #4A5568;
    --bbc-text-muted: #718096;
    --bbc-bg: #F7FAFC;
    --bbc-panel: #FFFFFF;
    --bbc-border: #E2E8F0;
    --bbc-success: #38A169;
    --bbc-danger: #E53E3E;
    --bbc-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --bbc-shadow-lg: 0 16px 40px rgba(26,32,44,0.14), 0 6px 12px rgba(26,32,44,0.06);
    --bbc-mobile-bar-h: 64px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--bbc-text);
}

/* Bubble */

.bbc-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 950;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bbc-accent) 0%, var(--bbc-accent-dark) 100%);
    color: var(--bbc-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 6px 24px rgba(255,160,0,0.45);
    transition: transform 0.15s ease;
}

.bbc-bubble svg {
    width: 28px;
    height: 28px;
    display: block;
    stroke: var(--bbc-text);
}

.bbc-bubble__close {
    width: 24px !important;
    height: 24px !important;
}

.bbc-bubble:hover {
    transform: scale(1.06);
}

.bbc-bubble__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    animation: bbc-pulse 2.4s infinite;
}

@keyframes bbc-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255,193,7,0.65); }
    70% { box-shadow: 0 0 0 16px rgba(255,193,7,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,193,7,0); }
}

.bbc-bubble__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--bbc-danger);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Усиленная пульсация бейджа когда callout активен */
.bbc-bubble__badge--pulse {
    animation: bbc-badge-pulse 1.4s ease-in-out infinite;
}

@keyframes bbc-badge-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(229,62,62,0.6); }
    50% { transform: scale(1.18); box-shadow: 0 0 0 8px rgba(229,62,62,0); }
}

#bbc-chat[data-state="open"] .bbc-bubble__pulse,
#bbc-chat[data-state="open"] .bbc-bubble__badge {
    display: none;
}

@media (max-width: 640px) {
    /* На мобильных bubble скрыт — кнопка AI находится в нижней мобильной панели темы.
       Если тема не активна (нет mobile bar), bubble будет показан через JS-feature-detect. */
    .bbc-bubble {
        display: none;
    }
    /* Если data-mobile-trigger="absent" — показываем (для совместимости с другими темами) */
    #bbc-chat[data-mobile-trigger="absent"] .bbc-bubble {
        display: flex;
        bottom: 16px;
        right: 14px;
    }
}

/* Callout speech bubble — chat-style notification */

.bbc-callout {
    position: fixed;
    bottom: 32px;
    right: 86px;
    z-index: 949;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    color: var(--bbc-text);
    padding: 10px 14px 10px 12px;
    border-radius: 18px 18px 6px 18px; /* острый правый-нижний угол → к хвосту/кнопке */
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    box-shadow: 0 12px 32px rgba(26,32,44,0.18),
                0 4px 10px rgba(26,32,44,0.08),
                0 0 0 1px rgba(26,32,44,0.04);
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    max-width: 280px;
    user-select: none;
    text-align: left;
}

.bbc-callout__avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bbc-accent) 0%, var(--bbc-accent-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(255,160,0,0.35);
}

.bbc-callout__body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.bbc-callout__name {
    font-size: 11px;
    font-weight: 700;
    color: var(--bbc-text-muted);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.bbc-callout__text {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--bbc-text);
    line-height: 1.35;
    transition: opacity 0.12s ease;
    min-height: 18px; /* удерживаем высоту во время typing-индикатора */
}

/* Typing-индикатор «бот печатает» — 3 пульсирующие точки */
.bbc-callout__typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 18px;
}
.bbc-callout__typing > span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bbc-text-muted);
    animation: bbc-typing-bounce 1.2s ease-in-out infinite;
}
.bbc-callout__typing > span:nth-child(2) { animation-delay: 0.15s; }
.bbc-callout__typing > span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bbc-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30%           { transform: translateY(-3px); opacity: 1; }
}

.bbc-callout:hover {
    transform: translateX(0) scale(1.02);
}

.bbc-callout::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #fff;
}

#bbc-chat[data-callout-visible="1"] .bbc-callout {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 640px) {
    /* Mobile callout — белый chat-bubble с жёлтым аватаром.
       Сильная тень + еле заметная серая обводка делают хвост видимым
       на белом баре. */
    .bbc-callout {
        right: 12px;
        max-width: 280px;
        padding: 10px 14px 10px 12px;
        background: #fff;
        color: var(--bbc-text);
        border-radius: 18px 18px 4px 18px;
        box-shadow: 0 14px 36px rgba(26,32,44,0.20),
                    0 4px 12px rgba(26,32,44,0.10),
                    0 0 0 1px rgba(26,32,44,0.06);
        transform-origin: 78% 100%;
        transform: scale(0.4) translateY(4px);
        opacity: 0;
        transition: opacity 0.3s ease,
                    transform 0.45s cubic-bezier(.2, 1.4, .4, 1);
    }
    #bbc-chat[data-callout-visible="1"] .bbc-callout {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    /* Хвост белый, видимость даёт двойной drop-shadow — сначала тонкая
       серая обводка по краю, потом мягкая большая тень */
    .bbc-callout::after {
        content: '';
        position: absolute;
        top: auto;
        bottom: -14px;
        right: 18px;
        left: auto;
        transform: none;
        width: 0;
        height: 0;
        border-left: 10px solid transparent;
        border-right: 7px solid transparent;
        border-top: 18px solid #fff;
        border-bottom: 0;
        filter:
            drop-shadow(0 1px 0 rgba(26,32,44,0.18))
            drop-shadow(1px 0 0 rgba(26,32,44,0.10))
            drop-shadow(-1px 0 0 rgba(26,32,44,0.10))
            drop-shadow(0 5px 6px rgba(26,32,44,0.18));
    }
    /* Капля — белая, та же обводка через тень */
    .bbc-callout::before {
        content: '';
        position: absolute;
        bottom: -22px;
        right: 22px;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 0 0 1px rgba(26,32,44,0.12),
                    0 3px 5px rgba(26,32,44,0.18);
    }
    /* Аватар бота — жёлтый круг с роботом, как в десктопной версии */
    .bbc-callout__avatar {
        width: 34px;
        height: 34px;
        font-size: 18px;
        background: linear-gradient(135deg, var(--bbc-accent) 0%, var(--bbc-accent-dark) 100%);
    }
}

/* «Непрочитанное» пульсирование кнопки AI после показа callout —
   мягкие волны от иконки + красная точка-индикатор */
@keyframes bbc-trigger-unread-pulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(255,160,0,0.5),
                            0 0 0 0 rgba(229,62,62,0.55); }
    50%      { box-shadow: 0 4px 14px rgba(255,160,0,0.5),
                            0 0 0 14px rgba(229,62,62,0); }
}

.bbc-trigger-unread .bb26-mobile-bar__icon {
    animation: bbc-trigger-unread-pulse 1.8s ease-out infinite;
    position: relative;
}

/* Красная точка-бейдж (как «непрочитанное сообщение») в правом верху иконки */
.bbc-trigger-unread .bb26-mobile-bar__icon::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: var(--bbc-danger, #E53E3E);
    border: 2px solid #fff;
    border-radius: 50%;
    animation: bbc-trigger-unread-dot 1.4s ease-in-out infinite;
}

@keyframes bbc-trigger-unread-dot {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.25); }
}

/* Wiggle для кнопки AI в sticky-bar при появлении callout —
   привлекает внимание, имитируя «бот написал тебе сообщение».
   Кнопка одновременно вырастает (~30%) и качается. */
@keyframes bbc-trigger-wiggle {
    0%   { transform: translateY(0) rotate(0deg) scale(1); }
    15%  { transform: translateY(-4px) rotate(-12deg) scale(1.28); }
    30%  { transform: translateY(-2px) rotate(10deg) scale(1.32); }
    45%  { transform: translateY(-3px) rotate(-8deg) scale(1.30); }
    60%  { transform: translateY(-1px) rotate(6deg) scale(1.22); }
    75%  { transform: translateY(0) rotate(-3deg) scale(1.12); }
    100% { transform: translateY(0) rotate(0deg) scale(1); }
}
.bbc-trigger-wiggle {
    animation: bbc-trigger-wiggle 1.1s cubic-bezier(.36, 1.6, .42, 1) both;
    transform-origin: 50% 60%;
    z-index: 2;
}
/* Когда трясётся именно акцент-кнопка чата — увеличиваем её круглую иконку */
.bbc-trigger-wiggle .bb26-mobile-bar__icon {
    box-shadow: 0 6px 20px rgba(255, 160, 0, 0.65);
}

/* Modal */

.bbc-modal {
    position: fixed;
    bottom: 88px;
    right: 20px;
    z-index: 951;
    width: 380px;
    max-width: calc(100vw - 28px);
    background: var(--bbc-panel);
    border: 1px solid var(--bbc-border);
    border-radius: 18px;
    box-shadow: var(--bbc-shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(620px, calc(100vh - 120px));
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#bbc-chat[data-state="open"] .bbc-modal {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

@media (max-width: 640px) {
    .bbc-modal {
        /* Поднимаем над sticky bottom bar (64px высотой) */
        bottom: var(--bb-mobile-bar-height, 64px);
        right: 0;
        width: 100vw;
        max-width: 100vw;
        max-height: calc(100vh - var(--bb-mobile-bar-height, 64px) - 16px);
        border-radius: 18px 18px 0 0;
        border-bottom: 0;
    }
}

/* Modal header */

.bbc-modal__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--bbc-accent) 0%, var(--bbc-accent-dark) 100%);
    color: var(--bbc-text);
    flex-shrink: 0;
}

.bbc-modal__head-icon {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.bbc-modal__head-text {
    flex: 1;
    min-width: 0;
}

.bbc-modal__title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--bbc-text);
}

/* Disclaimer-полоска под шапкой — единственная маркировка «Реклама»
   (Reklaamiseadus §29 + Tarbijakaitseamet требования) */
.bbc-modal__ad-bar {
    display: flex;
    gap: 8px;
    padding: 8px 14px;
    background: #fff7e0;
    border-bottom: 1px solid #f0e0a0;
    color: #6b5300;
    font-size: 11.5px;
    line-height: 1.4;
    flex-shrink: 0;
}

.bbc-modal__ad-bar-icon {
    flex-shrink: 0;
    color: #b58a00;
}

.bbc-modal__ad-bar-text {
    flex: 1;
    min-width: 0;
}

.bbc-modal__sub {
    margin: 1px 0 0;
    font-size: 11px;
    color: rgba(26,32,44,0.7);
    line-height: 1.3;
}

.bbc-modal__close {
    width: 36px;
    height: 36px;
    border: 0;
    background: rgba(26, 32, 44, 0.15);
    color: var(--bbc-text);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.bbc-modal__close svg {
    width: 22px;
    height: 22px;
    stroke: var(--bbc-text);
    stroke-width: 2.6;
    display: block;
}

.bbc-modal__close:hover {
    background: rgba(26, 32, 44, 0.28);
    transform: rotate(90deg);
}

.bbc-modal__close:hover svg {
    stroke: var(--bbc-text);
}

/* Messages area */

.bbc-modal__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 6px;
    background: var(--bbc-bg);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.bbc-modal__messages::-webkit-scrollbar {
    width: 4px;
}
.bbc-modal__messages::-webkit-scrollbar-thumb {
    background: var(--bbc-border);
    border-radius: 4px;
}

/* Message types */

.bbc-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: flex-start;
    animation: bbc-fade-in 0.25s ease;
}

@keyframes bbc-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.bbc-msg--bot {
    align-items: flex-start;
}

.bbc-msg__avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: var(--bbc-accent-soft);
    color: var(--bbc-accent-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

.bbc-msg__bubble {
    background: var(--bbc-panel);
    color: var(--bbc-text);
    padding: 10px 13px;
    border-radius: 14px 14px 14px 4px;
    font-size: 14px;
    line-height: 1.45;
    max-width: 84%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid var(--bbc-border);
}

.bbc-msg__bubble b { font-weight: 700; }

.bbc-msg--user {
    justify-content: flex-end;
}

.bbc-msg--user .bbc-msg__bubble {
    background: var(--bbc-text);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    border-color: var(--bbc-text);
    box-shadow: var(--bbc-shadow);
}

.bbc-msg__hint {
    font-size: 11px;
    color: var(--bbc-text-muted);
    font-style: italic;
    margin-top: 4px;
}

.bbc-msg__spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--bbc-border);
    border-top-color: var(--bbc-accent-dark);
    border-radius: 50%;
    animation: bbc-spin 0.7s linear infinite;
    margin-right: 6px;
    vertical-align: -3px;
}

@keyframes bbc-spin {
    to { transform: rotate(360deg); }
}

/* Choice buttons */

.bbc-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-left: 36px;
    margin-bottom: 12px;
    animation: bbc-fade-in 0.25s ease;
}

.bbc-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    background: var(--bbc-panel);
    border: 1.5px solid var(--bbc-border);
    color: var(--bbc-text);
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bbc-choice:hover,
.bbc-choice:focus {
    background: var(--bbc-accent-soft);
    border-color: var(--bbc-accent);
    color: var(--bbc-text);
    transform: translateY(-1px);
}

.bbc-choice__icon {
    font-size: 16px;
    line-height: 1;
}

/* Big icon-buttons (mode select, employment, etc) */

.bbc-choices--big {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-left: 0;
}

.bbc-choices--big .bbc-choice {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px 10px;
    border-radius: 12px;
    gap: 6px;
}

.bbc-choices--big .bbc-choice__icon {
    font-size: 26px;
}

.bbc-choices--4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 360px) {
    .bbc-choices--4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Amount chips */

.bbc-amount-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-left: 36px;
    margin-bottom: 8px;
}

.bbc-amount-chip {
    padding: 7px 12px;
    background: var(--bbc-panel);
    border: 1.5px solid var(--bbc-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--bbc-text);
    transition: all 0.15s ease;
}

.bbc-amount-chip:hover {
    background: var(--bbc-accent-soft);
    border-color: var(--bbc-accent);
}

/* Input area */

.bbc-modal__input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--bbc-border);
    background: var(--bbc-panel);
    flex-shrink: 0;
}

.bbc-modal__input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--bbc-border);
    border-radius: 999px;
    font: inherit;
    font-size: 15px;
    background: var(--bbc-bg);
    color: var(--bbc-text);
}

.bbc-modal__input-area input:focus {
    outline: none;
    border-color: var(--bbc-accent);
    background: var(--bbc-panel);
}

.bbc-modal__send {
    padding: 10px 18px;
    background: var(--bbc-accent);
    color: var(--bbc-text);
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bbc-modal__send:hover {
    background: var(--bbc-accent-dark);
}

/* Footer */

.bbc-modal__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid var(--bbc-border);
    background: var(--bbc-panel);
    flex-shrink: 0;
    font-size: 11px;
}

.bbc-modal__restart {
    background: transparent;
    border: 0;
    color: var(--bbc-text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    text-decoration: underline;
}

.bbc-modal__restart:hover {
    color: var(--bbc-accent-dark);
}

.bbc-modal__brand {
    color: var(--bbc-text-muted);
    font-size: 10px;
}

/* Offer card */

.bbc-offer {
    background: var(--bbc-panel);
    border: 1.5px solid var(--bbc-border);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.bbc-offer--best {
    border-color: var(--bbc-accent);
    background: var(--bbc-accent-soft);
}

.bbc-offer__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.bbc-offer__logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid var(--bbc-border);
}

.bbc-offer__name {
    font-weight: 800;
    font-size: 14px;
    color: var(--bbc-text);
    flex: 1;
    line-height: 1.2;
}

.bbc-offer__ad-badge {
    font-size: 9px;
    padding: 2px 6px;
    background: var(--bbc-text-muted);
    color: #fff;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.bbc-offer__suit {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bbc-offer__suit--high { background: rgba(56,161,105,0.15); color: var(--bbc-success); }
.bbc-offer__suit--medium { background: rgba(255,193,7,0.18); color: var(--bbc-accent-dark); }
.bbc-offer__suit--low { background: rgba(229,62,62,0.15); color: var(--bbc-danger); }

.bbc-offer__short {
    font-size: 12px;
    color: var(--bbc-text-secondary);
    margin: 0 0 8px;
    line-height: 1.4;
}

.bbc-offer__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    font-size: 11px;
    color: var(--bbc-text-secondary);
    margin-bottom: 10px;
}

.bbc-offer__meta b {
    color: var(--bbc-text);
    font-weight: 700;
}

.bbc-offer__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 14px;
    background: var(--bbc-accent);
    color: var(--bbc-text);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s ease;
}

.bbc-offer__cta:hover {
    background: var(--bbc-accent-dark);
    color: var(--bbc-text);
}

.bbc-offer:not(.bbc-offer--best) .bbc-offer__cta {
    background: var(--bbc-text);
    color: #fff;
}

.bbc-offer:not(.bbc-offer--best) .bbc-offer__cta:hover {
    background: #2D3748;
    color: #fff;
}

@media print {
    #bbc-chat { display: none !important; }
}
