/* EZ Store — customer chat */
:root {
  --bg: #efe8dc; --wall: #e9e1d3; --surface: #ffffff; --surface-2: #f7f3ec; --text: #1d1a16; --muted: #7a7166;
  --border: #e3d9c8; --accent: #b5701f; --ink: #16130f; --on-ink: #f7f3ec;
  --me: #d9fdd3; --me-text: #10241a; --bot: #ffffff; --tick: #34b7f1; --wa: #25d366;
  --shadow: 0 1px 1.5px rgba(0,0,0,.13);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0c10; --wall: #0f1116; --surface: #1a1d24; --surface-2: #222631; --text: #ece7df; --muted: #9a9387;
  --border: #2b2f3a; --accent: #e3a458; --ink: #ece7df; --on-ink: #121419;
  --me: #144d37; --me-text: #e8fff2; --bot: #1f232c; --shadow: 0 1px 1.5px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

.app { height: 100dvh; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; background: var(--wall); position: relative; box-shadow: 0 0 40px rgba(0,0,0,.08); }
@supports not (height: 100dvh) { .app { height: 100vh; } }
.app::before { /* subtle doodle pattern */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .05;
  background-image: radial-gradient(circle at 10px 10px, var(--text) 1.2px, transparent 1.3px);
  background-size: 26px 26px;
}

/* header */
.top { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--ink); color: var(--on-ink); }
.top .back { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; text-decoration: none; }
.avatar { width: 42px; height: 42px; border-radius: 12px; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.who b { font-size: 16px; }
.who span { font-size: 12.5px; opacity: .75; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .who .long { display: none; } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wa); display: inline-block; box-shadow: 0 0 0 0 rgba(37,211,102,.7); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(37,211,102,0); } 100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); } }
.icon { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.top .icon:hover { background: rgba(127,127,127,.18); }
.top .i-sun, .top .i-moon { position: absolute; transition: transform .4s, opacity .3s; }
.top .i-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
:root[data-theme="dark"] .top .i-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
:root[data-theme="dark"] .top .i-moon { opacity: 1; transform: none; }
.shop-btn { text-decoration: none; font-size: 13.5px; font-weight: 600; padding: 8px 14px; border-radius: 999px; background: var(--accent); color: #1a1208; white-space: nowrap; }

/* messages */
.thread { position: relative; z-index: 1; flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 4px; scroll-behavior: smooth; overscroll-behavior: contain; }
.day { align-self: center; margin: 10px 0 6px; padding: 5px 12px; border-radius: 9px; font-size: 12px; font-weight: 500; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); }
.notice { align-self: center; max-width: 88%; margin: 4px 0 8px; padding: 7px 12px; border-radius: 9px; font-size: 12px; text-align: center; background: #fff3cd; color: #6b5200; }
:root[data-theme="dark"] .notice { background: #3a3112; color: #f1dc8f; }
.msg { max-width: min(78%, 520px); padding: 7px 10px 6px; border-radius: 12px; box-shadow: var(--shadow); position: relative; font-size: 14.5px; line-height: 1.45; word-wrap: break-word; animation: pop .28s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.msg.bot { align-self: flex-start; background: var(--bot); border-top-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--me); color: var(--me-text); border-top-right-radius: 4px; }
.msg.cont.bot { border-top-left-radius: 12px; }
.msg.cont.me { border-top-right-radius: 12px; }
.msg .txt { white-space: pre-wrap; }
.msg .txt b { font-weight: 600; }
.meta { float: right; margin: 6px 0 -3px 12px; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; line-height: 1; }
.msg.me .meta { color: color-mix(in srgb, var(--me-text) 60%, transparent); }
.tick svg { width: 16px; height: 16px; stroke-width: 2.2; }
.tick.read { color: var(--tick); }
.sender { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }

/* price list card */
.prices { list-style: none; margin: 8px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.prices li { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; background: var(--surface-2); }
.prices img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.prices .pn { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.3; }
.prices .pn small { display: block; color: var(--muted); font-family: 'Noto Nastaliq Urdu', serif; font-size: 12px; line-height: 1.9; }
.prices .pp { font-weight: 700; font-size: 14px; white-space: nowrap; }

/* sample albums */
.album { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; border-radius: 9px; overflow: hidden; margin: 2px -4px 4px; }
.album.n1 { grid-template-columns: 1fr; }
.album button { border: 0; padding: 0; background: #000; aspect-ratio: 1 / 1; overflow: hidden; position: relative; }
.album.n1 button { aspect-ratio: 4 / 3; }
.album img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.album button:hover img { transform: scale(1.05); }
.album .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-size: 22px; font-weight: 600; }
.cap { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.cap span { font-weight: 400; color: var(--muted); }

/* choice buttons & links inside bot messages */
.choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.choice { border: 1.5px solid var(--accent); background: transparent; color: var(--text); padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; text-align: center; text-decoration: none; display: block; transition: background-color .2s, transform .15s; }
.choice:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.choice:active { transform: scale(.98); }
.choice.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.choice.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.choice small { display: block; font-weight: 400; font-size: 12px; opacity: .8; margin-top: 2px; }
.choice[disabled] { opacity: .55; cursor: default; }
.agent-card { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.agent-card .av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--wa); color: #fff; font-size: 18px; flex: none; }
.agent-card b { display: block; font-size: 14px; }
.agent-card span { font-size: 13px; color: var(--muted); }

/* customer media */
.msg img.media, .msg video.media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin: -2px -4px 2px; }
.msg audio { display: block; width: 240px; max-width: 100%; height: 40px; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.voice .vplay { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; }
.voice .vbar { flex: 1; height: 4px; border-radius: 4px; background: color-mix(in srgb, currentColor 22%, transparent); position: relative; overflow: hidden; }
.voice .vbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); }
.voice .vtime { font-size: 12px; opacity: .75; min-width: 34px; }
.progress { height: 4px; border-radius: 4px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; margin: 6px 0 2px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.failed { color: #c0262d; font-size: 12px; margin-top: 4px; }
.placeholder-media { display: flex; align-items: center; gap: 8px; font-size: 13.5px; opacity: .85; }

/* typing indicator */
.typing { align-self: flex-start; background: var(--bot); padding: 12px 14px; border-radius: 12px; border-top-left-radius: 4px; box-shadow: var(--shadow); display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* quick replies */
.quick { position: relative; z-index: 1; display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick:empty { display: none; }
.quick button { flex: none; border: 1.5px solid var(--accent); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }

/* composer */
.composer { position: relative; z-index: 2; display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: transparent; }
.attach-wrap { position: relative; }
.composer .attach { background: var(--surface); width: 46px; height: 46px; box-shadow: var(--shadow); color: var(--muted); }
.attach-menu { position: absolute; bottom: 56px; left: 0; background: var(--surface); border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 8px; display: flex; flex-direction: column; gap: 2px; min-width: 170px; animation: pop .2s; }
.attach-menu[hidden] { display: none; }
.attach-menu label { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; font-size: 14.5px; font-weight: 500; cursor: pointer; }
.attach-menu label:hover { background: var(--surface-2); }
.am-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; }
.am-img { background: #e8defd; } .am-vid { background: #fde2e2; } .am-cam { background: #ffe9cc; }
.field { flex: 1; min-width: 0; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); padding: 4px 16px; display: flex; align-items: center; min-height: 46px; }
.field textarea { flex: 1; border: 0; outline: none; resize: none; background: transparent; font: inherit; font-size: 15px; color: var(--text); max-height: 120px; padding: 9px 0; line-height: 1.4; }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; flex: none; box-shadow: var(--shadow); transition: transform .15s; position: relative; }
.send:active { transform: scale(.94); }
.send .i-send, .send .i-mic { position: absolute; transition: transform .25s, opacity .2s; }
.send .i-send { opacity: 0; transform: scale(.4) rotate(-40deg); }
.composer.has-text .send .i-send { opacity: 1; transform: none; }
.composer.has-text .send .i-mic { opacity: 0; transform: scale(.4); }
.recorder { position: absolute; inset: 8px 10px; display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 24px; padding: 0 0 0 4px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.recorder[hidden] { display: none; }
.rec-cancel { color: #c0262d; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: blink 1s infinite; }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 3px; height: 24px; }
.rec-wave i { width: 3px; border-radius: 3px; background: var(--accent); animation: wave 1s ease-in-out infinite; height: 30%; }
.rec-wave i:nth-child(2n) { animation-delay: .15s; } .rec-wave i:nth-child(3n) { animation-delay: .3s; }
@keyframes wave { 50% { height: 100%; } }
.rec-send { background: var(--wa); color: #fff; }

/* image viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.viewer[hidden] { display: none; }
.viewer img { max-width: 100%; max-height: 92vh; border-radius: 8px; }
.viewer-close { position: fixed; top: 12px; right: 12px; color: #fff; font-size: 30px; background: rgba(255,255,255,.12); }

@media (min-width: 900px) {
  body { padding: 18px 0; }
  .app { height: calc(100dvh - 36px); border-radius: 18px; overflow: hidden; }
}
@media (max-width: 420px) {
  .shop-btn { padding: 7px 10px; font-size: 12.5px; }
  .msg { max-width: 86%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
