:root {
  --accent: #c8102e;
  --accent-2: #f04242;
  --text: #f2f4f7;
  --muted: #9ca3af;
  --outline: rgba(255, 255, 255, 0.14);
  --bg: #111421;
  --panel: rgba(18, 20, 30, 0.92);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Cairo", "Tajawal", system-ui, -apple-system, sans-serif;
  background: #e6ece7;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(200, 16, 46, 0.08), transparent 32%),
              radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.08), transparent 35%),
              #e6ece7;
  z-index: -2;
}

.phone-shell {
  width: min(420px, 100%);
  max-width: 420px;
  background: #131722;
  border-radius: 22px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  filter: brightness(1.08);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 88vh;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(180deg, #121521 0%, #0d0f16 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.hero-left { display: flex; align-items: center; gap: 10px; }
.back-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--outline); color: var(--text);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #c8102e, #1a1d2a 70%);
  border: 1px solid var(--outline);
  background-image: url("/logo.svg");
  background-size: 75%;
  background-repeat: no-repeat;
  background-position: center;
}
.brand-name { font-weight: 800; font-size: 16px; }
.brand-name span { color: var(--accent); }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hero-actions { display: flex; gap: 10px; color: var(--text); opacity: 0.85; }
.hero-icon { font-size: 15px; }

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #0d0f16;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("hero-banner.jpg") center/cover no-repeat;
  opacity: 0.2;
  filter: grayscale(0.2);
  pointer-events: none;
  z-index: 0;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(0,0,0,0.1), transparent 40%),
              linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.45));
  pointer-events: none;
  z-index: 0;
}
.panel > * {
  position: relative;
  z-index: 1;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.row {
  display: flex;
}
.row.user { justify-content: flex-end; }
.row.assistant { justify-content: flex-start; }
.bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  backdrop-filter: blur(4px);
  white-space: pre-line;
}
.user .bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-top-left-radius: 4px;
}
.assistant .bubble {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border-top-right-radius: 4px;
}

.summary {
  padding: 10px;
}
.summary.hidden { display: none; }
.summary-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--outline);
  border-radius: 14px;
  padding: 12px;
  color: var(--text);
}
.sumTitle { font-weight: 800; margin-bottom: 8px; }
.sumBody { white-space: normal; color: #dfe3ea; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.sumTotal { margin-top: 8px; font-weight: 800; color: #fff; }
.sumActions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.wa-note { font-size: 12px; color: var(--muted); }
.sumLine { display: flex; gap: 8px; align-items: center; line-height: 1.4; }
.sumBullet { color: var(--accent); width: 18px; display: inline-flex; justify-content: center; }
.sumIcon { width: 18px; height: 18px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
.sumText { flex: 1; }

.composer {
  padding: 12px 12px 16px;
  background: linear-gradient(180deg, rgba(17, 20, 33, 0.9), rgba(17, 20, 33, 0.96));
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
}
.composer-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}
.phone-first {
  display: grid;
  grid-template-columns: 1fr;
}
.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  align-items: stretch;
}
.input-row.pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.input {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: #ffffff;
  resize: none;
  min-height: 46px;
  font-size: 14px;
  padding: 12px 14px;
}
.input:focus { outline: none; }
.phone {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  padding: 12px 14px;
  color: #ffffff;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.composer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.input::placeholder,
.phone::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.btn {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.2px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 12px 24px rgba(231, 35, 57, 0.35);
}
.btn.outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}
.btn.whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  height: 48px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #c8102e, #f04242);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 12px 24px rgba(240, 66, 66, 0.35);
}
.btn.whatsapp.square { width: 48px; min-width: 48px; padding: 0; }
.btn.whatsapp.send-icon { width: 46px; min-width: 46px; height: 46px; padding: 0; }
.btn.small { padding: 8px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wa-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2.25c-5.37 0-9.75 4.38-9.75 9.75 0 1.716.45 3.393 1.305 4.873L2 22l5.265-1.498A9.7 9.7 0 0 0 12 21.75c5.37 0 9.75-4.38 9.75-9.75S17.37 2.25 12 2.25Zm0 17.25c-1.54 0-3.053-.408-4.377-1.183l-.313-.183-3.11.885.885-3.11-.183-.313A7.69 7.69 0 0 1 4.5 12c0-4.136 3.364-7.5 7.5-7.5s7.5 3.364 7.5 7.5-3.364 7.5-7.5 7.5Zm4.222-5.119c-.23-.115-1.356-.67-1.567-.747-.21-.077-.363-.115-.516.115-.153.23-.592.747-.725.9-.134.153-.268.173-.498.058-.23-.115-.972-.358-1.852-1.142-.685-.611-1.147-1.366-1.281-1.596-.134-.23-.014-.355.1-.47.103-.102.23-.268.345-.402.115-.134.153-.23.23-.383.077-.153.038-.287-.019-.402-.058-.115-.516-1.244-.707-1.704-.186-.448-.375-.388-.516-.395-.134-.007-.287-.009-.44-.009-.153 0-.402.058-.612.287-.21.23-.802.784-.802 1.91 0 1.126.822 2.214.937 2.365.115.153 1.62 2.477 3.925 3.469.549.237.977.379 1.31.484.55.175 1.05.15 1.447.091.441-.066 1.356-.555 1.548-1.091.19-.536.19-.996.134-1.091-.058-.096-.21-.153-.44-.268Z' fill='%23ffffff'/%3E%3C/svg%3E") center/contain no-repeat;
}
.btn.whatsapp .btn-label { display: none; }
.send-icon-shape {
  display: inline-block;
  width: 16px;
  height: 16px;
  mask: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23ffffff' d='M2.01 21 23 12 2.01 3 2 10l15 2-15 2z'/%3E%3C/svg%3E") center/contain no-repeat;
  background: #fff;
}

