/* ============================================================
   EXCS V16 — Professional SaaS UI/UX
   Frontend Chat Widget — Premium look inspired by Binance, Intercom, Crisp.
   Backwards compatible: all class names from V9-V15 preserved.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root{
  --excs-brand-start:#16a34a;
  --excs-brand-end:#0f766e;
  --excs-brand-dark:#0b3d2e;
  --excs-bg:#f8fafc;
  --excs-surface:#ffffff;
  --excs-surface-2:#f1f5f9;
  --excs-border:#e5e7eb;
  --excs-border-soft:#eef2f7;
  --excs-text:#0f172a;
  --excs-text-soft:#475569;
  --excs-text-mute:#94a3b8;
  --excs-bubble-me:linear-gradient(135deg,#16a34a 0%,#0f766e 100%);
  --excs-bubble-bot:#ffffff;
  --excs-bubble-smart:linear-gradient(135deg,#eef2ff 0%,#f5f3ff 100%);
  --excs-bubble-queue:linear-gradient(135deg,#fff7ed 0%,#fef3c7 100%);
  --excs-shadow-sm:0 2px 8px rgba(15,23,42,.06);
  --excs-shadow-md:0 10px 30px rgba(15,23,42,.10);
  --excs-shadow-lg:0 25px 60px rgba(15,118,110,.22);
  --excs-radius:20px;
  --excs-radius-lg:26px;
  --excs-radius-sm:14px;
}

/* ---- Reset within widget only ---- */
.excs-chat-pro,
.excs-floating-shell,
.excs-inline-shell,
.excs-tickets,
.excs-chat-pro *{box-sizing:border-box}

/* ============================================================
   1. Chat Shell (inline + floating)
   ============================================================ */
.excs-chat-pro{
  font-family:'Cairo','Tahoma',Arial,sans-serif;
  max-width:420px;
  border:1px solid var(--excs-border-soft);
  border-radius:var(--excs-radius-lg);
  overflow:hidden;
  background:var(--excs-surface);
  box-shadow:var(--excs-shadow-lg);
  margin:20px 0;
  display:flex;
  flex-direction:column;
  position:relative;
}

/* ---- Header ---- */
.excs-chat-head{
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255,255,255,.10) 0%, transparent 50%),
    linear-gradient(135deg,#0b3d2e 0%, #0f766e 50%, #16a34a 110%);
  color:#fff;
  padding:18px 18px 16px;
  display:flex;
  align-items:center;
  gap:12px;
  position:relative;
  overflow:hidden;
}
.excs-chat-head::after{
  content:"";
  position:absolute;
  inset:auto -30% -60% auto;
  width:220px;height:220px;
  background:radial-gradient(circle at center, rgba(255,255,255,.16), transparent 65%);
  pointer-events:none;
}
.excs-chat-head .excs-avatar{
  width:42px;height:42px;
  border-radius:14px;
  background:linear-gradient(135deg,#22c55e,#0f766e);
  display:flex;align-items:center;justify-content:center;
  font-weight:900;font-size:18px;color:#fff;
  box-shadow:0 6px 18px rgba(34,197,94,.45), inset 0 0 0 1px rgba(255,255,255,.22);
  position:relative;
}
.excs-chat-head .excs-avatar::after{
  content:"";position:absolute;
  right:-2px;bottom:-2px;
  width:12px;height:12px;border-radius:50%;
  background:#22c55e;border:2px solid #0b3d2e;
  box-shadow:0 0 0 0 rgba(34,197,94,.7);
  animation:excsOnlinePulse 2s ease-in-out infinite;
}
@keyframes excsOnlinePulse{
  0%,100%{box-shadow:0 0 0 0 rgba(34,197,94,.7)}
  50%{box-shadow:0 0 0 6px rgba(34,197,94,0)}
}
.excs-chat-head .excs-title{flex:1;line-height:1.4}
.excs-chat-head .excs-title b{font-size:15px;font-weight:800;display:block;color:#fff}
.excs-chat-head .excs-title small{display:block;color:rgba(255,255,255,.78);font-size:12px;margin-top:2px;font-weight:500}
.excs-chat-head .excs-online-dot{
  background:rgba(34,197,94,.22);
  color:#bbf7d0;
  border-radius:99px;
  padding:5px 11px;
  font-size:11px;
  font-weight:800;
  border:1px solid rgba(187,247,208,.3);
  white-space:nowrap;
}
.excs-close-chat{
  background:rgba(255,255,255,.14)!important;
  color:#fff!important;
  border:0!important;
  border-radius:12px!important;
  width:34px!important;height:34px!important;
  padding:0!important;
  font-size:20px!important;
  line-height:1!important;
  cursor:pointer;
  transition:.18s;
}
.excs-close-chat:hover{background:rgba(255,255,255,.24)!important;transform:rotate(90deg)}

/* ---- Category Chips ---- */
.excs-cats{
  display:flex;
  gap:8px;
  padding:12px 14px;
  background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-bottom:1px solid var(--excs-border-soft);
  overflow-x:auto;
  scrollbar-width:thin;
}
.excs-cats::-webkit-scrollbar{height:4px}
.excs-cats::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:99px}
.excs-cats button{
  border:1px solid var(--excs-border);
  background:#fff;
  border-radius:99px;
  padding:8px 14px;
  font-weight:700;
  font-size:12.5px;
  color:var(--excs-text);
  cursor:pointer;
  white-space:nowrap;
  flex:0 0 auto;
  font-family:inherit;
  transition:.18s ease;
}
.excs-cats button:hover{
  background:linear-gradient(135deg, var(--excs-brand-start), var(--excs-brand-end));
  color:#fff;
  border-color:transparent;
  transform:translateY(-1px);
  box-shadow:0 6px 16px rgba(22,163,74,.28);
}

/* ---- Chat Body ---- */
.excs-chat-body{
  height:360px;
  overflow-y:auto;
  padding:16px 14px;
  background:
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  scrollbar-width:thin;
  scrollbar-color:#cbd5e1 transparent;
}
.excs-chat-body::-webkit-scrollbar{width:6px}
.excs-chat-body::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:99px}
.excs-chat-body::-webkit-scrollbar-track{background:transparent}

