/* דף הצ'אט של כלבו 24 – עברית מימין לשמאל, מותאם לטלפון ולמחשב */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #1d2433;
  --muted: #6b7385;
  --brand: #1f6f8b;
  --brand-dark: #17566c;
  --user: #1f6f8b;
  --bot: #ffffff;
  --border: #e1e5ec;
  --error-bg: #fdecec;
  --error-text: #a12626;
  --tag-bg: #e6f2f6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: linear-gradient(135deg, #1f6f8b 0%, #2a9d8f 55%, #e9c46a 100%) fixed;
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 16px;
}

[hidden] { display: none !important; }

.app { height: 100dvh; max-width: 720px; margin: 0 auto; }

/* --- מסכי סיסמה ושם --- */
.card-screen { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 12px 40px rgba(10, 30, 50, 0.25);
}
.brand { font-size: 26px; font-weight: 700; color: var(--brand); }
.brand.small { font-size: 18px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
label { font-weight: 600; margin-top: 8px; }
.error { color: var(--error-text); font-size: 14px; min-height: 1em; margin: 0; }

input {
  font: inherit; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

button {
  font: inherit; font-weight: 600; padding: 12px 18px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: 0.55; cursor: default; }
button.secondary { background: var(--tag-bg); color: var(--brand-dark); padding: 8px 14px; font-size: 14px; }

/* --- הצ'אט --- */
.chat { height: 100%; display: flex; flex-direction: column; background: var(--bg); box-shadow: 0 0 40px rgba(0, 0, 0, 0.18); }
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: linear-gradient(135deg, #1f6f8b, #2a9d8f); color: #fff;
}
.chat-header .brand, .chat-header .muted { color: #fff; }
.chat-header .muted { opacity: 0.85; }
.chat-header button.secondary { background: rgba(255, 255, 255, 0.18); color: #fff; border: 1px solid rgba(255, 255, 255, 0.45); }
.chat-header button.secondary:hover { background: rgba(255, 255, 255, 0.3); }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 14px; line-height: 1.5;
  display: flex; flex-direction: column; gap: 6px; word-wrap: break-word;
}
.bubble .text { white-space: pre-wrap; }
.order-id { unicode-bidi: isolate; white-space: nowrap; }
/* ב-RTL: start = ימין. הלקוח בימין, העוזר בשמאל */
.bubble.user { align-self: flex-start; background: var(--user); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-end; background: var(--bot); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { align-self: flex-end; background: var(--error-bg); color: var(--error-text); }
.retry { align-self: flex-start; }

.tag {
  align-self: flex-start; background: var(--tag-bg); color: var(--brand-dark);
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
}
.handoff {
  font-size: 14px; font-weight: 600; color: #1b5e20; background: #e8f5e9;
  border: 1px solid #a5d6a7; border-radius: 10px; padding: 8px 12px;
}

/* שלוש נקודות מהבהבות */
.typing { flex-direction: row; gap: 4px; padding: 14px 16px; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* שאלות מוכנות */
.quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 10px; }
.quick button {
  background: var(--surface); color: var(--brand-dark); border: 1px solid var(--brand);
  font-size: 14px; padding: 8px 12px; border-radius: 999px;
}
.quick button:hover { background: var(--tag-bg); }

.composer {
  display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.composer input { flex: 1; }
