/* ── Variables ───────────────────────────────────────────────── */
:root {
  --asa-color:      #2563eb;
  --asa-color-dark: #1d4ed8;
  --asa-bg:         #ffffff;
  --asa-text:       #1e293b;
  --asa-muted:      #64748b;
  --asa-border:     #e2e8f0;
  --asa-agent-bg:   #f1f5f9;
  --asa-user-bg:    var(--asa-color);
  --asa-radius:     14px;
  --asa-shadow:     0 8px 32px rgba(0,0,0,.16);
  --asa-z:          99999;
}

/* ── Bubble ──────────────────────────────────────────────────── */
#asa-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  background: var(--asa-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37,99,235,.4);
  z-index: var(--asa-z);
  transition: transform .2s, box-shadow .2s;
}
#asa-bubble:hover          { transform: scale(1.08); box-shadow: 0 6px 24px rgba(37,99,235,.5); }
#asa-bubble.asa-open svg   { display: none; }
#asa-bubble.asa-open::after { content: '✕'; font-size: 22px; font-weight: 700; }

/* ── Panel ───────────────────────────────────────────────────── */
#asa-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: var(--asa-bg);
  border-radius: var(--asa-radius);
  box-shadow: var(--asa-shadow);
  display: flex;
  flex-direction: column;
  z-index: var(--asa-z);
  overflow: hidden;
  animation: asaSlideUp .22s ease;
}
@keyframes asaSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ──────────────────────────────────────────────────── */
#asa-header {
  background: var(--asa-color);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#asa-header-info  { display: flex; align-items: center; gap: 10px; }
#asa-avatar       { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
#asa-agent-name   { font-weight: 600; font-size: 15px; }
#asa-status       { font-size: 11px; opacity: .8; }
#asa-close        { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 0 4px; opacity: .8; transition: opacity .15s; }
#asa-close:hover  { opacity: 1; }

