﻿/* قسم "الأسئلة الأكثر شيوعاً" بالرئيسية (Shared/KhabeerFaq.razor): محادثة مع الخبير بألوان فاتحة */
/* بالكمبيوتر: الأسئلة عاليمين والمحادثة عاليسار. بالموبايل: المحادثة أول، وتحتها الأسئلة كأزرار رد سريع متل تطبيقات المحادثة */

.khfaq {
    --khfaq-ink: var(--sec-color);
    --khfaq-green: var(--pr-color);
    /* أخضر الهوية أغمق شوي مشان يبيّن عالأبيض */
    --khfaq-green-text: #3BA811;
    --khfaq-muted: #4E6463;
    --khfaq-line: rgba(0, 34, 33, 0.09);
    direction: rtl;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    width: min(var(--default-spacing), var(--default-max-spacing));
    margin-inline: auto;
    margin-top: 40px;
    padding: 70px 60px;
    border-radius: 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-areas:
        "head chat"
        "qs   chat";
    grid-template-rows: auto 1fr;
    column-gap: clamp(32px, 5vw, 72px);
    row-gap: 32px;
    align-items: start;
    color: var(--khfaq-ink);
    background:
        radial-gradient(60% 70% at 100% 0%, rgba(91, 225, 30, 0.16), transparent 70%),
        radial-gradient(50% 60% at 0% 100%, rgba(91, 225, 30, 0.12), transparent 70%),
        #F3F8EF;
}

/* شبكة خفيفة بالخلفية متل باقي أقسام الهوية، بس فاتحة */
.khfaq::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(0, 34, 33, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 34, 33, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    background-position: center;
    -webkit-mask-image: radial-gradient(70% 80% at 50% 40%, #000, transparent);
    mask-image: radial-gradient(70% 80% at 50% 40%, #000, transparent);
}

/* علامتين استفهام (؟) كبار وباهتين بالخلفية */
.khfaq-deco {
    position: absolute;
    z-index: -1;
    pointer-events: none;
    width: clamp(130px, 15vw, 210px);
}

.khfaq-deco svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    fill: none;
    stroke: rgba(91, 225, 30, 0.22);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.khfaq-deco circle {
    fill: rgba(91, 225, 30, 0.22);
    stroke: none;
    r: 10px;
}

.khfaq-deco-1 {
    top: 18px;
    right: -26px;
    rotate: 14deg;
}

.khfaq-deco-2 {
    bottom: -50px;
    left: 40%;
    rotate: -16deg;
    width: clamp(100px, 11vw, 150px);
}

.khfaq-deco-2 svg {
    stroke: rgba(0, 34, 33, 0.07);
}

.khfaq-deco-2 circle {
    fill: rgba(0, 34, 33, 0.07);
}

/* ---------- العنوان ---------- */

.khfaq-head {
    grid-area: head;
}

.khfaq-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    font-family: var(--kh-reg);
    font-size: 0.95rem;
    color: var(--khfaq-ink);
    background: #fff;
    border: 1px solid rgba(91, 225, 30, 0.45);
    box-shadow: 0 6px 18px -10px rgba(0, 34, 33, 0.3);
}

.khfaq-eyebrow::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--khfaq-green);
    box-shadow: 0 0 0 4px rgba(91, 225, 30, 0.2);
}

.khfaq-title {
    margin: 18px 0 0;
    font-family: var(--kh-bold);
    font-weight: normal;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.3;
    color: var(--khfaq-ink);
}

.khfaq-title span {
    color: var(--khfaq-green-text);
}

.khfaq-sub {
    margin: 10px 0 0;
    font-family: var(--kh-reg);
    font-size: clamp(1.02rem, 1.4vw, 1.2rem);
    color: var(--khfaq-muted);
}

/* ---------- الأسئلة ---------- */

.khfaq-qs {
    grid-area: qs;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.khfaq-chip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 0;
    padding: 15px 18px;
    border: 1px solid var(--khfaq-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--khfaq-ink);
    font-family: var(--kh-reg);
    font-size: 1.08rem;
    line-height: 1.5;
    text-align: right;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.3s ease;
}

.khfaq-chip:hover {
    border-color: rgba(91, 225, 30, 0.7);
    transform: translateX(-6px);
    box-shadow: 0 12px 24px -18px rgba(0, 34, 33, 0.45);
}

.khfaq-chip:focus-visible {
    outline: 2px solid var(--khfaq-green-text);
    outline-offset: 3px;
}

.khfaq-num {
    font-family: var(--kh-bold);
    font-size: 0.95rem;
    color: var(--khfaq-green-text);
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.khfaq-q-short {
    display: none;
}

/* دائرة صغيرة بتصير علامة صح لما ينسأل السؤال (متل بنود الفحص) */
.khfaq-tick {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 34, 33, 0.18);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.khfaq-tick svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: var(--khfaq-ink);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset 0.45s ease 0.1s;
}