.excs-chat-body > div{
  padding:11px 14px;
  border-radius:18px;
  margin:6px 0;
  max-width:82%;
  line-height:1.7;
  font-size:14px;
  word-wrap:break-word;
  animation:excsBubbleIn .22s cubic-bezier(.2,.8,.2,1);
  position:relative;
  box-shadow:var(--excs-shadow-sm);
}
@keyframes excsBubbleIn{
  from{opacity:0;transform:translateY(8px) scale(.96)}
  to{opacity:1;transform:translateY(0) scale(1)}
}

/* Bot bubbles (right-side in RTL, served from agent/system) */
.excs-chat-body .bot{
  background:var(--excs-bubble-bot);
  color:var(--excs-text);
  border:1px solid var(--excs-border-soft);
  border-top-right-radius:6px;
  margin-left:auto;margin-right:0;
}

/* My bubbles — gradient brand color, opposite side */
.excs-chat-body .me{
  background:var(--excs-bubble-me);
  color:#fff;
  border:0;
  border-top-left-radius:6px;
  margin-right:auto;margin-left:0;
  box-shadow:0 8px 22px rgba(22,163,74,.28);
}
.excs-chat-body .me small{color:rgba(255,255,255,.85)!important}

/* Smart bubble (FAQ AI suggestion) */
.excs-chat-body .smart{
  background:var(--excs-bubble-smart);
  border:1px solid #c7d2fe;
  color:#1e1b4b;
  border-top-right-radius:6px;
  margin-left:auto;margin-right:0;
}

/* Queue / ticket info */
.excs-chat-body .queue{
  background:var(--excs-bubble-queue);
  border:1px solid #fed7aa;
  color:#7c2d12;
  font-weight:700;
  text-align:center;
  max-width:96%;
  margin:10px auto;
  border-radius:14px;
  font-size:13px;
}

.excs-chat-body p{margin:0}
.excs-chat-body small{
  display:block;
  color:var(--excs-text-mute);
  font-size:10.5px;
  margin-top:5px;
  font-weight:500;
}
.excs-chat-body a{
  display:inline-block;
  margin-top:8px;
  color:#0f766e;
  font-weight:700;
  text-decoration:none;
  background:rgba(15,118,110,.08);
  padding:5px 10px;
  border-radius:10px;
  font-size:12.5px;
  transition:.15s;
}
.excs-chat-body a:hover{background:rgba(15,118,110,.16)}
.excs-chat-body .me a{
  color:#fff;
  background:rgba(255,255,255,.18);
}
.excs-chat-body .me a:hover{background:rgba(255,255,255,.28)}

