*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-app: #1c2733;
  --bg-sidebar: #212d3b;
  --bg-sidebar-hover: #2b3a4a;
  --bg-sidebar-active: #2b5278;
  --bg-main: #0e1621;
  --bg-input: #182533;
  --bg-bubble-out: #2b5278;
  --bg-bubble-in: #182533;
  --accent: #2CA5E0;
  --text-primary: #e8eaed;
  --text-secondary: #8e9da8;
  --text-time: #6c8697;
  --border: #2a3a4a;
  --avatar-size: 48px;
  --sidebar-width: 340px;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-app); color: var(--text-primary); }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}


/* ─── MAIN ─── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
  position: relative;
}

/* Topbar */
.chat-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}
.chat-topbar-info { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: #5682a3;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: #fff;
}
.topbar-text { display: flex; flex-direction: column; }
.topbar-name { font-size: 15px; font-weight: 600; }
.topbar-status { font-size: 13px; color: var(--accent); }
.topbar-actions { display: flex; gap: 4px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.07); color: var(--text-primary); }

/* Messages */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-image: url("https://web.telegram.org/a/chat-bg-pattern-dark.png");
  background-size: 400px;
  background-repeat: repeat;
}
.messages-area::-webkit-scrollbar { width: 5px; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 5px; }

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Date divider */
.date-divider {
  text-align: center;
  margin: 10px 0 6px;
}
.date-divider span {
  background: rgba(0,0,0,.4);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

/* Bubbles */
.msg-row {
  display: flex;
  margin: 2px 0;
}
.msg-row.out { justify-content: flex-end; }
.msg-row.in  { justify-content: flex-start; }

.bubble {
  max-width: 65%;
  padding: 8px 12px 6px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
.msg-row.out .bubble {
  background: var(--bg-bubble-out);
  border-bottom-right-radius: 4px;
}
.msg-row.in .bubble {
  background: var(--bg-bubble-in);
  border-bottom-left-radius: 4px;
}
.msg-row.in .bubble-media {
  max-width: calc(100vw - 40px);
}

.bubble-tail {
  position: absolute;
  bottom: 0;
  width: 10px;
  height: 14px;
}
.msg-row.out .bubble-tail {
  right: -8px;
}
.msg-row.in .bubble-tail {
  left: -8px;
  transform: scaleX(-1);
}

.bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}
.bubble-time { font-size: 11px; color: var(--text-time); }
.bubble-check {
  display: flex;
  align-items: center;
  color: var(--accent);
}
.bubble-check.single svg:last-child { display: none; }
.bubble-check svg { width: 12px; height: 12px; margin-left: -4px; }

/* Input bar */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrap {
  flex: 1;
  background: var(--bg-input);
  border-radius: 22px;
  display: flex;
  align-items: flex-end;
  padding: 6px 8px 6px 14px;
  gap: 4px;
}

.msg-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  padding: 2px 0;
  font-family: inherit;
}
.msg-input::placeholder { color: var(--text-secondary); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.send-btn:hover { background: #1e9fd6; }
.send-btn:active { transform: scale(.93); }

/* ─── Video bubble ─── */
.bubble-media {
  padding: 4px 4px 6px;
  width: calc(100vw - 40px);
  max-width: 520px;
}
.video-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
}
.video-wrap video {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 420px;
  object-fit: cover;
}
.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  transition: opacity .2s;
}
.play-btn {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.video-duration {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.bubble-footer-media {
  padding: 0 6px;
  margin-top: 3px;
}
.video-caption {
  font-size: 14px;
  line-height: 1.4;
  padding: 6px 8px 2px;
  color: var(--text-primary);
}

/* ─── CTA button ─── */
.cta-wrap {
  padding: 10px 14px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.cta-btn {
  width: 100%;
  padding: 13px 16px;
  background: #2CA5E0;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.cta-btn:hover { background: #1e9fd6; }
.cta-btn:active { transform: scale(.98); }

/* ─── Scroll-to-bottom button ─── */
.scroll-down-btn {
  position: absolute;
  bottom: 130px;
  right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity .2s, transform .2s;
  z-index: 10;
}
.scroll-down-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-down-btn:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }


/* ─── PIX Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-card {
  background: #1e2d3d;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 480px;
  position: relative;
  transform: translateY(40px);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal-card { transform: translateY(0); }
.modal-top-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.modal-close {
  background: none; border: none; color: rgba(255,255,255,.7);
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: color .15s;
  padding: 0;
}
.modal-close:hover { color: #fff; }

.modal-urgency {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .6px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
}
#countdown { font-size: 14px; font-weight: 900; }

.modal-header { text-align: center; margin-bottom: 12px; }
.modal-subtitle-top { font-size: 12px; color: #27ae60; font-weight: 600; margin-bottom: 4px; }
.modal-title { font-size: 18px; font-weight: 800; color: var(--text-primary); margin-bottom: 10px; }
.modal-price-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.modal-price-old { font-size: 14px; color: var(--text-secondary); text-decoration: line-through; }
.modal-amount { font-size: 30px; font-weight: 900; color: #32BCAD; }
.modal-badge { background: #e74c3c; color: #fff; font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 6px; }

.modal-desc { font-size: 13px; line-height: 1.7; color: var(--text-primary); background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.modal-social { text-align: center; font-size: 13px; color: var(--text-secondary); background: rgba(39,174,96,.1); border: 1px solid rgba(39,174,96,.2); border-radius: 8px; padding: 7px 12px; margin-bottom: 14px; }
.modal-social strong { color: #2ecc71; }

.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.qr-row { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.qr-left { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.qr-img { width: 130px; height: 130px; border-radius: 10px; background: #fff; padding: 5px; }
.qr-hint { font-size: 11px; color: var(--text-secondary); text-align: center; }
.qr-instructions { display: flex; flex-direction: column; gap: 8px; flex: 1; justify-content: center; padding-top: 4px; }
.qr-step { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--text-primary); line-height: 1.4; }
.qr-num { background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.qr-step-value { font-size: 13px; color: #2ecc71; font-weight: 700; margin-top: 2px; padding-left: 2px; }
.pix-divider { text-align: center; position: relative; margin-bottom: 12px; }
.pix-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.pix-divider span { position: relative; background: #1e2d3d; padding: 0 10px; font-size: 12px; color: var(--text-secondary); }
.pix-key-wrap { display: flex; align-items: center; background: var(--bg-input); border-radius: 10px; padding: 10px 12px; gap: 8px; margin-bottom: 12px; }
.pix-key { flex: 1; font-size: 13px; color: var(--text-primary); word-break: break-all; }
.copy-btn { display: flex; align-items: center; gap: 5px; background: var(--accent); border: none; color: #fff; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 7px; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.copy-btn:hover { background: #1e9fd6; }
.copy-btn.copied { background: #27ae60; }

.modal-trust { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.modal-trust span { font-size: 11px; color: var(--text-secondary); }
.modal-note { text-align: center; font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* ─── Unmute button ─── */
.unmute-btn {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,.65);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition: background .15s;
}
.unmute-btn:hover { background: rgba(0,0,0,.8); }
.unmute-btn .icon-muted path { fill: #e74c3c; }
.unmute-btn .icon-unmuted { display: none; }
.unmute-btn.unmuted { display: none; }
.unmute-btn.unmuted .icon-muted { display: none; }
.unmute-btn.unmuted .icon-unmuted { display: block; }
.unmute-btn.unmuted .unmute-label { display: none; }