/* ── Messages ────────────────────────────────────────────────── */
#asa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.asa-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.asa-message.asa-agent {
  background: var(--asa-agent-bg);
  color: var(--asa-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  max-width: 100%;
}
.asa-message.asa-user {
  background: var(--asa-color);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ── Typing ──────────────────────────────────────────────────── */
.asa-typing {
  display: flex !important;
  gap: 5px;
  align-items: center;
  padding: 12px 16px !important;
}
.asa-typing span {
  width: 8px; height: 8px;
  background: var(--asa-muted);
  border-radius: 50%;
  animation: asaBounce 1.2s infinite;
}
.asa-typing span:nth-child(2) { animation-delay: .2s; }
.asa-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes asaBounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* ── Input ───────────────────────────────────────────────────── */
#asa-input-area {
  border-top: 1px solid var(--asa-border);
  padding: 12px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
#asa-input {
  flex: 1;
  border: 1px solid var(--asa-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  color: var(--asa-text);
  background: var(--asa-bg);
}
#asa-input:focus     { border-color: var(--asa-color); }
#asa-input:disabled  { opacity: .6; }
#asa-send {
  width: 40px; height: 40px;
  background: var(--asa-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
#asa-send:hover    { background: var(--asa-color-dark); }
#asa-send:disabled { opacity: .5; cursor: not-allowed; }

/* ── Product Cards ───────────────────────────────────────────── */
.asa-products-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 4px 0;
}
.asa-product-card {
  background: #fff;
  border: 1px solid var(--asa-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  gap: 0;
  transition: box-shadow .15s;
}
.asa-product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.asa-product-card img   { width: 90px; height: 90px; object-fit: cover; flex-shrink: 0; }
.asa-no-img             { width: 90px; height: 90px; background: #f8fafc; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.asa-card-body          { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.asa-card-brand         { font-size: 11px; color: var(--asa-muted); text-transform: uppercase; letter-spacing: .5px; }
.asa-card-name          { font-size: 13px; font-weight: 600; color: var(--asa-text); line-height: 1.3; }
.asa-card-price         { font-size: 14px; font-weight: 700; color: var(--asa-color); }
.asa-card-stock         { font-size: 11px; }
.asa-card-stock.in      { color: #16a34a; }
.asa-card-stock.out     { color: #dc2626; }
.asa-card-actions       { display: flex; gap: 6px; margin-top: 6px; }
.asa-btn-details {
  font-size: 12px; padding: 5px 10px;
  background: var(--asa-agent-bg);
  border: 1px solid var(--asa-border);
  border-radius: 6px; cursor: pointer;
  color: var(--asa-text);
  transition: background .15s;
}
.asa-btn-details:hover { background: var(--asa-border); }
.asa-btn-buy {
  font-size: 12px; padding: 5px 10px;
  background: var(--asa-color);
  color: #fff !important;
  border-radius: 6px;
  text-decoration: none !important;
  transition: background .15s;
  display: inline-flex; align-items: center;
}
.asa-btn-buy:hover { background: var(--asa-color-dark); }

/* ── Popup ───────────────────────────────────────────────────── */
#asa-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: calc(var(--asa-z) + 1);
  backdrop-filter: blur(3px);
}
#asa-popup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 96vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  z-index: calc(var(--asa-z) + 2);
  overflow-y: auto;
  animation: asaPopIn .2s ease;
}
@keyframes asaPopIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 20px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
#asa-popup-inner   { padding: 28px; position: relative; }
#asa-popup-close   {
  position: absolute; top: 16px; right: 16px;
  background: #f1f5f9; border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
#asa-popup-close:hover { background: var(--asa-border); }
.asa-popup-grid      { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.asa-popup-img img   { width: 100%; border-radius: 10px; object-fit: contain; max-height: 320px; }
.asa-no-img-lg       { height: 240px; background: #f8fafc; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 48px; }
.asa-popup-gallery   { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.asa-popup-gallery img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; transition: border-color .15s; }
.asa-popup-gallery img:hover { border-color: var(--asa-color); }
.asa-popup-brand     { font-size: 12px; color: var(--asa-muted); text-transform: uppercase; letter-spacing: .6px; }
.asa-popup-title     { font-size: 20px; font-weight: 700; color: var(--asa-text); margin: 6px 0; line-height: 1.3; }
.asa-popup-price     { font-size: 24px; font-weight: 800; color: var(--asa-color); margin: 8px 0; }
.asa-popup-stock     { font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.asa-popup-stock.in  { color: #16a34a; }
.asa-popup-stock.out { color: #dc2626; }
.asa-popup-sku       { font-size: 12px; color: var(--asa-muted); margin-bottom: 10px; }
.asa-popup-tax       { font-size: 13px; color: var(--asa-text); margin-bottom: 5px; }
.asa-popup-desc      { font-size: 13px; color: var(--asa-muted); line-height: 1.6; margin-top: 10px; border-top: 1px solid var(--asa-border); padding-top: 10px; }
.asa-popup-cta       { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.asa-btn-primary     { padding: 11px 20px; background: var(--asa-color); color: #fff !important; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none !important; transition: background .15s; display: inline-block; }
.asa-btn-primary:hover { background: var(--asa-color-dark); }
.asa-btn-secondary   { padding: 11px 20px; background: var(--asa-agent-bg); color: var(--asa-text); border: 1px solid var(--asa-border); border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s; }
.asa-btn-secondary:hover { background: var(--asa-border); }

/* ── Compare ─────────────────────────────────────────────────── */
.asa-compare-wrap   { overflow-x: auto; width: 100%; }
.asa-compare-table  { width: 100%; border-collapse: collapse; font-size: 13px; }
.asa-compare-table th,
.asa-compare-table td { border: 1px solid var(--asa-border); padding: 8px 10px; text-align: left; }
.asa-compare-table thead th { background: var(--asa-color); color: #fff; }
.asa-compare-table tbody tr:nth-child(even) { background: var(--asa-agent-bg); }

/* ── Lead Form ───────────────────────────────────────────────── */
.asa-lead-form      { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.asa-lead-form p    { font-size: 13px; color: var(--asa-text); margin: 0 0 4px; }
.asa-lead-form input {
  border: 1px solid var(--asa-border); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; outline: none;
  transition: border-color .15s; color: var(--asa-text);
  background: #fff;
}
.asa-lead-form input:focus { border-color: var(--asa-color); }

/* ── Hidden ──────────────────────────────────────────────────── */
.asa-hidden { display: none !important; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #asa-panel           { bottom: 80px; right: 12px; width: calc(100vw - 24px); }
  #asa-bubble          { bottom: 16px; right: 16px; }
  .asa-popup-grid      { grid-template-columns: 1fr; }
  #asa-popup-inner     { padding: 20px; }
}

/* ── Admin ───────────────────────────────────────────────────── */
.wrap .form-table th { width: 200px; }
