.psfm-ai-assistant {
    position: fixed;
    right: 18px;
    bottom: 92px;
    z-index: 9990;
    font-family: "Roboto", "Arial", sans-serif;
}

.psfm-ai-assistant[dir="rtl"] {
    right: auto;
    left: 18px;
    font-family: "Tahoma", "Arial", sans-serif;
}

.psfm-ai-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 10px 18px 10px 12px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #e31e24, #b9151a);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 18px 42px rgba(7, 23, 44, 0.24);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.psfm-ai-launcher:hover,
.psfm-ai-assistant.is-open .psfm-ai-launcher {
    transform: translateY(-2px);
    box-shadow: 0 22px 54px rgba(7, 23, 44, 0.3);
}

.psfm-ai-assistant[dir="rtl"] .psfm-ai-launcher {
    padding: 10px 12px 10px 18px;
}

.psfm-ai-launcher-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
}

.psfm-ai-panel {
    position: absolute;
    right: 0;
    bottom: 68px;
    width: min(390px, calc(100vw - 28px));
    max-height: min(720px, calc(100vh - 130px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    background: #ffffff;
    border: 1px solid rgba(7, 23, 44, 0.1);
    box-shadow: 0 28px 80px rgba(7, 23, 44, 0.28);
}

.psfm-ai-assistant[dir="rtl"] .psfm-ai-panel {
    right: auto;
    left: 0;
}

.psfm-ai-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    background: linear-gradient(135deg, #07172c, #102847);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.psfm-ai-header::after {
    content: "";
    position: absolute;
    inset-inline: 18px;
    bottom: 0;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, #0f7a3a, #d7b56d, #e31e24);
    opacity: 0.9;
}

.psfm-ai-header strong {
    display: block;
    color: #fff;
    font-size: 1rem;
}

.psfm-ai-header span {
    display: block;
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.82rem;
    line-height: 1.45;
    margin-top: 3px;
}

.psfm-ai-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
}

.psfm-ai-messages {
    display: grid;
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    min-height: 160px;
    max-height: 260px;
    background: #f8fafc;
}

.psfm-ai-message {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 16px;
    color: #172033;
    background: #fff;
    border: 1px solid rgba(7, 23, 44, 0.08);
    line-height: 1.55;
    font-size: 0.91rem;
    white-space: pre-wrap;
}

.psfm-ai-message.is-user {
    justify-self: end;
    background: #e31e24;
    color: #fff;
    border-color: #e31e24;
}

.psfm-ai-assistant[dir="rtl"] .psfm-ai-message.is-user {
    justify-self: start;
}

.psfm-ai-message.is-status {
    color: #64748b;
    font-size: 0.82rem;
}

.psfm-ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px 0;
    background: #fff;
}

.psfm-ai-quick-actions button {
    border: 1px solid rgba(7, 23, 44, 0.1);
    border-radius: 999px;
    background: #fff;
    color: #07172c;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 7px 10px;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.psfm-ai-quick-actions button:hover,
.psfm-ai-quick-actions button:focus-visible {
    background: #07172c;
    border-color: #07172c;
    color: #fff;
    transform: translateY(-1px);
}

.psfm-ai-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 8px;
    padding: 14px 16px 16px;
    background: #fff;
}

.psfm-ai-input-row textarea,
.psfm-ai-lead-form input,
.psfm-ai-lead-form select,
.psfm-ai-lead-form textarea {
    width: 100%;
    border: 1px solid rgba(7, 23, 44, 0.12);
    border-radius: 14px;
    padding: 10px 12px;
    color: #07172c;
    background: #fff;
    font-size: 0.88rem;
    outline: none;
}

.psfm-ai-input-row textarea:focus,
.psfm-ai-lead-form input:focus,
.psfm-ai-lead-form select:focus,
.psfm-ai-lead-form textarea:focus {
    border-color: rgba(227, 30, 36, 0.48);
    box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.08);
}