.khfaq-chip.is-asked .khfaq-tick {
    background: var(--khfaq-green);
    border-color: var(--khfaq-green);
}

.khfaq-chip.is-asked .khfaq-tick svg {
    stroke-dashoffset: 0;
}

/* السؤال المفتوح هلق */
.khfaq-chip.is-current {
    background: var(--khfaq-ink);
    border-color: var(--khfaq-ink);
    color: #fff;
    box-shadow: 0 18px 30px -18px rgba(0, 34, 33, 0.7);
}

.khfaq-chip.is-current .khfaq-num {
    color: var(--khfaq-green);
}

/* ---------- المحادثة ---------- */

.khfaq-chat {
    grid-area: chat;
    position: relative;
    display: flex;
    flex-direction: column;
    height: clamp(560px, 70vh, 640px);
    border-radius: 28px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 34, 33, 0.06), 0 40px 80px -36px rgba(0, 34, 33, 0.4), 0 0 0 10px rgba(255, 255, 255, 0.5);
}

.khfaq-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--khfaq-line);
    background: #fff;
}

.khfaq-avatar {
    flex: none;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--khfaq-ink);
    box-shadow: 0 0 0 3px rgba(91, 225, 30, 0.25);
}

.khfaq-avatar svg {
    width: 30px;
    height: 30px;
}

.khfaq-who {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.khfaq-who b {
    font-family: var(--kh-bold);
    font-weight: normal;
    font-size: 1.15rem;
}

.khfaq-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--kh-reg);
    font-size: 0.88rem;
    color: var(--khfaq-muted);
}

.khfaq-status i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--khfaq-green);
}

.khfaq-log {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 34, 33, 0.18) transparent;
    background:
        radial-gradient(rgba(0, 34, 33, 0.07) 1px, transparent 1.3px) 0 0 / 18px 18px,
        #F7FAF5;
}

.khfaq-pair {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.khfaq-pair.is-shown {
    display: flex;
}

.khfaq-msg {
    max-width: 86%;
    margin: 0;
    padding: 12px 16px;
    border-radius: 18px;
    font-family: var(--kh-reg);
    font-weight: normal;
    font-size: 1.02rem;
    line-height: 1.75;
}

.khfaq-msg p {
    margin: 0;
}

.khfaq-msg p + p {
    margin-top: 6px;
}

/* رسائل الخبير عاليمين (بداية السطر بالعربي) */
.khfaq-bot {
    align-self: flex-start;
    background: #fff;
    color: #1B3332;
    border: 1px solid var(--khfaq-line);
    border-start-start-radius: 6px;
    box-shadow: 0 6px 16px -14px rgba(0, 34, 33, 0.5);
}

/* أسئلة الزائر عاليسار بأخضر الهوية */
.khfaq-me {
    align-self: flex-end;
    background: var(--khfaq-green);
    color: var(--khfaq-ink);
    border-start-end-radius: 6px;
    box-shadow: 0 10px 20px -14px rgba(59, 168, 17, 0.9);
}

.khfaq-pair:not(.is-answered) .khfaq-bot {
    display: none;
}

.khfaq-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.khfaq-list li {
    position: relative;
    padding: 8px 34px 8px 12px;
    border-radius: 12px;
    background: #F3F8EF;
}

.khfaq-list li::before {
    content: "";
    position: absolute;
    right: 10px;
    top: 15px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--khfaq-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23002221' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4L18 8'/%3E%3C/svg%3E") center / 10px no-repeat;
}

.khfaq-list b {
    font-family: var(--kh-bold);
    font-weight: normal;
    color: var(--khfaq-ink);
}

.khfaq-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.95rem;
    color: var(--khfaq-ink);
    background: rgba(91, 225, 30, 0.16);
    border: 1px solid rgba(91, 225, 30, 0.6);
    text-decoration: none;
    transition: background-color 0.25s ease;
}

.khfaq-link::after {
    content: "←";
    transition: transform 0.25s ease;
}

.khfaq-link:hover {
    background: var(--khfaq-green);
}

.khfaq-link:hover::after {
    transform: translateX(-3px);
}

/* "عم يكتب..." */
.khfaq-typing {
    display: none;
    gap: 5px;
    align-items: center;
    padding: 15px 18px;
}

.khfaq-typing.is-on {
    display: inline-flex;
}

.khfaq-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--khfaq-green-text);
    opacity: 0.35;
}

/* شريط الكتابة تحت: بياخد عواتساب */
.khfaq-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px;
    padding: 7px 7px 7px 7px;
    padding-inline-start: 18px;
    border-radius: 999px;
    background: #F1F5EE;
    border: 1px solid var(--khfaq-line);
    color: var(--khfaq-muted);
    font-family: var(--kh-reg);
    font-size: 0.98rem;
    text-decoration: none;
    transition: border-color 0.25s ease, background-color 0.25s ease;
}

