@charset "UTF-8";
/* ==========================================================================
   بيوت العقارية — chat.css
   «زين» — the property consultant assistant.
   Styled as a consultant's notepad: ruled, ink-on-paper, gold accents.
   ========================================================================== */

.byt-chat { position: fixed; inset-block-end: 24px; inset-inline-end: 24px; z-index: 1100; }

/* ==========================================================================
   1. LAUNCHER
   ========================================================================== */
.byt-chat__launcher {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 20px 11px 12px;
  background: var(--ink-900); color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-4);
  transition: transform .2s var(--ease), background-color var(--dur) var(--ease);
}
[dir="rtl"] .byt-chat__launcher { padding: 11px 12px 11px 20px; }
.byt-chat__launcher:hover { transform: translateY(-2px); background: var(--ink-800); }
.byt-chat__launcher[aria-expanded="true"] { transform: scale(.9); opacity: 0; pointer-events: none; }

.byt-chat__avatar {
  inline-size: 38px; block-size: 38px; flex: none;
  display: grid; place-items: center;
  background: var(--gold-500); color: var(--ink-950);
  border-radius: 50%;
  font-family: var(--font-display); font-size: 18px; font-weight: 700; line-height: 1;
}
.byt-chat__avatar img { inline-size: 100%; block-size: 100%; object-fit: contain; background: none; padding: 5px; }

.byt-chat__launcher-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; line-height: 1.2; }
.byt-chat__launcher-text strong { font-size: var(--step--1); font-weight: 600; }
.byt-chat__launcher-text span { font-size: var(--step--2); color: var(--gold-300); display: flex; align-items: center; gap: 5px; }
.byt-chat__dot { inline-size: 6px; block-size: 6px; border-radius: 50%; background: #35D07F; flex: none; }

/* Unread pip */
.byt-chat__launcher[data-unread]:not([data-unread="0"])::after {
  content: attr(data-unread);
  position: absolute; inset-block-start: -4px; inset-inline-end: -4px;
  min-inline-size: 20px; padding: 0 6px;
  font-family: var(--font-num); font-size: 11px; font-weight: 700; line-height: 19px;
  color: #fff; background: var(--bad); border: 2px solid var(--bg);
  border-radius: var(--r-pill); text-align: center;
}

/* Proactive nudge bubble */
.byt-chat__nudge {
  position: absolute; inset-block-end: calc(100% + 12px); inset-inline-end: 0;
  inline-size: max-content; max-inline-size: 260px;
  padding: 12px 15px;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--line); border-inline-end: 3px solid var(--gold-500);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  font-size: var(--step--1); line-height: 1.55;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
}
[dir="rtl"] .byt-chat__nudge { border-inline-end: 1px solid var(--line); border-inline-start: 3px solid var(--gold-500); }
.byt-chat__nudge.is-on { opacity: 1; visibility: visible; transform: none; }
.byt-chat__nudge button { position: absolute; inset-block-start: 4px; inset-inline-end: 6px; color: var(--text-mute); font-size: 15px; line-height: 1; padding: 4px; }
.byt-chat__nudge button:hover { color: var(--text); }

/* ==========================================================================
   2. PANEL
   ========================================================================== */
.byt-chat__panel {
  position: absolute; inset-block-end: 0; inset-inline-end: 0;
  inline-size: min(400px, calc(100vw - 32px));
  block-size: min(640px, calc(100vh - 100px));
  display: flex; flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.97);
  transform-origin: 100% 100%;
  transition: opacity .26s var(--ease), transform .26s var(--ease), visibility .26s;
}
[dir="rtl"] .byt-chat__panel { transform-origin: 0 100%; }
.byt-chat__panel.is-open { opacity: 1; visibility: visible; transform: none; }

@media (max-width: 520px) {
  .byt-chat { inset-block-end: 16px; inset-inline-end: 16px; }
  .byt-chat__panel {
    position: fixed; inset: 0;
    inline-size: 100%; block-size: 100%;
    border-radius: 0; border: 0;
    transform-origin: 50% 100%;
  }
}

