/* Survanta public website floating support chat. Native website look (not dashboard),
   responsive, RTL-safe. No CDN, no inline styles. */

/* Placement: English (LTR) = bottom-left, Arabic (RTL) = bottom-right.
   inset-inline-start resolves to left in LTR and right in RTL. */
.svf-chat-launcher {
    position: fixed;
    inset-inline-start: 24px;
    inset-block-end: 24px;
    z-index: 1080;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 55%, #14b8a6 140%);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.svf-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45);
}

.svf-chat-launcher__icon {
    font-size: 1.2rem;
    line-height: 1;
}

.svf-chat-panel {
    position: fixed;
    inset-inline-start: 24px;
    inset-block-end: 88px;
    z-index: 1081;
    width: 370px;
    max-width: calc(100vw - 32px);
    /* Open at the full intended chat-box size, not collapsed to content. */
    height: 520px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

/* Responsive: near-fullscreen sheet on small screens. */
@media (max-width: 480px) {
    /* This stylesheet is only emitted when chat is enabled, so reserve space only when the launcher exists. */
    .account-page {
        padding-block-end: calc(6rem + env(safe-area-inset-bottom, 0px));
    }

    .svf-chat-launcher {
        inset-inline-start: 12px;
        inset-block-end: 12px;
        width: 48px;
        height: 48px;
        justify-content: center;
        padding: 0;
    }

    .svf-chat-launcher > span:last-child {
        display: none;
    }

    .svf-chat-panel {
        inset-inline-start: 16px;
        inset-inline-end: 16px;
        inset-block-end: 16px;
        width: auto;
        height: calc(100vh - 88px);
        max-height: none;
    }
}

.svf-chat-panel.is-open {
    display: flex;
}

.svf-chat-panel__header {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 60%, #14b8a6 150%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.svf-chat-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.svf-chat-panel__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.svf-chat-panel__body {
    padding: 16px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.svf-chat-gate {
    text-align: center;
    padding: 12px 4px;
}

.svf-chat-gate__text {
    margin-bottom: 14px;
    color: #475569;
}

.svf-chat-gate__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.svf-chat-btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid #2563eb;
}

.svf-chat-btn--primary {
    background: #2563eb;
    color: #fff;
}

.svf-chat-btn--ghost {
    background: #fff;
    color: #2563eb;
}

.svf-chat-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.svf-chat-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.svf-chat-msg--mine {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.svf-chat-msg--theirs {
    align-self: flex-start;
    background: #f1f5f9;
    color: #0f172a;
    border-bottom-left-radius: 4px;
}

.svf-chat-msg__sender {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    opacity: 0.8;
    margin-bottom: 2px;
}

.svf-chat-panel__footer {
    border-top: 1px solid #e2e8f0;
    padding: 10px;
    display: flex;
    gap: 8px;
}

.svf-chat-input {
    flex: 1 1 auto;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    resize: none;
}

.svf-chat-send {
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    padding: 0 14px;
    font-weight: 600;
    cursor: pointer;
}

.svf-chat-status {
    font-size: 0.8rem;
    color: #64748b;
    padding: 4px 2px;
}

[dir="rtl"] .svf-chat-msg--mine {
    align-self: flex-start;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .svf-chat-msg--theirs {
    align-self: flex-end;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

/* Assistant robot visual (anonymous gate + authenticated welcome). */
.svf-chat-robot {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.svf-chat-robot svg {
    animation: svf-robot-bob 3s ease-in-out infinite;
    transform-origin: 50% 100%;
}

.svf-robot-eye {
    animation: svf-robot-blink 4s ease-in-out infinite;
    transform-origin: center;
}

@keyframes svf-robot-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes svf-robot-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.1); }
}

@media (prefers-reduced-motion: reduce) {
    .svf-chat-robot svg,
    .svf-robot-eye { animation: none; }
}

.svf-chat-welcome {
    text-align: center;
    padding: 6px 4px 14px;
    border-bottom: 1px solid #eef2f7;
    margin-bottom: 12px;
}

.svf-chat-welcome__text {
    margin: 0;
    font-weight: 700;
    color: #0f172a;
}

/* Category-first flow: the input and category grid are mutually exclusive. The compose footer stays
   hidden until the user has an open conversation or has picked a category (panel.svf-input-ready). */
.svf-chat-panel:not(.svf-input-ready) .svf-chat-panel__footer {
    display: none;
}

.svf-chat-panel.svf-input-ready #svfChatCategories {
    display: none;
}

.svf-chat-categories {
    padding: 4px 2px 8px;
}

.svf-chat-categories__label {
    margin: 0 0 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    text-align: center;
}

.svf-chat-categories__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.svf-chat-cat {
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
    color: #1e40af;
    font: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 12px 10px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.svf-chat-cat:hover {
    transform: translateY(-1px);
    border-color: #2563eb;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18);
}

/* Post-close rating prompt. */
.svf-chat-rating {
    border-top: 1px solid #eef2f7;
    padding: 12px 4px 4px;
    text-align: center;
}

.svf-chat-rating__prompt {
    margin: 0 0 8px;
    font-weight: 700;
    color: #0f172a;
}

.svf-chat-rating__stars {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 10px;
}

.svf-chat-star {
    border: none;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.12s ease, transform 0.12s ease;
}

.svf-chat-star:hover {
    transform: scale(1.1);
}

.svf-chat-star--on {
    color: #f59e0b;
}

.svf-chat-rating__comment {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    resize: none;
    margin-bottom: 10px;
}

.svf-chat-rating__submit {
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 60%, #14b8a6 150%);
    color: #fff;
    padding: 9px 18px;
    font-weight: 600;
    cursor: pointer;
}

.svf-chat-rating__thanks {
    margin: 8px 0 0;
    font-weight: 600;
    color: #14b8a6;
}
