/* ============ تنظیمات رنگ (اینجا رو تغییر بدید) ============ */
:root{
    --brand-1: #F47A20;          /* رنگ اصلی نارنجی */
    --brand-2: #D65E0B;          /* نسخه تیره‌تر برای گرادیان */
    --chat-bg: #f8f9fc;
    --text: #1f2333;
    --muted: #8b90a5;
    --border: #e9ecf5;
  
    /* رنگ‌های کمکی مشتق‌شده از نارنجی برای سایه و حاشیه */
    --brand-1-rgb: 244, 122, 32;
    --brand-2-rgb: 214, 94, 11;
  }
  
  *{ box-sizing: border-box; }
  
  /* ============ کانتینر اصلی ویجت ============ */
  .support-widget{
    position: fixed;
    bottom: 24px;
    left: 24px;          /* اگر راست می‌خواید: left را حذف و right: 24px بگذارید */
    z-index: 99999;
    direction: rtl;
    font-family: Vazirmatn, Tahoma, sans-serif;
  }
  
  /* ============ دکمه دایره‌ای ============ */
  .chat-toggle{
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    box-shadow: 0 12px 28px -8px rgba(var(--brand-2-rgb), .75);
    transition: transform .25s ease, box-shadow .25s ease;
  }
  .chat-toggle:hover{
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 18px 34px -8px rgba(var(--brand-2-rgb), .85);
  }
  .chat-toggle:active{ transform: scale(.96); }
  
  /* حلقه پالس */
  .chat-toggle::after{
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(var(--brand-1-rgb), .55);
    animation: pulse 2.2s infinite;
  }
  .support-widget.open .chat-toggle::after{ animation: none; }
  
  @keyframes pulse{
    70%  { box-shadow: 0 0 0 18px rgba(var(--brand-1-rgb), 0); }
    100% { box-shadow: 0 0 0 0   rgba(var(--brand-1-rgb), 0); }
  }
  
  /* آیکون‌ها */
  .chat-toggle svg{
    position: absolute;
    width: 28px; height: 28px;
    transition: opacity .2s ease, transform .3s ease;
  }
  .icon-close{ opacity: 0; transform: rotate(-90deg) scale(.4); }
  .support-widget.open .icon-chat{ opacity: 0; transform: rotate(90deg) scale(.4); }
  .support-widget.open .icon-close{ opacity: 1; transform: rotate(0) scale(1); }
  
  /* نشان پیام خوانده‌نشده */
  .chat-badge{
    position: absolute;
    top: -2px; right: -2px;
    min-width: 22px; height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #ff4d6d;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: grid;
    place-items: center;
    border: 2px solid #fff;
    box-shadow: 0 3px 8px rgba(255,77,109,.5);
  }
  
  /* ============ پنجره چت ============ */
  .chat-window{
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 372px;
    height: 560px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 28px 70px -14px rgba(80, 45, 20, .35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(22px) scale(.94);
    transform-origin: bottom left;
    transition: opacity .3s ease, transform .35s cubic-bezier(.22,1,.36,1), visibility .3s;
  }
  .support-widget.open .chat-window{
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
  }
  
  /* ---------- هدر ---------- */
  .chat-header{
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 14px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  }
  .chat-avatar{
    position: relative;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: grid;
    place-items: center;
    flex-shrink: 0;
  }
  .chat-avatar svg{ width: 22px; height: 22px; }
  .chat-avatar::after{
    content: "";
    position: absolute;
    bottom: 1px; left: 1px;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid var(--brand-2);
  }
  .chat-head-info{ flex: 1; min-width: 0; }
  .chat-head-info h3{
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 700;
  }
  .chat-head-info span{
    font-size: 11.5px;
    opacity: .88;
    display: block;
  }
  .chat-close{
    width: 32px; height: 32px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,.15);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .2s;
  }
  .chat-close:hover{ background: rgba(255,255,255,.3); }
  .chat-close svg{ width: 16px; height: 16px; }
  
  /* ---------- بدنه پیام‌ها ---------- */
  .chat-body{
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
  }
  .chat-body::-webkit-scrollbar{ width: 6px; }
  .chat-body::-webkit-scrollbar-track{ background: transparent; }
  .chat-body::-webkit-scrollbar-thumb{
    background: #e3d5c8;
    border-radius: 10px;
  }
  
  /* حباب پیام */
  .msg{
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.85;
    white-space: pre-line;
    word-wrap: break-word;
    animation: msgIn .28s cubic-bezier(.22,1,.36,1);
  }
  @keyframes msgIn{
    from{ opacity: 0; transform: translateY(10px); }
  }
  .msg.bot{
    align-self: flex-start;
    background: #fff;
    color: var(--text);
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 10px rgba(80, 45, 20, .07);
  }
  .msg.user{
    align-self: flex-end;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    color: #fff;
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 14px -4px rgba(var(--brand-2-rgb), .6);
  }
  
  /* انیمیشن سه‌نقطه (در حال تایپ) */
  .typing{
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 16px;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 10px rgba(80, 45, 20, .07);
    animation: msgIn .28s ease;
  }
  .typing span{
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #e0c6b0;
    animation: bounce 1.3s infinite ease-in-out;
  }
  .typing span:nth-child(2){ animation-delay: .18s; }
  .typing span:nth-child(3){ animation-delay: .36s; }
  @keyframes bounce{
    0%, 60%, 100%{ transform: translateY(0); opacity: .5; }
    30%          { transform: translateY(-6px); opacity: 1; }
  }
  
  /* ---------- پاسخ‌های سریع ---------- */
  .quick-replies{
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0 14px 10px;
    background: var(--chat-bg);
  }
  .quick-reply{
    padding: 7px 13px;
    border-radius: 20px;
    border: 1px solid #fbdcc2;
    background: #fff;
    color: var(--brand-2);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: all .2s;
  }
  .quick-reply:hover{
    background: var(--brand-2);
    color: #fff;
    border-color: var(--brand-2);
  }
  
  /* ---------- فوتر / ورودی ---------- */
  .chat-footer{
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid var(--border);
  }
  .chat-footer input{
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f5f6fa;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    outline: none;
    transition: all .2s;
  }
  .chat-footer input::placeholder{ color: var(--muted); }
  .chat-footer input:focus{
    background: #fff;
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3.5px rgba(var(--brand-1-rgb), .18);
  }
  .chat-send{
    flex-shrink: 0;
    width: 45px; height: 45px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    box-shadow: 0 6px 16px -6px rgba(var(--brand-2-rgb), .9);
    transition: transform .2s, filter .2s;
  }
  .chat-send:hover{ filter: brightness(1.08); transform: translateY(-1px); }
  .chat-send:active{ transform: scale(.94); }
  .chat-send svg{ width: 19px; height: 19px; }
  
  /* ============ ریسپانسیو ============ */
  @media (max-width: 480px){
    .support-widget{ bottom: 16px; left: 16px; }
    .chat-toggle{ width: 56px; height: 56px; }
    .chat-window{
      bottom: 72px;
      width: calc(100vw - 32px);
      height: calc(100vh - 140px);
      max-height: 640px;
      border-radius: 18px;
    }
  }