/* ============================================================
   מאיה - עיצוב הממשק
   צבעים אך ורק מטוקני המותג (tokens.css, ערכת מותג פסטמן):
   רקע 24231F / משטח 25232B / משטח משני 343043 / אקצנט 896EC0 /
   אינדיגו 4A3B7A / טקסט משני B4A8E4. כחול לילה 202239 - לעולם לא רקע.
   מובייל: סרגל ניווט תחתון. מחשב (880 ומעלה): כותרת עליונה + תוכן רחב.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;700;800&family=Sora:wght@600;700;800&display=swap');

:root {
  --bg: #24231F;          /* רקע ראשי - אפור-חום עמוק (--ms-bg) */
  --surface: #25232B;     /* כרטיס/משטח (--ms-surface) */
  --surface-2: #343043;   /* משטח משני (--ms-surface-2) */
  --accent: #896EC0;      /* סגול לבנדר - אקצנט ראשי (--ms-accent) */
  --accent-hover: #7857B0;
  --deep: #4A3B7A;        /* אינדיגו עמוק - כפתורים משניים (--ms-indigo) */
  --text: #FFFFFF;        /* טקסט ראשי (--ms-text) */
  --muted: #B4A8E4;       /* טקסט משני - לבנדר בהיר (--ms-text-muted) */
  --border: rgba(180, 168, 228, 0.16); /* (--ms-border) */
  --ok: #6fcf97;          /* מצב הצלחה תפעולי */
  --radius: 8px;          /* (--ms-radius) */
  --nav-h: 58px;          /* גובה כותרת עליונה במחשב (--ms-nav-height) */
}

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

html { direction: rtl; }

body {
  font-family: 'Heebo', 'Sora', -apple-system, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  direction: rtl;
  text-align: right;
  line-height: 1.6;
}

/* ---------- מעטפת עמוד ---------- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 84px; /* מקום לסרגל הניווט התחתון במובייל */
}

h1 { font-size: 1.35rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* כפתורי הכותרת (שיחה חדשה / מצב נהיגה) - גלולות עדינות, לא כפתוני מערכת */
h1 .expand-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
h1 .expand-btn:hover { border-color: var(--accent); color: var(--accent); }
h2 { font-size: 1.05rem; font-weight: 700; color: var(--muted); }

.brand-mark {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--deep);
  color: var(--text);
  min-height: 44px; /* יעד מגע נוח במובייל */
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-hover); filter: none; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- טפסים ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.9rem; }

.input-wrap { position: relative; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  direction: rtl;
  text-align: right;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* עין הסיסמה: משמאל לשדה (סוף השורה בכיוון ימין-לשמאל) */
.eye-btn {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  line-height: 0;
}
.eye-btn:hover { color: var(--accent); }
.input-wrap input[type="password"], .input-wrap input[type="text"] { padding-left: 44px; }

/* ---------- מסך כניסה ---------- */
.login-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  max-width: 420px;
  margin: 0 auto;
}
.login-title { text-align: center; margin-bottom: 32px; }
.login-title .brand-mark { font-size: 2rem; display: block; margin-bottom: 8px; }
.login-error { color: #ef8e8e; font-size: 0.9rem; min-height: 1.2em; margin-bottom: 10px; }

/* ---------- צ'אט ---------- */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.msg {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user { background: var(--deep); align-self: flex-start; }   /* המשתמש: צד ימין בזרימת rtl */
.msg-maya { background: var(--surface-2); border: 1px solid var(--border); align-self: flex-end; }

/* תקרת מלל בכרטיס: הקיטום נעשה בקוד, הכפתור מרחיב */
.msg .expand-btn {
  display: block;
  margin-top: 8px;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.chat-input-row {
  position: fixed;
  bottom: 64px;
  right: 0; left: 0;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap; /* מובייל: שדה הכתיבה בשורה מלאה, הכפתורים מתחתיו */
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
}
.chat-input-row textarea { resize: none; height: 48px; flex: 1 1 100%; min-width: 0; }
.chat-input-row .btn { flex: 1 1 auto; min-height: 42px; padding: 8px 10px; font-size: 0.9rem; }

/* צ'אט: מרווח תחתון גדול - שתי שורות קלט + סרגל ניווט */
.chat-page { padding-bottom: 200px; }

@media (min-width: 480px) {
  .chat-input-row { flex-wrap: nowrap; }
  .chat-input-row textarea { flex: 1 1 auto; }
  .chat-input-row .btn { flex: 0 0 auto; }
  .chat-page { padding-bottom: 150px; }
}

/* ---------- יומן פעולות ---------- */
.action-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.action-item input[type="checkbox"] {
  width: 20px; height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
}
.action-item .meta { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.action-item.done { opacity: 0.55; }
.action-item.done .title { text-decoration: line-through; }

.actions-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ---------- לוח מגמות ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-card .num { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.stat-card .lbl { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .bar-label { width: 110px; font-size: 0.9rem; color: var(--muted); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; background: var(--surface-2); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar-row .bar-val { width: 34px; font-size: 0.85rem; color: var(--muted); text-align: left; }

/* ---------- ניווט: סרגל תחתון במובייל, כותרת עליונה במחשב ---------- */
.nav-bar {
  position: fixed;
  bottom: 0; right: 0; left: 0;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav-bar a {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.nav-bar a.active { color: var(--accent); }

/* מותג בכותרת (לוגו + שם): נסתר במובייל, מוצג במחשב */
.nav-brand { display: none; }

/* ---------- הודעת דגימה (מצב הדגמה) ---------- */
.mock-note {
  background: var(--surface-2);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.8rem;
  margin-bottom: 14px;
  text-align: center;
}

/* ---------- מסכים רחבים: נראות אתר מלאה ---------- */
@media (min-width: 880px) {
  /* הניווט הופך לכותרת עליונה קבועה לכל רוחב המסך */
  .nav-bar {
    top: 0; bottom: auto;
    max-width: none;
    height: var(--nav-h);
    align-items: center;
    gap: 4px;
    padding: 0 clamp(16px, 4vw, 48px);
    border-top: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  }
  .nav-bar a {
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 0.95rem;
    border-radius: var(--radius);
  }
  .nav-bar a:hover { color: var(--text); background: var(--surface-2); }
  .nav-bar a.active { color: var(--accent); background: var(--surface-2); }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto; /* דוחף את הקישורים לשמאל בזרימת ימין-לשמאל */
    text-decoration: none;
  }
  .nav-brand img { height: 26px; display: block; }
  .nav-brand .brand-mark { font-size: 1.1rem; }

  /* התוכן יורד מתחת לכותרת ומתרחב לרוחב אתר */
  .page {
    max-width: 1100px;
    padding: 32px clamp(24px, 4vw, 48px);
    padding-top: calc(var(--nav-h) + 28px);
    padding-bottom: 48px;
  }

  /* צ'אט: טור קריאה נוח במרכז, שורת הקלט צמודה לתחתית החלון */
  .chat-page { max-width: 860px; padding-bottom: 140px; }
  .msg { max-width: 72%; }
  .chat-input-row {
    bottom: 0;
    max-width: 860px;
    padding: 14px clamp(24px, 4vw, 48px) 18px;
    border-top: 1px solid var(--border);
  }

  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }

  h1 { font-size: 1.7rem; }
}
