/* WhatsApp in-site chat widget + Sales Agent */

.whatsapp-widget {
    position: fixed;
    z-index: 70;
    right: 1.1rem;
    bottom: 1.1rem;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.75rem;
}

.whatsapp-float {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 1rem;
    border: 0;
    border-radius: 999px;
    background: #25d366;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(18, 140, 70, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.whatsapp-float:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(18, 140, 70, 0.42);
    color: #fff;
}

.whatsapp-float-icon {
    display: inline-flex;
    width: 1.55rem;
    height: 1.55rem;
}

.whatsapp-float-label {
    white-space: nowrap;
}

.whatsapp-panel {
    width: min(22.5rem, calc(100vw - 2rem));
    border-radius: 1.1rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.whatsapp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: #075e54;
    color: #fff;
}

.whatsapp-panel-identity {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.whatsapp-panel-avatar {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 999px;
    background: #25d366;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.whatsapp-panel-header strong {
    display: block;
    font-size: 0.98rem;
}

.whatsapp-panel-header p {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.82);
}

.whatsapp-panel-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.45rem;
    line-height: 1;
    cursor: pointer;
}

.whatsapp-panel-body {
    min-height: 9rem;
    max-height: 14rem;
    overflow: auto;
    padding: 1rem;
    background:
        linear-gradient(rgba(236, 229, 221, 0.92), rgba(236, 229, 221, 0.92)),
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 40%);
}

.whatsapp-bubble {
    max-width: 92%;
    padding: 0.7rem 0.85rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
    line-height: 1.45;
    background: #fff;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.whatsapp-bubble.is-team {
    border-top-left-radius: 0.25rem;
}

html[dir="rtl"] .whatsapp-bubble.is-team {
    border-top-left-radius: 0.85rem;
    border-top-right-radius: 0.25rem;
}

.whatsapp-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.whatsapp-chip {
    border: 1px solid #b7ebc6;
    background: #fff;
    color: #128c7e;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.whatsapp-panel-form {
    display: grid;
    gap: 0.5rem;
    padding: 0.85rem 1rem 1rem;
    background: #fff;
    border-top: 1px solid #e8eef5;
}

.whatsapp-panel-form input,
.whatsapp-panel-form textarea {
    width: 100%;
    border: 1px solid #d7deed;
    border-radius: 0.7rem;
    padding: 0.55rem 0.7rem;
    font: inherit;
    resize: vertical;
}

.whatsapp-send-btn {
    border: 0;
    border-radius: 0.75rem;
    background: #25d366;
    color: #fff;
    font-weight: 700;
    padding: 0.7rem 0.9rem;
    cursor: pointer;
}

.whatsapp-send-btn:hover {
    background: #1ebe57;
}

.sales-agent {
    position: fixed;
    z-index: 69;
    right: 1.1rem;
    bottom: 5.25rem;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.65rem;
}

.sales-agent-toggle {
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%);
    color: #fff;
    font-weight: 700;
    padding: 0.75rem 1.05rem;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.sales-agent-toggle-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    background: #34d399;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.18);
}

.sales-agent-panel {
    width: min(23rem, calc(100vw - 1.5rem));
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 1.15rem;
    background: #fff;
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.22);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(34rem, calc(100vh - 7rem));
}

.sales-agent-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #fff;
}

.sales-agent-header-copy {
    min-width: 0;
}

.sales-agent-header p {
    margin: 0.25rem 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.35;
}

.sales-agent-close {
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.sales-agent-messages {
    flex: 1 1 auto;
    min-height: 12rem;
    max-height: none;
    overflow: auto;
    padding: 0.9rem 1rem;
    display: grid;
    gap: 0.55rem;
    background:
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.sales-agent-bubble {
    max-width: 92%;
    padding: 0.7rem 0.85rem;
    border-radius: 0.95rem;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.sales-agent-bubble.is-bot {
    background: #fff;
    border: 1px solid #e2e8f0;
    justify-self: start;
    border-top-left-radius: 0.35rem;
}

.sales-agent-bubble.is-user {
    background: #2563eb;
    color: #fff;
    justify-self: end;
    border-top-right-radius: 0.35rem;
}

.sales-agent-source {
    font-size: 0.7rem;
    color: #64748b;
    justify-self: start;
    margin-top: -0.15rem;
}

.sales-agent-topics {
    border-top: 1px solid #e8eef5;
    background: #fff;
}

.sales-agent-topics-toggle {
    width: 100%;
    border: 0;
    background: #fff;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.sales-agent-suggestions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding: 0 1rem 0.65rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.sales-agent-chip {
    border: 1px solid #dbe3f0;
    background: #f8fafc;
    border-radius: 999px;
    padding: 0.32rem 0.7rem;
    font-size: 0.72rem;
    cursor: pointer;
    color: #334155;
    white-space: nowrap;
    flex: 0 0 auto;
}

.sales-agent-handoff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0;
}

.sales-agent-handoff.is-active {
    animation: sales-handoff-pulse 1.2s ease;
}

.sales-agent-handoff.is-active .btn-primary,
.sales-agent-handoff.is-active .btn-secondary {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.sales-agent-handoff [data-sales-agent-whatsapp].is-preferred,
.sales-agent-handoff [data-sales-agent-demo].is-preferred {
    outline: 2px solid #25d366;
    outline-offset: 2px;
}

.sales-agent-handoff [data-sales-agent-demo].is-preferred {
    outline-color: #2563eb;
}

@keyframes sales-handoff-pulse {
    0% { transform: translateY(0); }
    40% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}

.sales-agent-handoff .btn-primary,
.sales-agent-handoff .btn-secondary {
    text-align: center;
    font-size: 0.82rem;
    padding: 0.55rem 0.4rem;
}

.sales-agent-form {
    display: flex;
    gap: 0.45rem;
    padding: 0.85rem 1rem 1rem;
}

.sales-agent-form input {
    flex: 1;
    border: 1px solid #d7deed;
    border-radius: 0.7rem;
    padding: 0.55rem 0.7rem;
}

.sales-agent-form button {
    border: 0;
    border-radius: 0.7rem;
    background: #2563eb;
    color: #fff;
    font-weight: 700;
    padding: 0.55rem 0.8rem;
    cursor: pointer;
}

.btn-cta-secondary {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
}

.timetable-demo-placeholder {
    border-style: dashed;
}

html[dir="rtl"] .whatsapp-widget {
    right: auto;
    left: 1.1rem;
}

html[dir="rtl"] .sales-agent {
    right: auto;
    left: 1.1rem;
}

html[dir="rtl"] .sales-agent-bubble.is-user {
    justify-self: start;
}

html[dir="rtl"] .sales-agent-bubble.is-bot {
    justify-self: end;
}

@media (max-width: 640px) {
    .whatsapp-float-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .whatsapp-float {
        padding: 0.9rem;
        border-radius: 999px;
    }

    .sales-agent {
        bottom: 4.85rem;
        right: 1rem;
    }

    html[dir="rtl"] .sales-agent {
        left: 1rem;
    }
}
