/* ═══════════════════════════════════════════════════════════
   RAYKA LIVE CHAT WIDGET
   ═══════════════════════════════════════════════════════════ */
.rayka-chat {
    --c-orange: #F97316;
    --c-orange-deep: #EA580C;
    --c-amber: #FBBF24;
    --c-red: #DC2626;
    --c-ink: #1C1917;
    --c-paper: #FFFBF5;
    --c-line: #F1E6D8;
    --c-muted: #9A8B78;
    --grad-brand: linear-gradient(135deg, #FBBF24 0%, #F97316 55%, #EA580C 100%);
    --shadow-panel: 0 28px 70px -16px rgba(124, 45, 18, 0.4);
    --font: 'Vazirmatn', -apple-system, sans-serif;

    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    font-family: var(--font);
}

/* ═══════════════ دکمه شناور ═══════════════ */
.chat-fab {
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50% 50% 50% 18px;
    background: var(--grad-brand);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px -6px rgba(234, 88, 12, 0.55);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    z-index: 2;
}

.chat-fab:hover {
    transform: scale(1.08) rotate(-6deg);
    box-shadow: 0 14px 34px -6px rgba(234, 88, 12, 0.65);
}

.chat-fab-pulse {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid rgba(249, 115, 22, 0.6);
    animation: fabPulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes fabPulse {
    0%   { transform: scale(1); opacity: 0.8; }
    70%, 100% { transform: scale(1.55); opacity: 0; }
}

.chat-fab-icon, .chat-fab-close {
    position: absolute;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.chat-fab-close { opacity: 0; transform: rotate(-90deg) scale(0.5); }

.rayka-chat.is-open .chat-fab-icon { opacity: 0; transform: rotate(90deg) scale(0.5); }
.rayka-chat.is-open .chat-fab-close { opacity: 1; transform: rotate(0) scale(1); }
.rayka-chat.is-open .chat-fab-pulse { display: none; }

.chat-fab-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 9999px;
    background: var(--c-red);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: badgeBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgeBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ═══════════════ پنل ═══════════════ */
.chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--c-paper);
    border-radius: 22px 22px 22px 6px;
    box-shadow: var(--shadow-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px) scale(0.92);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s;
}

.rayka-chat.is-open .chat-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ═══════════════ هدر ═══════════════ */
.chat-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 18px;
    background: var(--grad-brand);
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

/* بافت هاف‌تون چاپخانه */
.chat-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.6px);
    background-size: 11px 11px;
    pointer-events: none;
}

