:root {
  --accent: #0ea5e9;
  --accent-2: #0284c7;
  --text: #eff6ff;
  --muted: #9fb2c8;
  --outline: rgba(255, 255, 255, 0.14);
  --bg: #0f172a;
  --panel: rgba(18, 20, 30, 0.92);
}

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

body.client-order-page {
  display: block;
  overflow-y: auto;
}

body.client-order-page .phone-shell {
  margin: 0 auto;
  height: auto;
  max-height: none;
  overflow: visible;
}

body.client-order-page .app {
  display: block;
  height: auto;
  min-height: 0;
}

body.client-order-page .panel {
  display: block;
  flex: none;
  height: auto;
  min-height: 520px;
  overflow: visible;
}

body.client-order-page .composer {
  flex: none;
  height: auto;
  overflow: visible;
}

body.client-order-page .summary {
  flex: none;
  height: auto;
  overflow: visible;
}

.bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.12), transparent 32%),
              radial-gradient(circle at 80% 0%, rgba(186, 230, 253, 0.25), transparent 35%),
              #eaf4ff;
  z-index: -2;
}

.phone-shell {
  width: min(420px, 100%);
  max-width: 420px;
  max-height: calc(100vh - 24px);
  max-height: calc(100svh - 24px);
  background: #0f172a;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(2, 132, 199, 0.22);
  overflow: hidden;
  border: 1px solid rgba(186, 230, 253, 0.22);
  filter: brightness(1.04);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: min(88vh, 820px);
  min-height: min(88svh, 820px);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(180deg, #0b1328 0%, #0f172a 100%);
  border-bottom: 1px solid rgba(186, 230, 253, 0.16);
}
.hero-left {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.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;
  order: 3;
  margin-right: auto;
}
.avatar {
  width: 50px; height: 50px; border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(200, 16, 46, 0.3);
  order: 1;
  flex: 0 0 50px;
}
.avatar-img {
  width: 150%;
  height: 150%;
  object-fit: contain;
  object-position: center 10%;
  display: block;
  transform: scale(1.08);
}
.brand {
  order: 2;
  text-align: right;
}
.brand-name { font-weight: 800; font-size: 16px; }
.brand-name span { color: #ef4444; }
.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: #0b1223;
  overflow: hidden;
  min-height: 0;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("hero-banner.jpg?v=20260501-fastbg") center 58% / cover no-repeat;
  opacity: 0.62;
  filter: saturate(1.05) contrast(1.02);
  pointer-events: none;
  z-index: 0;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 7, 17, 0.12) 0%, rgba(4, 7, 17, 0.3) 18%, rgba(4, 7, 17, 0.72) 52%, rgba(4, 7, 17, 0.92) 100%),
    radial-gradient(circle at 72% 18%, rgba(248, 45, 74, 0.3), transparent 26%),
    radial-gradient(circle at 20% 16%, rgba(255, 255, 255, 0.08), transparent 22%);
  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: 10px; align-items: center; line-height: 1.35; }
.sumBullet { color: var(--accent); width: 22px; display: inline-flex; justify-content: center; flex: 0 0 22px; }
.sumIcon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex: 0 0 26px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
}
.sumText { flex: 1; }

.composer {
  padding: 12px 12px 16px;
  background: linear-gradient(180deg, rgba(10, 12, 22, 0.3), rgba(10, 12, 22, 0.76));
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  overflow-y: auto;
}
.composer-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(12, 16, 26, 0.72);
  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);
}
.client-suggest {
  position: relative;
}
.client-suggest-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  background: rgba(13, 18, 31, 0.96);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(0,0,0,0.28);
  max-height: 220px;
  overflow-y: auto;
  backdrop-filter: blur(12px);
}
.client-suggest-list.hidden {
  display: none;
}
.client-suggest-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: #fff;
  text-align: right;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
}
.client-suggest-item:last-child {
  border-bottom: 0;
}
.client-suggest-item:hover,
.client-suggest-item.active {
  background: rgba(255,255,255,0.08);
}
.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: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    align-items: stretch;
  }
  body.client-order-page {
    display: block;
  }
  .phone-shell {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100svh - 16px);
    border-radius: 20px;
  }
  .app {
    min-height: calc(100vh - 16px);
    min-height: calc(100svh - 16px);
  }
  .hero {
    padding: 12px;
  }
  .brand-name {
    font-size: 15px;
  }
  .brand-sub {
    font-size: 11px;
  }
  .composer-inner { gap: 10px; }
  .btn.whatsapp { min-width: 46px; height: 46px; }
}

@media (max-width: 390px) {
  body {
    padding: 0;
  }
  body.client-order-page .phone-shell {
    max-height: none;
  }
  .phone-shell {
    border-radius: 0;
    border-left: none;
    border-right: none;
    max-height: 100vh;
    max-height: 100svh;
  }
  .app {
    min-height: 100vh;
    min-height: 100svh;
  }
  .hero {
    padding: 10px 12px;
  }
  .avatar {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
  }
  .avatar-img {
    width: 144%;
    height: 144%;
  }
  .composer {
    padding: 10px 10px 14px;
  }
  .composer-inner {
    padding: 9px;
    border-radius: 16px;
  }
  .input {
    min-height: 44px;
    font-size: 13px;
    padding: 11px 12px;
  }
}
/* ================================
   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;
}
