/* ===== دستیار — سبک پنل مشاوره (websima-like) ===== */

.assistant {
    --as-dark: #1a1a1f;
    --as-dark-2: #252530;
    --as-surface: #ffffff;
    --as-bg: #f5f5f7;
    --as-text: #1a1a1f;
    --as-muted: #6b6b7b;
    --as-accent: #ef6c00;
    --as-accent-h: #e65100;
    --as-accent-soft: rgba(154, 112, 72, 0.12);
    --as-green: #22c55e;
    --as-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --as-spring: cubic-bezier(0.34, 1.2, 0.64, 1);
    --as-z: 300;
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--as-z);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Dock + Welcome (پایین وسط) — جایگزین نوار dock-bar ─── */
.assistant__dock {
    display: none;
}

.assistant__dock > * {
    pointer-events: auto;
}

.assistant__welcome {
    position: relative;
    width: min(320px, calc(100vw - 2.5rem));
    padding: 0.85rem 2.25rem 0.85rem 1rem;
    background: var(--as-surface);
    color: var(--as-text);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(154, 112, 72, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.4s var(--as-ease), transform 0.45s var(--as-spring), visibility 0.4s;
}

.assistant__welcome.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.assistant__welcome.is-dismissed,
.assistant.is-open .assistant__welcome {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
    pointer-events: none;
}

.assistant__welcome-text {
    font-size: 0.84rem;
    line-height: 1.65;
    font-weight: 500;
    min-height: 2.6em;
}

.assistant__welcome-text::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 0.9em;
    margin-inline-start: 2px;
    background: var(--as-accent);
    vertical-align: text-bottom;
    animation: asCursorBlink 0.9s step-end infinite;
}

.assistant__welcome.is-done .assistant__welcome-text::after {
    display: none;
}

@keyframes asCursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.assistant__welcome-close {
    position: absolute;
    top: 0.55rem;
    inset-inline-end: 0.55rem;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--as-bg);
    border: none;
    border-radius: 50%;
    color: var(--as-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.assistant__welcome-close:hover {
    background: var(--as-accent-soft);
    color: var(--as-accent);
}

.assistant__welcome-close svg {
    width: 14px;
    height: 14px;
}

.assistant__welcome-tail {
    position: absolute;
    bottom: -7px;
    left: 50%;
    width: 14px;
    height: 14px;
    background: var(--as-surface);
    border-right: 1px solid rgba(154, 112, 72, 0.18);
    border-bottom: 1px solid rgba(154, 112, 72, 0.18);
    transform: translateX(-50%) rotate(45deg);
}

.assistant__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.12rem;
    padding: 0.5rem 0.9rem;
    background: var(--as-dark);
    color: #fff;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    transition: opacity 0.35s var(--as-ease), transform 0.35s var(--as-spring);
    pointer-events: none;
}

.assistant__label strong {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.assistant__label span {
    font-size: 0.66rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.3;
    white-space: nowrap;
}

.assistant.is-open .assistant__label {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

/* ─── Trigger (دایره استوری اینستاگرام) ─── */
.assistant__trigger {
    --as-ring: 3px;
    --as-gap: 3px;
    position: relative;
    width: 64px;
    height: 64px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 6px 24px rgba(204, 35, 102, 0.28);
    transition: transform 0.35s var(--as-spring), box-shadow 0.35s var(--as-ease), opacity 0.35s;
}

.assistant__trigger:hover {
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 10px 32px rgba(204, 35, 102, 0.38);
}

.assistant__trigger:active {
    transform: translateY(-1px) scale(0.98);
}

.assistant.is-open .assistant__trigger {
    transform: translateY(calc(100% + 2rem));
    opacity: 0;
    pointer-events: none;
}

.assistant__trigger-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 200deg,
        #feda75,
        #fa7e1e,
        #d62976,
        #962fbf,
        #4f5bd5,
        #feda75
    );
    animation: asRingSpin 4s linear infinite;
}

.assistant__trigger-inner {
    position: absolute;
    inset: var(--as-ring);
    border-radius: 50%;
    padding: var(--as-gap);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant__trigger-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--as-dark) 0%, var(--as-dark-2) 100%);
    border-radius: 50%;
    color: #fff;
}