/* نوار کالیبراسیون رنگ CMYK */
.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        #00AEEF 0 20%, #EC008C 20% 40%, #FFF200 40% 58%,
        #1C1917 58% 72%, #FFFFFF 72% 100%);
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.chat-avatar {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 14px 14px 14px 4px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--c-orange-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-avatar-status {
    position: absolute;
    bottom: -2px;
    left: -2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #22C55E;
    border: 2.5px solid #fff;
    animation: statusPulse 2s ease-out infinite;
}

.chat-avatar-status.is-offline { background: #A8A29E; animation: none; }

@keyframes statusPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70%, 100% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.chat-header-info { display: flex; flex-direction: column; gap: 2px; }

.chat-header-info strong {
    font-size: 1.0625rem;
    font-weight: 900;
    letter-spacing: -0.01em;
}

.chat-header-info span {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.92;
}

.chat-minimize {
    position: relative;
    z-index: 1;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.chat-minimize:hover { background: rgba(255, 255, 255, 0.32); transform: translateY(2px); }

/* ═══════════════ مراحل ═══════════════ */
.chat-step {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    animation: stepIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-step.is-active { display: flex; }

@keyframes stepIn {
    from { opacity: 0; transform: translateX(-14px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ═══════════════ مرحله خوش‌آمد ═══════════════ */
.chat-step-welcome {
    padding: 16px;
    overflow-y: auto;
    gap: 14px;
}

.chat-welcome-hero {
    position: relative;
    background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
    border: 1.5px solid #FED7AA;
    border-radius: 16px 16px 16px 5px;
    padding: 16px;
    overflow: hidden;
}

.chat-welcome-hero::before {
    content: '';
    position: absolute;
    top: -30px;
    left: -30px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.35), transparent 70%);
    pointer-events: none;
}

.chat-welcome-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px 13px 13px 4px;
    background: var(--grad-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    margin-bottom: 10px;
    box-shadow: 0 5px 14px rgba(234, 88, 12, 0.35);
}

.chat-welcome-hero h3 {
    margin: 0 0 6px;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--c-ink);
    letter-spacing: -0.01em;
}

.chat-welcome-hero p {
    margin: 0 0 10px;
    font-size: 0.8125rem;
    line-height: 1.8;
    color: #6B5D4C;
}

.chat-welcome-hero p strong { color: var(--c-orange-deep); font-weight: 800; }

.chat-hours {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #FED7AA;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #B45309;
}

.chat-hours i { font-size: 0.625rem; }

.chat-faqs-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--c-muted);
}

.chat-faqs-label i { color: var(--c-orange); }

.chat-faqs { display: flex; flex-direction: column; gap: 8px; }

.chat-faq-loading {
    text-align: center;
    padding: 14px;
    color: var(--c-orange);
    font-size: 1.125rem;
}

.chat-faq {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    background: #fff;
    border: 1.5px solid var(--c-line);
    border-radius: 13px 13px 13px 4px;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 700;
    color: #44403C;
    text-align: right;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: stepIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.chat-faq:nth-child(1) { animation-delay: 0.05s; }
.chat-faq:nth-child(2) { animation-delay: 0.12s; }
.chat-faq:nth-child(3) { animation-delay: 0.19s; }

.chat-faq i {
    color: var(--c-orange);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.chat-faq:hover {
    border-color: #FDBA74;
    background: linear-gradient(135deg, #FFF7ED, #fff);
    transform: translateX(-4px);
    box-shadow: 0 6px 16px rgba(234, 88, 12, 0.12);
}

.chat-faq:hover i { transform: translateX(-3px); }

.chat-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 14px 14px 14px 5px;
    background: var(--grad-brand);
    color: #fff;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 22px -6px rgba(234, 88, 12, 0.5);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    margin-top: auto;
}

.chat-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -6px rgba(234, 88, 12, 0.6);
}

.chat-start-btn i { transition: transform 0.3s ease; }
.chat-start-btn:hover i { transform: rotate(-12deg) scale(1.15); }

/* ═══════════════ مرحله فرم ═══════════════ */
.chat-step-form {
    padding: 20px 16px;
    overflow-y: auto;
}

.chat-form-wrap { text-align: center; }

.chat-form-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px 18px 18px 6px;
    background: var(--grad-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    margin: 0 auto 14px;
    box-shadow: 0 8px 22px -6px rgba(234, 88, 12, 0.5);
}

.chat-form-wrap h3 {
    margin: 0 0 6px;
    font-size: 1.125rem;
    font-weight: 900;
    color: var(--c-ink);
}

.chat-form-wrap > p {
    margin: 0 0 18px;
    font-size: 0.8125rem;
    color: var(--c-muted);
    line-height: 1.7;
}

.chat-field { margin-bottom: 14px; text-align: right; }

.chat-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #57534E;
}

.chat-input-wrap { position: relative; }

.chat-input-wrap > i {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #C9B8A3;
    font-size: 0.875rem;
    pointer-events: none;
    transition: color 0.2s ease;
}

.chat-input-wrap input {
    width: 100%;
    height: 46px;
    padding: 0 40px 0 14px;
    background: #fff;
    border: 1.5px solid var(--c-line);
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--c-ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.chat-input-wrap input::placeholder { color: #C9B8A3; }

.chat-input-wrap input:focus {
    border-color: var(--c-orange);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.12);
}

.chat-input-wrap input:focus + i,
.chat-input-wrap:focus-within > i { color: var(--c-orange); }

.chat-input-wrap.has-error input {
    border-color: var(--c-red);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
}

.chat-field-error {
    display: block;
    margin-top: 5px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--c-red);
    min-height: 14px;
}

.chat-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 14px 14px 14px 5px;
    background: var(--grad-brand);
    color: #fff;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 22px -6px rgba(234, 88, 12, 0.5);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.chat-submit-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -6px rgba(234, 88, 12, 0.6); }
.chat-submit-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.chat-back-link {
    margin-top: 12px;
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--c-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.chat-back-link:hover { color: var(--c-orange-deep); }

/* ═══════════════ مرحله گفتگو ═══════════════ */
.chat-step-chat { position: relative; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-image: radial-gradient(rgba(234, 88, 12, 0.045) 1px, transparent 1.4px);
    background-size: 16px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(249, 115, 22, 0.3) transparent;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(249, 115, 22, 0.3); border-radius: 99px; }

/* ── حباب پیام ── */
.chat-msg {
    display: flex;
    max-width: 82%;
    animation: msgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(12px) scale(0.92); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* پیام مشتری — سمت چپ (RTL) */
.chat-msg-customer { align-self: flex-end; }

.chat-msg-customer .chat-bubble {
    background: var(--grad-brand);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.28);
}

/* پیام پشتیبانی — سمت راست (RTL) */
.chat-msg-admin { align-self: flex-start; }

.chat-msg-admin .chat-bubble {
    background: #fff;
    color: #3F3A34;
    border: 1.5px solid var(--c-line);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 3px 10px rgba(124, 45, 18, 0.07);
}

.chat-bubble {
    padding: 10px 14px;
    font-size: 0.8125rem;
    line-height: 1.8;
    word-break: break-word;
}

.chat-bubble-time {
    display: block;
    margin-top: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    opacity: 0.7;
    text-align: left;
}

/* پیام سیستم — وسط */
.chat-msg-system {
    align-self: center;
    max-width: 94%;
}

.chat-msg-system .chat-bubble {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 1px solid #FCD34D;
    color: #92400E;
    border-radius: 12px;
    font-size: 0.75rem;
    text-align: center;
    padding: 9px 14px;
}

/* ── در حال نوشتن ── */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 8px;
    font-size: 0.6875rem;
    color: var(--c-muted);
    flex-shrink: 0;
}

.chat-typing-dots { display: inline-flex; gap: 3px; }

.chat-typing-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--c-orange);
    animation: typingDot 1.2s ease-in-out infinite;
}

.chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── قفل کامپوزر ── */
.chat-composer-lock {
    padding: 12px 16px;
    background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
    border-top: 1.5px solid #FED7AA;
    text-align: center;
    flex-shrink: 0;
}

.chat-composer-lock p {
    margin: 0 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #B45309;
}

.chat-composer-lock p i { margin-left: 4px; }

.chat-unlock-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: 9999px;
    background: var(--grad-brand);
    color: #fff;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 5px 16px -4px rgba(234, 88, 12, 0.5);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-unlock-btn:hover { transform: translateY(-2px) scale(1.03); }

/* ── کامپوزر ── */
.chat-composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1.5px solid var(--c-line);
    flex-shrink: 0;
}

.chat-composer input {
    flex: 1;
    height: 42px;
    padding: 0 14px;
    background: var(--c-paper);
    border: 1.5px solid var(--c-line);
    border-radius: 9999px;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--c-ink);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-composer input:focus {
    border-color: var(--c-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50% 50% 50% 14px;
    background: var(--grad-brand);
    color: #fff;
    font-size: 0.9375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 5px 14px -4px rgba(234, 88, 12, 0.55);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-send-btn:hover { transform: scale(1.1) rotate(-10deg); }
.chat-send-btn:active { transform: scale(0.95); }

.chat-send-btn i { transform: scaleX(-1); } /* آیکون ارسال برای RTL */

/* ═══════════════ ریسپانسیو ═══════════════ */
@media (max-width: 480px) {
    .rayka-chat { bottom: 16px; right: 16px; }

    .chat-panel {
        position: fixed;
        top: auto;
        right: 10px;
        left: 10px;
        bottom: 90px;
        width: auto;
        height: 72vh;
        max-height: 72vh;
        z-index:98px ;
    }

    .chat-fab { width: 56px; height: 56px; font-size: 1.375rem; bottom: 70px; }
}

/* ═══════════════ دسترس‌پذیری ═══════════════ */
@media (prefers-reduced-motion: reduce) {
    .rayka-chat *, .rayka-chat *::before, .rayka-chat *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ═══════════════ پیام خوش‌آمد ═══════════════ */
.chat-greeting {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: stepIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-greeting-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px 12px 12px 4px;
    background: var(--grad-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 5px 14px rgba(234, 88, 12, 0.32);
}

.chat-greeting-bubble {
    position: relative;
    background: #fff;
    border: 1.5px solid var(--c-line);
    border-radius: 16px 4px 16px 16px;
    padding: 12px 14px;
    box-shadow: 0 4px 14px rgba(124, 45, 18, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.chat-greeting-bubble strong {
    font-size: 0.875rem;
    font-weight: 900;
    color: var(--c-ink);
    letter-spacing: -0.01em;
}

.chat-greeting-bubble > span:not(.chat-hours) {
    font-size: 0.8125rem;
    line-height: 1.8;
    color: #6B5D4C;
}

.chat-greeting-bubble .chat-hours {
    align-self: flex-start;
    margin-top: 2px;
}

/* ═══════════════ رفع باگ hidden (بسیار مهم) ═══════════════ */
.rayka-chat [hidden] { display: none !important; }

/* ═══════════════ نوار ابزار چت ═══════════════ */
.chat-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: #fff;
    border-bottom: 1.5px solid var(--c-line);
    flex-shrink: 0;
}

.chat-toolbar-title {
    flex: 1;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 800;
    color: var(--c-ink);
}

.chat-tool-btn {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--c-line);
    border-radius: 10px;
    background: #fff;
    color: var(--c-orange-deep);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-tool-btn:hover {
    background: #FFF7ED;
    border-color: #FDBA74;
    transform: translateY(-1px);
}

.chat-tool-close:hover {
    background: #FEF2F2;
    border-color: #FCA5A5;
    color: #DC2626;
}

/* ═══════════════ اعلان بسته شدن ═══════════════ */
.chat-closed-notice {
    padding: 18px 16px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-top: 1.5px solid #FCD34D;
    text-align: center;
    flex-shrink: 0;
}

.chat-closed-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    color: #B45309;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    margin: 0 auto 10px;
}

.chat-closed-title {
    margin: 0 0 6px;
    font-size: 0.875rem;
    font-weight: 900;
    color: #92400E;
}

.chat-closed-desc {
    margin: 0 0 12px;
    font-size: 0.75rem;
    line-height: 1.8;
    color: #A16207;
}

.chat-closed-desc a {
    color: #B45309;
    font-weight: 800;
    text-decoration: none;
    border-bottom: 1.5px dashed #D97706;
}

.chat-new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    border: none;
    border-radius: 9999px;
    background: var(--grad-brand);
    color: #fff;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 16px -4px rgba(234, 88, 12, 0.5);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-new-chat-btn:hover { transform: translateY(-2px) scale(1.03); }

/* ═══════════════ گفتگوهای اخیر ═══════════════ */
.chat-recent-wrap { margin-top: 2px; }

.chat-recent {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.chat-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: #fff;
    border: 1.5px solid var(--c-line);
    border-radius: 12px 12px 12px 4px;
    font-family: var(--font);
    text-align: right;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-recent-item:hover {
    border-color: #FDBA74;
    transform: translateX(-3px);
    box-shadow: 0 5px 14px rgba(234, 88, 12, 0.1);
}

.chat-recent-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #A8A29E;
}

.chat-recent-item.is-open .chat-recent-dot {
    background: #22C55E;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.chat-recent-body { flex: 1; min-width: 0; }

.chat-recent-preview {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--c-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-recent-time {
    display: block;
    font-size: 0.625rem;
    color: var(--c-muted);
    margin-top: 2px;
}

.chat-recent-arrow { color: #C9B8A3; font-size: 0.6875rem; flex-shrink: 0; }


/* ═══════════════ مودال تأیید بستن ═══════════════ */
.rayka-chat [hidden] { display: none !important; }

.chat-confirm {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border-radius: inherit;
    overflow: hidden;
}

.chat-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 25, 23, 0.55);
    backdrop-filter: blur(3px);
}

.chat-confirm-dialog {
    position: relative;
    width: 100%;
    max-width: 280px;
    background: #FFFFFF;
    border-radius: 18px 18px 18px 6px;
    padding: 22px 20px;
    text-align: center;
    box-shadow: 0 20px 50px -10px rgba(124, 45, 18, 0.4);
    animation: confirmIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes confirmIn {
    from { opacity: 0; transform: scale(0.85) translateY(14px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.chat-confirm-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    color: #B45309;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin: 0 auto 12px;
}

.chat-confirm-dialog h4 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 900;
    color: #1C1917;
}

.chat-confirm-dialog p {
    margin: 0 0 16px;
    font-size: 0.8125rem;
    color: #7C6F5C;
    line-height: 1.7;
}

.chat-confirm-actions {
    display: flex;
    gap: 9px;
}

.chat-confirm-cancel {
    flex: 1;
    padding: 10px;
    border: 1.5px solid #F1E6D8;
    border-radius: 11px;
    background: #FFFFFF;
    color: #7C6F5C;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-confirm-cancel:hover { background: #FAF7F2; border-color: #C9B8A3; }

.chat-confirm-ok {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 11px 11px 11px 4px;
    background: linear-gradient(135deg, #F87171, #DC2626);
    color: #FFFFFF;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 5px 14px -3px rgba(220, 38, 38, 0.45);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-confirm-ok:hover { transform: translateY(-2px); }


/* ═══════════════ فوتر حالت سوالات متداول ═══════════════ */
.chat-faq-footer {
    padding: 16px;
    background: #FFFFFF;
    border-top: 1.5px solid var(--c-line);
    text-align: center;
    flex-shrink: 0;
}

.chat-faq-footer-hint {
    margin: 0 0 11px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--c-muted);
}

.chat-faq-footer .chat-start-btn {
    width: 100%;
    margin-top: 0;
}

/* ═══════════════ اسکرول welcome: فعال ولی نوار مخفی ═══════════════ */
.chat-step-welcome {
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE/Edge قدیم */
}
.chat-step-welcome::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;                  /* Chrome/Safari/Opera */
}
/* توجه: .chat-messages دست نخورده و اسکرول‌بار خودش را حفظ می‌کند */

/* ═══════════════ نقطه وضعیت: دور (away) ═══════════════ */
.chat-avatar-status.is-away {
    background: #F59E0B;
    animation: awayPulse 2.4s ease-in-out infinite;
}

@keyframes awayPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
}

/* ═══════════════ فاصله دکمه شناور از نوار پایین (موبایل) ═══════════════ */
@media (max-width: 640px) {
    .chat-fab {
        bottom: 100px;
    }
}