/* Client search */
.stack { display: flex; flex-direction: column; gap: 10px; }
.cs-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.cs-card {
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  color: #0f172a;
  min-height: auto;
}
.cs-name { font-weight: 800; color: #0f172a; margin-bottom: 2px; font-size: 14px; line-height: 1.3; }
.cs-meta-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.chip { background: #eaf6ff; color: #0f172a; border-radius: 999px; padding: 4px 8px; font-size: 12px; }
.chip.muted { background: #f8fafc; color: #475569; }
.cs-price { color: #0ea5e9; font-weight: 800; }
.cs-card .btn.outline.small { color: #0f172a; border-color: #cbd5e1; background: #fff; padding: 6px 10px; transition: box-shadow 0.2s ease, transform 0.1s ease; }
.cs-card .btn.outline.small:hover { box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); transform: translateY(-1px); }
.cs-card .btn.outline.small.added { border-color: #ef4444; color: #ef4444; box-shadow: 0 0 14px rgba(239,68,68,0.6); }

/* Hide manual search button; rely on auto-search */
#csSearch { display: none !important; }

/* Keep ask-price button visible and prominent at bottom */
#csAskPrice {
  display: block;
  width: 100%;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

/* Selected block styling */
.cs-selected {
  background: #fff5f5;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 0 18px rgba(248, 113, 113, 0.3);
}
.cs-selected .sumTitle {
  color: #dc2626;
  text-shadow: 0 0 8px rgba(248, 113, 113, 0.6);
}
#csSelectedList .cs-card {
  background: #f7fffb;
  border-color: #bbf7d0;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.28);
}

@media (max-width: 520px) {
  body { padding: 8px; }
  .phone-shell { width: 100%; }
  .composer-inner { gap: 10px; }
  .btn.whatsapp { min-width: 46px; height: 46px; }
}
/* ================================
   Compact catalog item cards
   ================================ */

.item-card,
.catalog-item,
.product-card {
  padding: 10px 12px !important;
  min-height: unset !important;
  border-radius: 12px;
}

.item-card h3,
.item-card .title,
.item-card .item-title {
  font-size: 14px !important;
  line-height: 1.25 !important;
  margin: 0 0 4px 0 !important;
}

.item-card .sub,
.item-card .meta,
.item-card .details {
  font-size: 12px !important;
  line-height: 1.2 !important;
  margin: 0 !important;
}

.item-card .badge,
.item-card .tag {
  font-size: 11px !important;
  padding: 3px 8px !important;
}

.item-card button,
.item-card .btn,
.item-card .add-btn {
  padding: 6px 10px !important;
  font-size: 12px !important;
  height: auto !important;
}

.item-card > * {
  margin-bottom: 4px !important;
}

.item-card > *:last-child {
  margin-bottom: 0 !important;
}
