/* styles.css — עיצוב צ'אט בסגנון וואטסאפ, RTL, mobile-first */

:root {
  --wa-header: #075e54;
  --wa-header-2: #128c7e;
  --wa-bg: #efeae2;
  --wa-bot: #ffffff;
  --wa-user: #d9fdd3;
  --wa-green: #25d366;
  --wa-green-dark: #128c7e;
  --wa-link: #027eb5;
  --text: #111b21;
  --muted: #667781;
  --shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #0b141a;
}

/* מסגרת "טלפון" ממורכזת בדסקטופ, מסך מלא בנייד */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--wa-bg);
  overflow: hidden;
}
@media (min-width: 500px) {
  .app {
    height: min(880px, 100dvh);
    margin-top: max(0px, calc((100dvh - 880px) / 2));
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  }
}

/* --- כותרת --- */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: linear-gradient(180deg, var(--wa-header-2), var(--wa-header));
  color: #fff;
  flex: 0 0 auto;
  z-index: 2;
}
.header .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  color: var(--wa-header);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
}
.header .title { font-weight: 600; font-size: 16px; line-height: 1.15; }
.header .subtitle { font-size: 12.5px; opacity: 0.9; min-height: 15px; }

/* --- אזור הצ'אט --- */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: var(--wa-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='none' stroke='%23d3cabd' stroke-width='1.1' stroke-opacity='0.5'%3E%3Ccircle cx='16' cy='16' r='4'/%3E%3Cpath d='M52 10l6 6-6 6-6-6z'/%3E%3Cpath d='M8 54c4-4 10-4 14 0'/%3E%3Cpath d='M58 50v12M52 56h12'/%3E%3Ccircle cx='40' cy='40' r='2.2'/%3E%3C/g%3E%3C/svg%3E");
}

.msg {
  position: relative;
  max-width: 82%;
  padding: 6px 9px 5px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: pop 0.16s ease-out;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg .msg-text { white-space: normal; }
.msg strong { font-weight: 700; }
.chat-link {
  color: var(--wa-link);
  text-decoration: underline;
  font-weight: 600;
  word-break: break-word;
}

/* חותמת זמן ו-וי-כפול */
.msg .time {
  display: block;
  text-align: end;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
  line-height: 1;
}
.msg .ticks { color: #53bdeb; font-size: 12px; letter-spacing: -2px; }

/* בועת בוט (נכנסת) — יישור לימין ב-RTL, זנב בפינה עליונה-ימנית */
.msg.bot {
  align-self: flex-start;
  background: var(--wa-bot);
  border-top-right-radius: 0;
}
.msg.bot::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 12px;
  background: var(--wa-bot);
  clip-path: polygon(0 0, 0 100%, 100% 0);
}

/* בועת משתמש (יוצאת) — יישור לשמאל, זנב בפינה עליונה-שמאלית */
.msg.user {
  align-self: flex-end;
  background: var(--wa-user);
  border-top-left-radius: 0;
}
.msg.user::after {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 12px;
  background: var(--wa-user);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}

/* מדיה */
.msg.media { padding: 3px; max-width: 78%; }
.msg.media img,
.msg.media video { display: block; width: 100%; border-radius: 6px; }
.msg.media audio { width: 250px; max-width: 100%; margin: 4px 2px; }
.media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 16px;
  background: #f3ede4;
  color: var(--muted);
  border: 1px dashed #c9bdae;
  border-radius: 6px;
}
.media-placeholder .ph-icon { font-size: 30px; }
.media-placeholder .ph-cap { font-size: 13px; }

/* חיווי הקלדה */
.msg.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  width: fit-content;
  padding: 12px 12px;
}
.msg.typing::after { display: none; }
.msg.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa5ab;
  animation: blink 1.2s infinite ease-in-out;
}
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* --- כפתורי מענה בתוך הצ'אט --- */
.replies {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: stretch;
  margin: 2px 0 6px;
  animation: pop 0.16s ease-out;
}
.reply-btn {
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--wa-bot);
  color: var(--wa-link);
  box-shadow: var(--shadow);
  text-align: center;
  text-decoration: none;
  display: block;
  transition: background 0.12s ease, transform 0.05s ease;
}
.reply-btn:hover { background: #f2fbff; }
.reply-btn:active { transform: scale(0.99); }
.reply-btn.primary { background: var(--wa-green); color: #fff; }
.reply-btn.primary:hover { background: #20c15c; }

/* תשובות שאלה — טקסט ארוך, יישור התחלה, פס ירוק שמסמן "לחיץ" */
.replies.choices .reply-btn {
  text-align: start;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
  border-inline-start: 3px solid var(--wa-green);
}
.replies.choices .reply-btn:hover { background: #f3fbf6; }

/* --- כרטיס טופס ליד --- */
.msg.form-card { max-width: 92%; padding: 10px; }
.lead-form { display: flex; flex-direction: column; gap: 8px; }
.lead-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}
.lead-form input {
  padding: 11px 12px;
  border: 1px solid #ccc;
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
}
.lead-form input:focus {
  outline: none;
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}
.lead-form .lead-consent {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
  margin: 2px 2px 0;
  cursor: pointer;
}
.lead-form .lead-consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin: 1px 0 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--wa-green);
  cursor: pointer;
}
.lead-form .reply-btn { margin-top: 4px; box-shadow: none; }
.lead-form .form-error {
  color: #c0392b;
  font-size: 13px;
  font-weight: 600;
  margin: 2px 2px -2px;
}

/* --- שורת קלט תחתונה (דקורטיבית, למראה וואטסאפ) --- */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #f0f2f5;
}
.composer-input {
  flex: 1;
  background: #fff;
  border-radius: 20px;
  padding: 10px 15px;
  color: #8696a0;
  font-size: 15px;
  box-shadow: var(--shadow);
  user-select: none;
}
.composer-mic {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--wa-green-dark);
  color: #fff;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: default;
  flex: 0 0 auto;
}