/* -- Header ------------------------------------------------------------- */
.byt-chat__head {
  display: flex; align-items: center; gap: 11px;
  padding: 13px var(--sp-4);
  background: var(--ink-900); color: #fff;
  flex: none;
  border-block-end: 2px solid var(--gold-500);
}
.byt-chat__head .byt-chat__avatar { inline-size: 36px; block-size: 36px; font-size: 16px; }
.byt-chat__who { flex: 1; min-inline-size: 0; line-height: 1.3; }
.byt-chat__who strong { display: block; font-size: var(--step--1); font-weight: 600; }
.byt-chat__who span { display: flex; align-items: center; gap: 5px; font-size: var(--step--2); color: rgba(255,255,255,.6); }
.byt-chat__head-btn {
  inline-size: 32px; block-size: 32px; flex: none;
  display: grid; place-items: center; border-radius: var(--r-sm);
  color: rgba(255,255,255,.65);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.byt-chat__head-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.byt-chat__head-btn svg { inline-size: 17px; block-size: 17px; }

/* -- Message log -------------------------------------------------------- */
.byt-chat__log {
  flex: 1; min-block-size: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: 14px;
  background: var(--bg);
  /* Faint ruled paper — a notepad, not a glass panel */
  background-image: repeating-linear-gradient(
    to bottom, transparent, transparent 31px, var(--line-soft) 31px, var(--line-soft) 32px);
  scroll-behavior: smooth;
}
.byt-chat__log::-webkit-scrollbar { inline-size: 8px; }
.byt-chat__log::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }
.byt-chat__log::-webkit-scrollbar-track { background: transparent; }

.byt-msg { display: flex; gap: 9px; max-inline-size: 92%; animation: byt-msg-in .3s var(--ease); }
@keyframes byt-msg-in { from { opacity: 0; transform: translateY(8px); } }

.byt-msg__avatar {
  inline-size: 28px; block-size: 28px; flex: none; align-self: flex-end;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--ink-900); color: var(--gold-300);
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
}
.byt-msg__avatar img { inline-size: 100%; block-size: 100%; object-fit: contain; padding: 3px; background: none; }

.byt-msg__bubble {
  padding: 11px 14px;
  font-size: var(--step--1); line-height: 1.7;
  border-radius: var(--r-md);
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
  min-inline-size: 0; word-wrap: break-word; overflow-wrap: anywhere;
}
.byt-msg__bubble p + p { margin-block-start: .65em; }
.byt-msg__bubble strong { font-weight: 700; color: var(--text); }
.byt-msg__bubble a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.byt-msg__bubble ul { margin-block: .5em 0; display: flex; flex-direction: column; gap: 6px; }
.byt-msg__bubble li { position: relative; padding-inline-start: 15px; }
.byt-msg__bubble li::before {
  content: ""; position: absolute; inset-inline-start: 2px; inset-block-start: .62em;
  inline-size: 5px; block-size: 5px; background: var(--accent); transform: rotate(45deg);
}
.byt-msg__bubble .num { font-family: var(--font-num); font-weight: 600; }

/* Bot: rounded except the corner nearest its avatar */
.byt-msg--bot { align-self: flex-start; }
.byt-msg--bot .byt-msg__bubble { border-start-start-radius: var(--r-xs); }

/* User: ink block, no avatar */
.byt-msg--me { align-self: flex-end; flex-direction: row-reverse; }
.byt-msg--me .byt-msg__bubble {
  background: var(--ink-900); color: #fff;
  border-color: var(--ink-900);
  border-end-end-radius: var(--r-xs);
}
.byt-msg--me .byt-msg__bubble a { color: var(--gold-300); }

.byt-msg__time { font-family: var(--font-num); font-size: 10px; color: var(--text-mute); margin-block-start: 5px; display: block; }
.byt-msg--me .byt-msg__time { color: rgba(255,255,255,.45); text-align: end; }

/* Day divider */
.byt-chat__divider { display: flex; align-items: center; gap: 10px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); }
.byt-chat__divider::before, .byt-chat__divider::after { content: ""; block-size: 1px; background: var(--line); flex: 1; }

