/* Baalveda chat widget — matches appointment form & site aesthetic */
.chat-widget {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10000;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--text, #1d2745);
}

.chat-widget * {
    box-sizing: border-box;
}

/* Closed: bubble (matches .btn-primary) */
.chat-bubble {
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--brand, #ef4a64), var(--brand-dark, #1a2f7f));
    box-shadow: var(--shadow-md, 0 12px 30px rgba(26, 47, 127, 0.16));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.chat-bubble:hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow: var(--shadow-lg, 0 20px 45px rgba(26, 47, 127, 0.22));
}

.chat-bubble:focus-visible {
    outline: 2px solid rgba(239, 74, 100, 0.45);
    outline-offset: 3px;
}

.chat-bubble svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.chat-bubble[hidden] {
    display: none;
}

/* Open panel — same card language as .appointment-form */
.chat-panel {
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 100px);
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border, #ebdce2);
    border-radius: var(--radius, 18px);
    box-shadow: var(--shadow-md, 0 12px 30px rgba(26, 47, 127, 0.16));
    animation: chatSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.chat-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(239, 74, 100, 0.95), rgba(26, 47, 127, 0.95));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.55;
    pointer-events: none;
    z-index: 0;
}

.chat-panel.is-open {
    display: flex;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header — matches .page-header gradient */
.chat-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    background: linear-gradient(135deg, #172a6f, #ef4a64);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-header-info h3 {
    font-family: "Playfair Display", serif;
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.25;
    color: #fff;
}

.chat-header-info p {
    font-size: 0.78rem;
    margin: 0.25rem 0 0;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.88);
}

.chat-close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    line-height: 1;
    transition: all 0.25s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}

/* Messages — site background tone */
.chat-messages {
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background:
        linear-gradient(180deg, rgba(255, 220, 228, 0.18), rgba(250, 247, 248, 0.35)),
        var(--bg, #faf7f8);
}

.chat-message {
    max-width: 90%;
    padding: 0.7rem 0.95rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.55;
    word-wrap: break-word;
}

/* Bot bubble — info-card style */
.chat-message.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text, #1d2745);
    border: 1px solid var(--border, #ebdce2);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm, 0 6px 18px rgba(26, 47, 127, 0.1));
}

/* User bubble — primary button gradient */
.chat-message.user {
    align-self: flex-end;
    color: #fff;
    border: none;
    border-bottom-right-radius: 4px;
    background: linear-gradient(135deg, var(--brand, #ef4a64), var(--brand-dark, #1a2f7f));
    box-shadow: var(--shadow-sm, 0 6px 18px rgba(26, 47, 127, 0.1));
}

.chat-message a {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-message.bot a {
    color: var(--brand-dark, #1a2f7f);
}

.chat-message.user a {
    color: #fff;
}

/* Quick replies — eyebrow / hero-pill style */
.chat-quick-replies {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0 1rem 0.65rem;
    background: var(--bg, #faf7f8);
}

.chat-quick-btn {
    border: 1px solid var(--border, #ebdce2);
    background: rgba(255, 220, 228, 0.55);
    color: var(--brand-dark, #1a2f7f);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 0.38rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
}

.chat-quick-btn:hover {
    background: var(--brand-soft, #ffdce4);
    border-color: rgba(239, 74, 100, 0.45);
    transform: translateY(-1px);
}

/* Input row — matches .form-group inputs */
.chat-input-area {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0.55rem;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid var(--border, #ebdce2);
    background: rgba(255, 255, 255, 0.98);
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border, #ebdce2);
    border-radius: 12px;
    background: #fbfefe;
    padding: 0.75rem 0.9rem;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text, #1d2745);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input::placeholder {
    color: var(--muted, #656c86);
}

.chat-input:focus {
    border-color: var(--brand, #ef4a64);
    outline: 2px solid rgba(239, 74, 100, 0.32);
}

.chat-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    background: linear-gradient(135deg, var(--brand, #ef4a64), var(--brand-dark, #1a2f7f));
    box-shadow: var(--shadow-sm, 0 6px 18px rgba(26, 47, 127, 0.1));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-send:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md, 0 12px 30px rgba(26, 47, 127, 0.16));
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

@media (max-width: 480px) {
    .chat-widget {
        right: 14px;
        bottom: 14px;
    }

    .chat-panel {
        width: calc(100vw - 28px);
        height: min(72vh, 520px);
    }

    .chat-bubble {
        width: 54px;
        height: 54px;
    }
}
