/* Explain: Styles for the floating chat button and conversation panel. */
/* ===== المساعد الذكي: زر محادثة عائم ولوحة محادثة ===== */

.chat-widget {
    position: fixed;
    z-index: 70;
    inset-block-end: 1.25rem;
    inset-inline-end: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    pointer-events: none;
}

.chat-widget > * {
    pointer-events: auto;
}

.chat-launcher {
    display: grid;
    width: 3.75rem;
    height: 3.75rem;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, #3a4048, var(--primary-color));
    box-shadow: 0 14px 34px rgba(43, 48, 55, 0.34);
    font-size: 1.35rem;
    cursor: pointer;
    transition: transform 240ms ease, box-shadow 240ms ease;
}

.chat-launcher:hover {
    box-shadow: 0 18px 42px rgba(43, 48, 55, 0.42);
    transform: translateY(-2px);
}

.chat-launcher-close {
    display: none;
}

.chat-widget.is-open .chat-launcher-open {
    display: none;
}

.chat-widget.is-open .chat-launcher-close {
    display: block;
}

.chat-panel {
    position: absolute;
    inset-block-end: calc(100% + 0.75rem);
    inset-inline-end: 0;
    display: none;
    width: min(23rem, calc(100vw - 2rem));
    max-height: min(74vh, 33rem);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(43, 48, 55, 0.14);
    border-radius: var(--radius-lg);
    background: #ffffff;
    box-shadow: 0 26px 64px rgba(20, 22, 26, 0.24);
}

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

.chat-panel-head {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: #ffffff;
    background: linear-gradient(135deg, #3a4048, var(--primary-color));
}

.chat-avatar {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 1rem;
}

.chat-panel-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.5;
}

.chat-panel-sub {
    margin-top: 0.1rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.72rem;
    line-height: 1.6;
}

.chat-close {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 220ms ease, border-color 220ms ease;
}

.chat-close:hover {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.22);
}

.chat-messages {
    display: flex;
    flex: 1;
    min-height: 9rem;
    flex-direction: column;
    gap: 0.7rem;
    overflow-y: auto;
    padding: 0.9rem;
    background: var(--surface-color);
    overscroll-behavior: contain;
}

.chat-row {
    display: flex;
}

.chat-row-bot {
    justify-content: flex-start;
}

.chat-row-user {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: 90%;
    padding: 0.6rem 0.85rem;
    border-radius: 1rem;
    font-size: 0.86rem;
    line-height: 1.95;
    text-align: start;
}

.chat-bubble p + p {
    margin-top: 0.45rem;
}

.chat-bubble-bot {
    border: 1px solid rgba(43, 48, 55, 0.12);
    border-end-start-radius: 0.35rem;
    color: var(--text-color);
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(20, 22, 26, 0.06);
}

.chat-bubble-user {
    border-end-end-radius: 0.35rem;
    color: #ffffff;
    background: var(--primary-color);
}

.chat-bubble.is-error {
    border-color: rgba(198, 44, 71, 0.4);
    color: #8f1f33;
    background: #fdf2f4;
}

.chat-cta {
    display: inline-flex;
    min-height: 2.6rem;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.7rem;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, #d4245c, var(--accent-color));
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.6;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(196, 31, 85, 0.32);
    transition: transform 220ms ease, box-shadow 220ms ease;
}

.chat-cta:hover {
    box-shadow: 0 14px 30px rgba(196, 31, 85, 0.42);
    transform: translateY(-1px);
}

.chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.8rem 0.9rem;
}

.chat-typing span {
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 999px;
    background: var(--text-muted);
    animation: chat-typing-bounce 1.1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-typing-bounce {
    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.chat-suggestions {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem;
    border-top: 1px solid rgba(43, 48, 55, 0.1);
    background: #ffffff;
}

.chat-suggestions.is-hidden {
    display: none;
}

.chat-chip {
    min-height: 2rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid rgba(43, 48, 55, 0.18);
    border-radius: 999px;
    color: var(--text-color);
    background: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.6;
    cursor: pointer;
    transition: border-color 200ms ease, color 200ms ease, background 200ms ease;
}

.chat-chip:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(196, 31, 85, 0.06);
}

.chat-form {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid rgba(43, 48, 55, 0.1);
    background: #ffffff;
}

.chat-input {
    min-width: 0;
    flex: 1;
    min-height: 2.75rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid rgba(43, 48, 55, 0.16);
    border-radius: 999px;
    color: var(--text-color);
    background: #f7f7f9;
    font-size: 0.85rem;
}

.chat-input:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(196, 31, 85, 0.14);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    place-items: center;
    border: 0;
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, #3a4048, var(--primary-color));
    cursor: pointer;
    transition: filter 200ms ease, opacity 200ms ease;
}

.chat-send:hover {
    filter: brightness(1.12);
}

.chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
    .chat-launcher,
    .chat-cta,
    .chat-close,
    .chat-chip,
    .chat-send {
        transition: none;
    }

    .chat-launcher:hover,
    .chat-cta:hover {
        transform: none;
    }

    .chat-typing span {
        opacity: 0.7;
        animation: none;
    }
}