/* ---- Form ---- */
.excs-chat-pro form{
  display:flex;
  gap:8px;
  padding:12px 12px 14px;
  border-top:1px solid var(--excs-border-soft);
  background:#fff;
  align-items:center;
}
.excs-chat-pro input[type=text]{
  flex:1;
  border:1px solid var(--excs-border);
  border-radius:99px;
  padding:12px 16px;
  font-size:14px;
  font-family:inherit;
  background:#f8fafc;
  color:var(--excs-text);
  outline:none;
  transition:.18s;
}
.excs-chat-pro input[type=text]:focus{
  background:#fff;
  border-color:var(--excs-brand-start);
  box-shadow:0 0 0 4px rgba(22,163,74,.12);
}
.excs-chat-pro input[type=text]::placeholder{color:var(--excs-text-mute)}
.excs-chat-pro .file{
  background:#f1f5f9;
  border-radius:50%;
  width:42px;height:42px;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  font-size:18px;
  transition:.15s;
  flex-shrink:0;
}
.excs-chat-pro .file:hover{background:#e2e8f0;transform:scale(1.05)}
.excs-chat-pro .file input{display:none}
.excs-chat-pro button[type=submit]{
  background:linear-gradient(135deg, var(--excs-brand-start), var(--excs-brand-end));
  color:#fff;
  border:0;
  border-radius:99px;
  padding:0 18px;
  height:42px;
  font-weight:800;
  font-size:13.5px;
  font-family:inherit;
  cursor:pointer;
  transition:.18s;
  box-shadow:0 8px 20px rgba(22,163,74,.32);
  flex-shrink:0;
}
.excs-chat-pro button[type=submit]:hover{
  transform:translateY(-1px);
  box-shadow:0 12px 26px rgba(22,163,74,.42);
}
.excs-chat-pro.sending button[type=submit]{
  opacity:.55;pointer-events:none;cursor:wait;
}
.excs-chat-pro.sending button[type=submit]::after{
  content:"...";display:inline-block;animation:excsDots 1.2s infinite;
}
@keyframes excsDots{0%{opacity:.2}50%{opacity:1}100%{opacity:.2}}

/* ============================================================
   2. Floating Widget
   ============================================================ */
.excs-floating-shell{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:999999;
  font-family:'Cairo','Tahoma',Arial,sans-serif;
  direction:rtl;
}
.excs-floating-btn{
  width:64px;height:64px;
  border-radius:99px;
  border:0;
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255,255,255,.18) 0%, transparent 50%),
    linear-gradient(135deg, var(--excs-brand-start) 0%, var(--excs-brand-end) 100%);
  color:#fff;
  box-shadow:
    0 18px 45px rgba(15,118,110,.4),
    0 0 0 0 rgba(22,163,74,.5);
  cursor:pointer;
  font-size:26px;
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  gap:0;
  font-family:inherit;
  transition:.22s cubic-bezier(.2,.8,.2,1);
  position:relative;
  animation:excsBtnPulse 2.4s ease-in-out infinite;
}
@keyframes excsBtnPulse{
  0%,100%{box-shadow:0 18px 45px rgba(15,118,110,.4), 0 0 0 0 rgba(22,163,74,.45)}
  50%{box-shadow:0 18px 45px rgba(15,118,110,.4), 0 0 0 14px rgba(22,163,74,0)}
}
.excs-floating-btn:hover{transform:translateY(-2px) scale(1.05)}
.excs-floating-btn span{font-size:10px;font-weight:900;margin-top:-2px;letter-spacing:.3px}

.excs-floating-panel{
  position:absolute;
  right:0;bottom:80px;
  width:400px;max-width:calc(100vw - 28px);
  transform:translateY(18px) scale(.94);
  opacity:0;pointer-events:none;
  transition:.26s cubic-bezier(.2,.8,.2,1);
  transform-origin:bottom right;
}
.excs-floating-shell.open .excs-floating-panel{
  transform:translateY(0) scale(1);
  opacity:1;
  pointer-events:auto;
}
.excs-floating-shell.open .excs-floating-btn{
  transform:scale(0);opacity:0;pointer-events:none;
}
.excs-floating-shell .excs-chat-pro{
  margin:0;
  width:400px;max-width:calc(100vw - 28px);
  border-radius:var(--excs-radius-lg);
}
.excs-floating-shell .excs-chat-body{height:380px}