.assistant__trigger-icon svg {
    width: 26px;
    height: 26px;
}

@keyframes asRingSpin {
    to { transform: rotate(360deg); }
}

/* ─── Backdrop ─── */
.assistant__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s var(--as-ease), visibility 0.35s;
    pointer-events: none;
    z-index: calc(var(--as-z) + 1);
}

.assistant.is-open .assistant__backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ─── Panel (bottom sheet از وسط) ─── */
.assistant__panel {
    position: fixed;
    bottom: 0;
    left: 50%;
    width: min(420px, calc(100vw - 1.5rem));
    max-height: min(85vh, 720px);
    z-index: calc(var(--as-z) + 2);
    display: flex;
    flex-direction: column;
    background: var(--as-surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
    transform: translateX(-50%) translateY(100%);
    visibility: hidden;
    transition: transform 0.45s var(--as-spring), visibility 0.45s;
    pointer-events: auto;
    overflow: hidden;
}

.assistant.is-open .assistant__panel {
    transform: translateX(-50%) translateY(0);
    visibility: visible;
}

/* Header */
.assistant__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.15rem 1.15rem 1rem;
    background: var(--as-dark);
    color: #fff;
    flex-shrink: 0;
}

.assistant__head-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.assistant__head-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--as-accent), var(--as-accent-h));
    border-radius: 12px;
    flex-shrink: 0;
}

.assistant__head-icon svg {
    width: 24px;
    height: 24px;
}

.assistant__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.assistant__beta {
    padding: 0.15rem 0.45rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    font-size: 0.58rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
}

.assistant__subtitle {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 0.15rem;
}

.assistant__close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.assistant__close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.assistant__close svg {
    width: 18px;
    height: 18px;
}

/* Banner */
.assistant__banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    background: linear-gradient(90deg, var(--as-accent-soft), transparent);
    border-bottom: 1px solid rgba(154, 112, 72, 0.15);
    flex-shrink: 0;
    animation: asBannerIn 0.5s var(--as-spring) 0.2s both;
}

.assistant__banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--as-green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
    animation: asDotPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

.assistant__banner p {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--as-text);
}

@keyframes asBannerIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes asDotPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.1); }
}

/* Body */
.assistant__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--as-bg);
}

.assistant__messages {
    flex: 1;
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 120px;
}

.assistant__msg {
    display: flex;
    gap: 0.6rem;
    animation: asMsgIn 0.4s var(--as-spring) both;
}

.assistant__msg--user {
    flex-direction: row-reverse;
}

.assistant__msg-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--as-accent), var(--as-accent-h));
    border-radius: 50%;
    color: #fff;
}

.assistant__msg-avatar svg {
    width: 16px;
    height: 16px;
}

.assistant__msg--user .assistant__msg-avatar {
    background: var(--as-dark-2);
}

.assistant__msg-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 85%;
}

.assistant__msg--user .assistant__msg-content {
    align-items: flex-end;
}

.assistant__bubble {
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.6;
    background: var(--as-surface);
    color: var(--as-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.assistant__msg--user .assistant__bubble {
    background: var(--as-dark);
    color: #fff;
    border-color: transparent;
}

.assistant__bubble p + p {
    margin-top: 0.4rem;
}

.assistant__time {
    font-size: 0.65rem;
    color: var(--as-muted);
    padding-inline: 0.2rem;
}

/* Typing */
.assistant__typing {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: var(--as-surface);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-inline-start: 2.5rem;
}

.assistant__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--as-muted);
    animation: asTyping 1.2s ease-in-out infinite;
}

.assistant__typing span:nth-child(2) { animation-delay: 0.15s; }
.assistant__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes asTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

@keyframes asMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Part card */
.assistant__part {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem;
    background: var(--as-bg);
    border-radius: 12px;
    border: 1px solid rgba(154, 112, 72, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.assistant__part:hover {
    border-color: var(--as-accent);
    box-shadow: 0 4px 12px var(--as-accent-soft);
}

.assistant__part-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--as-accent-soft);
    border-radius: 10px;
    color: var(--as-accent);
    flex-shrink: 0;
}

.assistant__part-icon svg {
    width: 20px;
    height: 20px;
}

.assistant__part-body {
    flex: 1;
    min-width: 0;
}

.assistant__part-body strong {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--as-text);
}

