/* ============================================================
   ЧАТ-БОТ ВАЛЕНТИНЫ — стили виджета v2
   Автооткрытие + экспресс-заявка + MAX
   ============================================================ */

:root {
    --cb-gold: #d4af37;
    --cb-gold-light: #f9e79f;
    --cb-gold-dark: #aa771c;
    --cb-bg-dark: #0f0c29;
    --cb-bg-purple: #1a0b2e;
    --cb-bubble-bot: #182533;
    --cb-chat-bg: #0e1621;
    --cb-text: #d1d1d1;
    --cb-text-dim: #6c7883;
    --cb-max: #9b59b6;
}

/* ---------- КНОПКА-ТРИГГЕР ---------- */
.cb-trigger {
    position: fixed;
    left: 30px;
    bottom: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-dark));
    border: none;
    cursor: pointer;
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: cbPulse 3s ease-in-out infinite;
}
.cb-trigger.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}
.cb-trigger:hover { transform: scale(1.1) rotate(5deg); animation: none; }
.cb-trigger svg { width: 27px; height: 27px; color: var(--cb-bg-dark); }

@keyframes cbPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4); }
    50% { box-shadow: 0 4px 28px rgba(212, 175, 55, 0.7); }
}

/* ---------- ОКНО ЧАТА ---------- */
.cb-window {
    position: fixed;
    left: 30px;
    bottom: 30px;
    width: 370px;
    height: 540px;
    max-height: calc(100vh - 60px);
    z-index: 9996;
    background: var(--cb-chat-bg);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transform: translateY(25px) scale(0.95);
    transform-origin: bottom left;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.cb-window.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Шапка */
.cb-header {
    background: rgba(26, 11, 46, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding: 14px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.cb-header::before, .cb-header::after {
    content: '✦';
    position: absolute;
    color: rgba(212, 175, 55, 0.35);
    font-size: 11px;
    animation: cbSparkle 4s ease-in-out infinite;
    pointer-events: none;
}
.cb-header::before { top: 10px; right: 110px; }
.cb-header::after { bottom: 10px; right: 140px; animation-delay: 2s; }
@keyframes cbSparkle {
    0%, 100% { opacity: 0.1; transform: scale(0.8); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

.cb-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--cb-gold);
    object-fit: cover;
    flex-shrink: 0;
}
.cb-header-info { flex: 1; min-width: 0; }
.cb-header-name {
    font-family: 'Playfair Display', serif;
    color: var(--cb-gold);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}
.cb-header-status {
    color: var(--cb-text-dim);
    font-size: 10.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.cb-status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #25D366;
    box-shadow: 0 0 5px #25D366;
    animation: cbBlink 2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes cbBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Кнопка-молния «Сразу заявку» в шапке */
.cb-header-cta {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.25s;
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.35);
    animation: cbCtaGlow 2.5s ease-in-out infinite;
}
.cb-header-cta:hover { transform: scale(1.12) rotate(-8deg); animation: none; }
.cb-header-cta svg { width: 16px; height: 16px; color: var(--cb-bg-dark); }
.cb-header-cta.hidden { display: none; }
@keyframes cbCtaGlow {
    0%, 100% { box-shadow: 0 2px 10px rgba(212, 175, 55, 0.35); }
    50% { box-shadow: 0 2px 18px rgba(212, 175, 55, 0.7); }
}

.cb-close-btn {
    background: none;
    border: none;
    color: var(--cb-text-dim);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 2px;
    transition: color 0.3s, transform 0.3s;
    font-weight: 300;
    flex-shrink: 0;
}
.cb-close-btn:hover { color: var(--cb-gold); transform: rotate(90deg); }

/* Прогресс-бар */
.cb-progress {
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.cb-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cb-gold-dark), var(--cb-gold), var(--cb-gold-light));
    transition: width 0.6s ease;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

/* Тело чата */
.cb-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overscroll-behavior: contain;
}
.cb-body::-webkit-scrollbar { width: 5px; }
.cb-body::-webkit-scrollbar-track { background: transparent; }
.cb-body::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.5); border-radius: 3px; }

/* Сообщения */
.cb-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: cbMsgIn 0.35s ease-out;
    align-items: flex-end;
}
@keyframes cbMsgIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.cb-msg.bot { align-self: flex-start; }
.cb-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.cb-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(212, 175, 55, 0.6);
    object-fit: cover;
    flex-shrink: 0;
}

.cb-bubble {
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}
.cb-msg.bot .cb-bubble {
    background: var(--cb-bubble-bot);
    color: #e6edf3;
    border-radius: 14px 14px 14px 4px;
}
.cb-msg.user .cb-bubble {
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-dark));
    color: var(--cb-bg-dark);
    font-weight: 600;
    border-radius: 14px 14px 4px 14px;
}