.khfaq-input-text {
    flex: 1;
    min-width: 0;
}

.khfaq-input-short {
    display: none;
}

.khfaq-input:hover {
    border-color: rgba(91, 225, 30, 0.8);
    background: #fff;
}

.khfaq-send {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--khfaq-green);
}

.khfaq-send svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--khfaq-ink);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- التابلت والموبايل: المحادثة أول وتحتها الأسئلة كأزرار ---------- */

@media (max-width: 960px) {
    .khfaq {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "head"
            "chat"
            "qs";
        grid-template-rows: auto;
        row-gap: 22px;
        padding: 52px 28px 40px;
    }

    .khfaq-head {
        text-align: center;
    }

    .khfaq-chat {
        height: clamp(380px, 58svh, 500px);
        width: min(100%, 620px);
        justify-self: center;
    }

    .khfaq-qs {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .khfaq-chip {
        width: auto;
        display: inline-flex;
        gap: 8px;
        padding: 9px 12px 9px 16px;
        border-radius: 999px;
        font-size: 0.98rem;
    }

    .khfaq-chip:hover {
        transform: none;
    }

    .khfaq-num,
    .khfaq-q-full {
        display: none;
    }

    .khfaq-q-short {
        display: inline;
    }

    .khfaq-tick {
        width: 20px;
        height: 20px;
    }

    .khfaq-tick svg {
        width: 12px;
        height: 12px;
    }

    .khfaq-deco-2 {
        left: auto;
        right: 50%;
    }
}

@media (max-width: 600px) {
    .khfaq {
        padding: 40px 14px 28px;
    }

    .khfaq-chat {
        border-radius: 22px;
        box-shadow: 0 0 0 1px rgba(0, 34, 33, 0.06), 0 30px 60px -30px rgba(0, 34, 33, 0.4);
    }

    .khfaq-log {
        padding: 16px 12px;
    }

    .khfaq-msg {
        max-width: 92%;
        font-size: 0.98rem;
    }

    .khfaq-input {
        margin: 10px;
        font-size: 0.92rem;
    }

    .khfaq-input-long {
        display: none;
    }

    .khfaq-input-short {
        display: inline;
    }

    .khfaq-send {
        width: 36px;
        height: 36px;
    }
}

/* ---------- الحركة ---------- */

@keyframes khfaq-pop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.92);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes khfaq-in {
    from {
        opacity: 0;
        transform: translateY(10px);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

@keyframes khfaq-dot {
    0%, 60%, 100% {
        transform: none;
        opacity: 0.35;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@keyframes khfaq-float {
    from {
        translate: 0 0;
    }

    to {
        translate: 0 -18px;
    }
}

@keyframes khfaq-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(91, 225, 30, 0.6);
    }

    100% {
        box-shadow: 0 0 0 8px rgba(91, 225, 30, 0);
    }
}

@keyframes khfaq-rise {
    from {
        opacity: 0;
        translate: 0 36px;
    }

    to {
        opacity: 1;
        translate: none;
    }
}

@media (prefers-reduced-motion: no-preference) {

    .khfaq-pair.is-new .khfaq-me {
        animation: khfaq-pop 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
        transform-origin: left bottom;
    }

    .khfaq-pair.is-new.is-answered .khfaq-bot,
    .khfaq-typing.is-on {
        animation: khfaq-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }

    .khfaq-typing i {
        animation: khfaq-dot 1s ease-in-out infinite;
    }

    .khfaq-typing i:nth-child(2) {
        animation-delay: 0.15s;
    }

    .khfaq-typing i:nth-child(3) {
        animation-delay: 0.3s;
    }

    .khfaq-status i {
        animation: khfaq-pulse 1.8s ease-out infinite;
    }

    .khfaq-deco {
        animation: khfaq-float 7s ease-in-out infinite alternate;
    }

    .khfaq-deco-2 {
        animation-duration: 9s;
        animation-delay: -3s;
    }

    /* القسم بيطلع لما يوصل عالشاشة (بالمتصفحات يللي بتدعمها، والباقي بيبيّن عادي) */
    @supports (animation-timeline: view()) {
        .khfaq-head,
        .khfaq-chat,
        .khfaq-chip {
            animation: khfaq-rise linear both;
            animation-timeline: view();
            animation-range: entry 0% entry 70%;
        }

        .khfaq-chat {
            animation-range: entry 5% entry 80%;
        }

        .khfaq-chip:nth-child(2) { animation-range: entry 5% entry 75%; }
        .khfaq-chip:nth-child(3) { animation-range: entry 10% entry 80%; }
        .khfaq-chip:nth-child(4) { animation-range: entry 15% entry 85%; }
        .khfaq-chip:nth-child(5) { animation-range: entry 20% entry 90%; }
        .khfaq-chip:nth-child(6) { animation-range: entry 25% entry 95%; }
    }
}