.psfm-ai-input-row button {
    border: 0;
    border-radius: 14px;
    background: #e31e24;
    color: #fff;
    cursor: pointer;
}

.psfm-ai-lead-form {
    display: grid;
    gap: 10px;
    padding: 14px 16px 16px;
    border-top: 1px solid rgba(7, 23, 44, 0.08);
    background: #fff;
    overflow-y: auto;
}

.psfm-ai-lead-form[hidden],
.psfm-ai-panel[hidden] {
    display: none;
}

.psfm-ai-lead-form strong {
    color: #07172c;
}

.psfm-ai-lead-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.psfm-ai-lead-grid input:nth-child(1),
.psfm-ai-lead-grid input:nth-child(3),
.psfm-ai-lead-grid input:nth-child(4),
.psfm-ai-lead-grid input:nth-child(5) {
    grid-column: 1 / -1;
}

.psfm-ai-lead-submit {
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #07172c, #102847);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.psfm-ai-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(7, 23, 44, 0.08);
    background: #f8fafc;
}

.psfm-ai-footer a {
    color: #e31e24;
    font-weight: 800;
    font-size: 0.83rem;
}

@media (max-width: 575.98px) {
    .psfm-ai-assistant,
    .psfm-ai-assistant[dir="rtl"] {
        right: 14px;
        left: 14px;
        bottom: 84px;
    }

    .psfm-ai-launcher {
        margin-inline-start: auto;
        min-height: 50px;
        padding-inline: 12px;
    }

    .psfm-ai-assistant[dir="rtl"] .psfm-ai-launcher {
        margin-inline-start: 0;
        margin-inline-end: auto;
    }

    .psfm-ai-panel,
    .psfm-ai-assistant[dir="rtl"] .psfm-ai-panel {
        left: 0;
        right: 0;
        width: 100%;
        bottom: 62px;
        max-height: min(430px, calc(100vh - 250px));
        border-radius: 18px;
    }

    .psfm-ai-header {
        padding: 14px;
    }

    .psfm-ai-header strong {
        font-size: 0.94rem;
    }

    .psfm-ai-header span {
        font-size: 0.76rem;
    }

    .psfm-ai-messages {
        min-height: 92px;
        max-height: 145px;
        padding: 12px;
    }

    .psfm-ai-message {
        max-width: 94%;
        padding: 9px 11px;
        font-size: 0.84rem;
        line-height: 1.45;
    }

    .psfm-ai-quick-actions {
        gap: 6px;
        padding: 10px 12px 0;
    }

    .psfm-ai-quick-actions button {
        font-size: 0.72rem;
        padding: 6px 8px;
    }

    .psfm-ai-input-row {
        grid-template-columns: minmax(0, 1fr) 42px;
        padding: 12px;
    }

    .psfm-ai-footer {
        padding: 10px 12px;
    }

    .psfm-ai-lead-form {
        max-height: 300px;
        padding: 12px;
    }

    .psfm-ai-assistant.is-auto-opened .psfm-ai-panel {
        animation: psfmAiPanelIn 220ms ease-out both;
    }

    .psfm-ai-assistant.is-home-page.is-auto-opened .psfm-ai-panel {
        max-height: 258px;
        overflow-y: auto;
    }

    .psfm-ai-assistant.is-home-page.is-auto-opened .psfm-ai-messages {
        min-height: 70px;
        max-height: 82px;
    }

    .psfm-ai-assistant.is-home-page.is-auto-opened .psfm-ai-quick-actions {
        max-height: 100px;
        overflow-y: auto;
        padding-bottom: 10px;
    }

    .psfm-ai-assistant.is-home-page.is-auto-opened .psfm-ai-input-row,
    .psfm-ai-assistant.is-home-page.is-auto-opened .psfm-ai-footer {
        display: none;
    }
}

@keyframes psfmAiPanelIn {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .psfm-ai-launcher,
    .psfm-ai-quick-actions button,
    .psfm-ai-assistant.is-auto-opened .psfm-ai-panel {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}