/* Индикатор набора */
.cb-typing {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    align-self: flex-start;
    animation: cbMsgIn 0.3s ease-out;
}
.cb-typing-bubble {
    background: var(--cb-bubble-bot);
    border-radius: 14px 14px 14px 4px;
    padding: 13px 16px;
    display: flex;
    gap: 4px;
}
.cb-typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--cb-gold);
    animation: cbTyping 1.2s ease-in-out infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cbTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- ЧИПЫ ---------- */
.cb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    animation: cbMsgIn 0.35s ease-out;
    padding-left: 36px;
}
.cb-chip {
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.5);
    color: var(--cb-gold);
    font-family: 'Montserrat', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    padding: 9px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cb-chip svg { width: 15px; height: 15px; }
.cb-chip:hover {
    background: var(--cb-gold);
    color: var(--cb-bg-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}
/* Акцентный чип «Сразу заявку» */
.cb-chip.accent {
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-dark));
    color: var(--cb-bg-dark);
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
}
.cb-chip.accent:hover {
    background: linear-gradient(135deg, var(--cb-gold-light), var(--cb-gold));
    transform: translateY(-2px);
}
/* Чип мессенджеров — фирменные цвета при hover */
.cb-chip svg.tg-ic { color: #0088cc; }
.cb-chip svg.wa-ic { color: #25D366; }
.cb-chip svg.max-ic { color: var(--cb-max); }
.cb-chip:hover svg.tg-ic,
.cb-chip:hover svg.wa-ic,
.cb-chip:hover svg.max-ic { color: currentColor; }

/* ---------- ФУТЕР ---------- */
.cb-footer {
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding: 12px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: rgba(14, 22, 33, 0.9);
}
.cb-input {
    flex: 1;
    min-width: 0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 22px;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 13.5px;
    padding: 11px 16px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.cb-input:focus {
    border-color: var(--cb-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}
.cb-input::placeholder { color: #5a6a7a; }

.cb-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-gold), var(--cb-gold-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.25s;
}
.cb-send-btn:hover { transform: scale(1.08); box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4); }
.cb-send-btn svg { width: 17px; height: 17px; color: var(--cb-bg-dark); }

.cb-hint {
    font-size: 10.5px;
    color: var(--cb-text-dim);
    text-align: center;
    padding: 0 12px 8px;
    flex-shrink: 0;
}

/* ---------- КАРТА ДНЯ ---------- */
.cb-card-gift {
    align-self: center;
    width: 85%;
    background: linear-gradient(160deg, rgba(212, 175, 55, 0.12), rgba(212, 175, 55, 0.03));
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 14px;
    padding: 20px 16px;
    text-align: center;
    animation: cbCardIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-top: 6px;
}
@keyframes cbCardIn {
    from { opacity: 0; transform: rotateY(90deg) scale(0.7); }
    to { opacity: 1; transform: rotateY(0) scale(1); }
}
.cb-card-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--cb-gold);
    margin-bottom: 4px;
}
.cb-card-symbol {
    font-family: 'Playfair Display', serif;
    font-size: 38px;
    color: var(--cb-gold);
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    margin-bottom: 6px;
    line-height: 1.2;
}
.cb-card-name {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    color: #fff;
    margin-bottom: 10px;
}
.cb-card-text {
    font-size: 13px;
    color: var(--cb-text);
    font-style: italic;
    line-height: 1.5;
}

/* ---------- ПРЯМЫЕ ССЫЛКИ ---------- */
.cb-direct-links {
    display: flex;
    gap: 7px;
    justify-content: center;
    padding: 4px 0 6px;
    flex-wrap: wrap;
    animation: cbMsgIn 0.35s ease-out;
}
.cb-direct-link {
    text-decoration: none;
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    padding: 8px 13px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s;
}
.cb-direct-link svg { width: 14px; height: 14px; }
.cb-direct-link.tg { background: #0088cc; }
.cb-direct-link.tg:hover { background: #0077b3; transform: translateY(-2px); }
.cb-direct-link.wa { background: #25D366; }
.cb-direct-link.wa:hover { background: #1da851; transform: translateY(-2px); }
.cb-direct-link.max { background: var(--cb-max); }
.cb-direct-link.max:hover { background: #80449a; transform: translateY(-2px); }
.cb-direct-link.call { background: #00b894; }
.cb-direct-link.call:hover { background: #009377; transform: translateY(-2px); }

/* ---------- АДАПТИВ ---------- */
@media (max-width: 768px) {
    .cb-trigger { left: 20px; bottom: 20px; width: 55px; height: 55px; }
    .cb-window {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        height: 78vh;
        max-height: 78vh;
    }
    .cb-msg { max-width: 92%; }
    .cb-chips { padding-left: 0; }
    .cb-header-status { font-size: 9.5px; }
}
@media (max-width: 380px) {
    .cb-direct-link { font-size: 10.5px; padding: 7px 10px; }
}