/* Site-wide AI chat assistant. Logical properties throughout so it mirrors
   correctly under dir="rtl" without a separate stylesheet. */

/* Stacked above the WhatsApp chat widget (public/assets — loaded separately
   from web.layouts.app.blade.php, bottom:50px/right:50px, ~50px tall), not
   beside it — there is only one bottom-right corner on a phone screen. */
.ai-assistant {
    position: fixed;
    inset-block-end: 112px;
    inset-inline-end: 24px;
    z-index: 1070;
    font-family: inherit;
}

.ai-assistant__bubble {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #75418F 0%, #39004E 100%);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 10px 25px rgba(57, 0, 78, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-assistant__bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(57, 0, 78, 0.45);
}

.ai-assistant__bubble .bi-x-lg { display: none; }
.ai-assistant.is-open .ai-assistant__bubble .bi-chat-dots-fill { display: none; }
.ai-assistant.is-open .ai-assistant__bubble .bi-x-lg { display: inline-block; }

.ai-assistant__badge {
    position: absolute;
    inset-block-start: -2px;
    inset-inline-end: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #36D399;
    border: 2px solid #fff;
}

.ai-assistant__panel {
    position: absolute;
    inset-block-end: 74px;
    inset-inline-end: 0;
    width: min(370px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 120px));
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 55px rgba(17, 12, 34, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ai-assistant.is-open .ai-assistant__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai-assistant__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #39004E 0%, #75418F 100%);
    color: #fff;
    flex-shrink: 0;
}

.ai-assistant__header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.ai-assistant__header-text { flex-grow: 1; min-width: 0; }
.ai-assistant__header-title { font-weight: 800; font-size: 0.95rem; margin: 0; }
.ai-assistant__header-sub { font-size: 0.72rem; opacity: 0.85; margin: 0; }

.ai-assistant__close {
    background: none;
    border: none;
    color: #fff;
    opacity: 0.85;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
}
.ai-assistant__close:hover { opacity: 1; }

.ai-assistant__messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.ai-assistant__msg { max-width: 86%; display: flex; flex-direction: column; gap: 4px; }
.ai-assistant__msg--user { align-self: flex-end; align-items: flex-end; }
.ai-assistant__msg--assistant { align-self: flex-start; align-items: flex-start; }

.ai-assistant__bubble-text {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-assistant__msg--user .ai-assistant__bubble-text {
    background: linear-gradient(135deg, #75418F 0%, #9A6BB3 100%);
    color: #fff;
    border-end-end-radius: 4px;
}

.ai-assistant__msg--assistant .ai-assistant__bubble-text {
    background: #fff;
    color: #1f2430;
    border: 1px solid #eef0f4;
    border-end-start-radius: 4px;
}

.ai-assistant__results { display: flex; flex-direction: column; gap: 6px; width: 100%; }

.ai-assistant__card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid #eef0f4;
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.ai-assistant__card:hover { border-color: #c9a6e0; background: rgba(117, 65, 143, 0.03); color: inherit; }

.ai-assistant__card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(117, 65, 143, 0.08);
    color: #75418F;
    font-size: 0.85rem;
}

.ai-assistant__card-body { min-width: 0; }
.ai-assistant__card-title { font-size: 0.78rem; font-weight: 700; color: #1f2430; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-assistant__card-reason { font-size: 0.7rem; color: #6b7280; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ai-assistant__suggested { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; flex-shrink: 0; }

.ai-assistant__chip {
    border: 1px solid #e3e6ed;
    background: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #75418F;
    cursor: pointer;
    transition: all 0.15s ease;
}
.ai-assistant__chip:hover { background: rgba(117, 65, 143, 0.08); }

.ai-assistant__typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.ai-assistant__typing span {
    width: 6px; height: 6px; border-radius: 50%; background: #c9a6e0;
    animation: aiAssistantTyping 1s infinite ease-in-out;
}
.ai-assistant__typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-assistant__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiAssistantTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ai-assistant__form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-block-start: 1px solid #eef0f4;
    background: #fff;
    flex-shrink: 0;
}

.ai-assistant__input {
    flex-grow: 1;
    border: 1px solid #e3e6ed;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.83rem;
    outline: none;
}
.ai-assistant__input:focus { border-color: #9A6BB3; box-shadow: 0 0 0 0.15rem rgba(117, 65, 143, 0.12); }

.ai-assistant__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #75418F 0%, #9A6BB3 100%);
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
}
.ai-assistant__send:disabled { opacity: 0.5; cursor: default; }

.ai-assistant__hp { position: absolute; opacity: 0; height: 0; width: 0; overflow: hidden; pointer-events: none; }

@media (max-width: 480px) {
    .ai-assistant { inset-block-end: 100px; inset-inline-end: 16px; }
    .ai-assistant__panel { inset-inline-end: -6px; }
}
