/* IDi app (chat.idis-il.com). Colors from the website (assets/css/core.css). */
:root {
  --teal: #0093a3;
  --teal-dark: #00707d;
  --teal-pale: #edf7f8;
  --navy: #293141;
  --text: #2b2b2b;
  --muted: #6c757d;
  --border: #e5e5e5;
  --bg: #f7f7f7;
  --white: #ffffff;
  --alert: #ef1b4d;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 'Noto Sans Hebrew', Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal-dark); }

/* ------------------------------------------------------------ login */

.login {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  background: linear-gradient(180deg, var(--navy) 0, var(--navy) 38%, var(--bg) 38%);
}
.login-idi { width: 150px; height: auto; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .35)); }
.login h1 { margin: 6px 0 0; color: var(--white); font-size: 30px; }
.login-sub { margin: 0 0 22px; color: #c9d1dc; }
.login-form {
  width: 100%;
  max-width: 360px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: 0 12px 30px rgba(20, 26, 46, .08);
}
.login-form label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.login-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid #cfd4dc;
  border-radius: 10px;
  background: var(--white);
  font-size: 16px; /* 16px keeps iOS from zooming in */
}
.login-form input:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.login-form button {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--teal);
  color: var(--white);
  font-weight: 700;
}
.login-form button:disabled { opacity: .6; }
.login-error { color: var(--alert); font-size: 14px; min-height: 1.5em; margin: 0 0 8px; }
.login-note { font-size: 14px; color: var(--muted); }

/* ------------------------------------------------------------ chat layout */

.chat {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 10px 10px;
  background: var(--navy);
  color: var(--white);
  flex-shrink: 0;
}
.head-idi { width: 52px; height: auto; }
.head-title { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.head-title strong { font-size: 18px; }
.head-title span { font-size: 13px; color: #c9d1dc; }
.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: var(--white);
}

.install {
  background: var(--teal-pale);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.install span { flex: 1; }
.install button { border: 0; border-radius: 8px; padding: 6px 12px; background: var(--teal); color: var(--white); font-weight: 600; }
.install .link-btn { background: none; color: var(--muted); padding: 6px; }

.log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child, .msg ol:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 0 0 8px; padding-inline-start: 20px; }
.msg-assistant {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  border-start-start-radius: 4px;
}
.msg-user {
  align-self: flex-end;
  background: var(--teal);
  color: var(--white);
  border-start-end-radius: 4px;
  white-space: pre-wrap;
}
.msg-error { border-color: var(--alert); }
.msg-typing { display: flex; gap: 5px; padding: 14px 16px; }
.msg-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite;
}
.msg-typing span:nth-child(2) { animation-delay: .15s; }
.msg-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.sent {
  align-self: stretch;
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--teal-pale);
  font-size: 14px;
}
.sent span { display: block; color: var(--muted); }

.suggest {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 14px 10px;
  flex-shrink: 0;
}
.suggest:empty { display: none; }
.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--teal);
  border-radius: 999px;
  background: var(--white);
  color: var(--teal-dark);
  font-size: 14px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px calc(10px + var(--safe-bottom));
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 14px;
  border: 1px solid #cfd4dc;
  border-radius: 22px;
  resize: none;
  font-size: 16px;
  line-height: 1.4;
  overflow-y: hidden;
}
.composer textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.send, .mic {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
}
.send { background: var(--teal); color: var(--white); }
.send:disabled { opacity: .5; }
.mic { background: var(--teal-pale); color: var(--teal-dark); }
.mic[aria-pressed="true"] { background: var(--alert); color: var(--white); animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 27, 77, .45); }
  100% { box-shadow: 0 0 0 14px rgba(239, 27, 77, 0); }
}
.mic-status {
  margin: 0;
  padding: 0 16px calc(6px + var(--safe-bottom));
  background: var(--white);
  font-size: 13px;
  color: var(--muted);
}
.mic-status:empty { display: none; }

/* ------------------------------------------------------------ drawer */

.scrim { position: fixed; inset: 0; background: rgba(10, 14, 26, .45); z-index: 10; }
.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(84vw, 340px);
  z-index: 11;
  background: var(--white);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  box-shadow: 0 0 30px rgba(0, 0, 0, .2);
}
.drawer-head { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: baseline; gap: 8px; }
.drawer-head strong { font-size: 17px; flex: 1; }
.drawer-note { font-size: 12px; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 6px 0; flex: 1; overflow-y: auto; }
.history button {
  width: 100%;
  text-align: start;
  border: 0;
  background: none;
  padding: 10px 16px;
  display: block;
}
.history button[aria-current="true"] { background: var(--teal-pale); }
.history .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .d { display: block; font-size: 12px; color: var(--muted); }
.history .empty { padding: 16px; color: var(--muted); font-size: 14px; }
.drawer-foot { border-top: 1px solid var(--border); padding: 14px 16px calc(14px + var(--safe-bottom)); font-size: 14px; }
.quota-bar { height: 6px; border-radius: 3px; background: var(--bg); margin: 6px 0 12px; overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--teal); width: 0; }
.quota-bar i.high { background: var(--alert); }
.user-row { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--teal-dark); font-weight: 600; padding: 4px; }

@media (prefers-reduced-motion: reduce) {
  .msg-typing span, .mic[aria-pressed="true"] { animation: none; }
}