/* ---- Unread Badge on floating button ---- */
.excs-widget-badge{
  position:absolute;
  top:-4px;left:-4px;
  background:linear-gradient(135deg,#ef4444,#dc2626);
  color:#fff;
  border:2px solid #fff;
  border-radius:99px;
  min-width:24px;height:24px;
  display:none;
  align-items:center;justify-content:center;
  font-size:11px;font-weight:900;
  box-shadow:0 6px 16px rgba(239,68,68,.5);
  animation:excsBadgePop .3s cubic-bezier(.2,1.4,.4,1);
}
@keyframes excsBadgePop{
  from{transform:scale(0)}
  to{transform:scale(1)}
}

/* ============================================================
   3. Tickets Page (shortcode: excs_user_tickets)
   ============================================================ */
.excs-tickets{
  font-family:'Cairo','Tahoma',Arial,sans-serif;
  max-width:760px;
  margin:24px auto;
}
.excs-tickets h3{
  font-size:22px;
  font-weight:900;
  color:var(--excs-text);
  margin:0 0 16px;
  padding-right:12px;
  border-right:4px solid var(--excs-brand-start);
}
.excs-ticket{
  border:1px solid var(--excs-border);
  border-radius:18px;
  padding:16px 18px;
  margin:10px 0;
  background:#fff;
  box-shadow:var(--excs-shadow-sm);
  transition:.18s;
}
.excs-ticket:hover{box-shadow:var(--excs-shadow-md);transform:translateY(-1px)}
.excs-ticket summary{
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  font-weight:700;
  list-style:none;
}
.excs-ticket summary::-webkit-details-marker{display:none}
.excs-ticket summary b{color:var(--excs-text);font-size:15px}
.excs-ticket summary span{
  background:linear-gradient(135deg,#eef2ff,#e0e7ff);
  color:#3730a3;
  border-radius:99px;
  padding:4px 12px;
  font-size:11.5px;
  font-weight:800;
}
.excs-ticket summary p{
  width:100%;
  margin:6px 0 0;
  color:var(--excs-text-soft);
  font-weight:500;
  font-size:13.5px;
}
.excs-ticket summary small{color:var(--excs-text-mute);font-size:12px;font-weight:600}
.ticket-msg{
  border-radius:14px;
  padding:11px 14px;
  margin:8px 0;
  background:#f8fafc;
  border:1px solid var(--excs-border-soft);
  line-height:1.7;
}
.ticket-msg.customer{background:linear-gradient(135deg,#dcfce7,#bbf7d0);border-color:#86efac}
.ticket-msg.agent{background:linear-gradient(135deg,#dbeafe,#bfdbfe);border-color:#93c5fd}
.ticket-msg small{display:block;color:var(--excs-text-mute);font-size:11px;margin-bottom:4px;font-weight:600}

/* ============================================================
   4. Mobile / RTL polish
   ============================================================ */
@media(max-width:600px){
  .excs-floating-shell{right:12px;left:12px;bottom:14px}
  .excs-floating-panel{right:0;left:0;width:auto;max-width:none;bottom:80px}
  .excs-floating-shell .excs-chat-pro{width:100%;max-width:none;border-radius:22px}
  .excs-floating-shell .excs-chat-body{height:62vh}
  .excs-floating-btn{margin-right:auto;width:60px;height:60px;font-size:24px}
  .excs-chat-pro{max-width:100%;border-radius:0;margin:0}
  .excs-chat-body{height:60vh}
  .excs-cats{padding:10px 12px}
  .excs-cats button{padding:7px 12px;font-size:12px}
}

/* ============================================================
   5. Empty + Loading states
   ============================================================ */
.excs-chat-body:empty::before{
  content:"⏳ جاري التحميل...";
  display:block;
  text-align:center;
  color:var(--excs-text-mute);
  padding:40px 20px;
  font-weight:600;
}



/* ===== EXCOIN V5.4 UX UPDATE ===== */

.excs-header-actions{
    display:flex;
    align-items:center;
    gap:8px;
}

.excs-close-btn,
.excs-minimize-btn{
    width:30px;
    height:30px;
    border:none;
    border-radius:50%;
    cursor:pointer;
    font-size:18px;
    font-weight:bold;
}

.excs-close-btn{
    background:#ff4d4f;
    color:#fff;
}

.excs-minimize-btn{
    background:rgba(255,255,255,.2);
    color:#fff;
}

.excs-minimized{
    display:none !important;
}

.excs-new-session-msg{
    background:#e8fff1;
    border:1px solid #1fa463;
    color:#1a7f4b;
    padding:14px;
    margin:12px 0;
    border-radius:12px;
    text-align:center;
    font-weight:600;
}