/* Typing indicator */
.byt-typing { display: inline-flex; gap: 4px; align-items: center; padding-block: 4px; }
.byt-typing i {
  inline-size: 6px; block-size: 6px; border-radius: 50%;
  background: var(--text-mute); animation: byt-bounce 1.3s infinite;
}
.byt-typing i:nth-child(2) { animation-delay: .18s; }
.byt-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes byt-bounce { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* -- Property card inside a reply --------------------------------------- */
.byt-card {
  display: flex; gap: 11px; margin-block-start: 10px;
  padding: 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.byt-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.byt-card__img { inline-size: 62px; block-size: 62px; flex: none; object-fit: cover; border-radius: var(--r-xs); background: var(--bg-sunken); }
.byt-card__img--empty { display: grid; place-items: center; background: var(--ink-900); }
.byt-card__img--empty img { inline-size: 60%; opacity: .35; background: none; }
.byt-card__body { min-inline-size: 0; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.byt-card__title { font-size: var(--step--1); font-weight: 600; color: var(--text); line-height: 1.35; }
.byt-card__meta { font-size: var(--step--2); color: var(--text-mute); }
.byt-card__price { font-family: var(--font-num); font-size: var(--step--1); font-weight: 600; color: var(--accent-text); }

/* -- Quick replies ------------------------------------------------------ */
.byt-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 var(--sp-4) var(--sp-3); flex: none; background: var(--bg); }
.byt-chip {
  padding: 7px 13px;
  font-size: var(--step--2); font-weight: 600;
  color: var(--accent-text); background: var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--r-pill);
  transition: all var(--dur) var(--ease);
}
.byt-chip:hover { background: var(--gold-500); color: var(--ink-950); border-color: var(--gold-500); }

/* -- Composer ----------------------------------------------------------- */
.byt-chat__composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px var(--sp-4) var(--sp-4);
  background: var(--bg-raised);
  border-block-start: 1px solid var(--line);
}
.byt-chat__composer textarea {
  flex: 1; min-block-size: 42px; max-block-size: 120px;
  padding: 10px 14px; resize: none;
  font-size: var(--step--1); line-height: 1.5;
  border-radius: var(--r-lg);
  background: var(--bg);
}
.byt-chat__send {
  inline-size: 42px; block-size: 42px; flex: none;
  display: grid; place-items: center;
  background: var(--gold-500); color: var(--ink-950);
  border-radius: 50%;
  transition: background-color var(--dur) var(--ease), transform .18s var(--ease);
}
.byt-chat__send:hover:not(:disabled) { background: var(--gold-400); transform: scale(1.05); }
.byt-chat__send:disabled { opacity: .38; cursor: not-allowed; }
.byt-chat__send svg { inline-size: 19px; block-size: 19px; }
[dir="rtl"] .byt-chat__send svg { transform: scaleX(-1); }

.byt-chat__foot {
  flex: none; padding: 0 var(--sp-4) 10px;
  background: var(--bg-raised);
  font-size: 10px; color: var(--text-mute); text-align: center;
}
.byt-chat__foot a { color: var(--accent-text); }

/* -- Inline lead form --------------------------------------------------- */
.byt-lead {
  margin-block-start: 10px; padding: 13px;
  background: var(--bg); border: 1px solid var(--line);
  border-inline-start: 3px solid var(--gold-500);
  border-radius: var(--r-sm);
  display: flex; flex-direction: column; gap: 9px;
}
.byt-lead input { padding: 9px 12px; font-size: var(--step--2); }
.byt-lead .btn { padding: 9px 16px; font-size: var(--step--2); }
.byt-lead__note { font-size: 10px; color: var(--text-mute); line-height: 1.5; }

/* -- Escalation row (human handoff) ------------------------------------- */
.byt-handoff { display: flex; flex-wrap: wrap; gap: 7px; margin-block-start: 10px; }
.byt-handoff .btn { padding: 8px 14px; font-size: var(--step--2); flex: 1; min-inline-size: 120px; }