.assistant__part-body span {
    font-size: 0.7rem;
    color: var(--as-muted);
}

.assistant__part-action {
    flex-shrink: 0;
    padding: 0.35rem 0.7rem;
    background: var(--as-accent);
    color: #fff;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    transition: background 0.2s;
}

.assistant__part-action:hover {
    background: var(--as-accent-h);
}

/* Quick buttons */
.assistant__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1.15rem 0.85rem;
    flex-shrink: 0;
}

.assistant__quick-btn {
    padding: 0.45rem 0.75rem;
    background: var(--as-surface);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 980px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--as-text);
    cursor: pointer;
    transition: all 0.22s var(--as-ease);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.assistant__quick-btn:hover {
    background: var(--as-accent);
    color: #fff;
    border-color: var(--as-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--as-accent-soft);
}

/* FAQ */
.assistant__faq {
    padding: 0 1.15rem 1rem;
    flex-shrink: 0;
}

.assistant__faq-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.assistant__faq-item summary {
    padding: 0.65rem 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--as-text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.assistant__faq-item summary::-webkit-details-marker { display: none; }

.assistant__faq-item summary::after {
    content: '+';
    font-size: 1rem;
    font-weight: 400;
    color: var(--as-muted);
    transition: transform 0.25s;
}

.assistant__faq-item[open] summary::after {
    transform: rotate(45deg);
}

.assistant__faq-item p {
    padding-bottom: 0.65rem;
    font-size: 0.75rem;
    line-height: 1.65;
    color: var(--as-muted);
}

/* Footer */
.assistant__foot {
    flex-shrink: 0;
    background: var(--as-surface);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0.75rem 1.15rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
}

.assistant__input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.45rem;
    padding: 0.35rem 0.35rem 0.35rem 0.75rem;
    background: var(--as-bg);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.assistant__input-row:focus-within {
    border-color: var(--as-accent);
    box-shadow: 0 0 0 3px var(--as-accent-soft);
}

.assistant__input {
    flex: 1;
    min-height: 36px;
    max-height: 80px;
    padding: 0.4rem 0;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--as-text);
}

.assistant__input::placeholder {
    color: var(--as-muted);
}

.assistant__send {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--as-accent);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

.assistant__send:disabled {
    opacity: 0.35;
    cursor: default;
}

.assistant__send:not(:disabled):hover {
    background: var(--as-accent-h);
}

.assistant__send:not(:disabled):active {
    transform: scale(0.94);
}

.assistant__send svg {
    width: 18px;
    height: 18px;
}

.assistant__contact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--as-dark);
    border-radius: 12px;
    color: #fff;
}

.assistant__contact-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.assistant__contact-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--as-accent);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.assistant__contact-info strong {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
}

.assistant__contact-info span {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
}

.assistant__contact-phones {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-shrink: 0;
}

.assistant__contact-call {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    background: var(--as-accent);
    color: #fff;
    border-radius: 980px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.assistant__contact-call:hover {
    background: var(--as-accent-h);
    transform: scale(1.03);
}

.assistant__contact-call svg {
    width: 14px;
    height: 14px;
}

/* ─── تبلت ─── */
@media (max-width: 768px) {
    .assistant__panel {
        width: min(100vw - 1.5rem, 400px);
        max-height: min(85vh, 640px);
    }

    .assistant__welcome {
        width: min(100%, calc(100vw - 2rem));
    }

    .assistant__quick {
        gap: 0.45rem;
    }

    .assistant__quick-btn {
        font-size: 0.76rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ─── موبایل ─── */
@media (max-width: 480px) {
    .assistant__panel {
        width: 100vw;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }

    .assistant__welcome {
        width: 100%;
    }

    .assistant__label strong {
        font-size: 0.76rem;
    }

    .assistant__label span {
        font-size: 0.62rem;
    }

    .assistant__trigger {
        width: 58px;
        height: 58px;
    }

    .assistant__trigger-icon svg {
        width: 24px;
        height: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .assistant__trigger-ring,
    .assistant__banner-dot,
    .assistant__msg,
    .assistant__typing span,
    .assistant__welcome-text::after { animation: none !important; }
    .assistant__panel,
    .assistant__trigger,
    .assistant__welcome { transition: none; }
}
