/* ============================================================
   HHload — app.css
   Auth modal · chat widget · install prompt · user chip
   ============================================================ */

body.no-scroll { overflow: hidden; }

/* ---------- Header user chip ---------- */
.user-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; min-width: 38px; padding: 0 14px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  font-family: var(--font); font-weight: 600; font-size: .88rem; color: var(--ink);
  cursor: pointer; transition: border-color .2s, box-shadow .2s;
}
.user-btn:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.user-btn.signed-in {
  padding: 0; width: 38px; min-width: 38px;
  background: linear-gradient(135deg, #7fc6bf, #4d9c95); color: #fff; border-color: transparent;
  font-weight: 800; font-size: .95rem;
}
.install-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1.5px dashed var(--teal); background: transparent;
  font-family: var(--font); font-weight: 700; font-size: .85rem; color: var(--teal-dark);
  cursor: pointer; transition: background .2s;
}
.install-btn:hover { background: var(--teal-soft); }
.install-btn[hidden] { display: none; }

/* ---------- Auth modal ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(38, 58, 62, .35);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
.auth-overlay.open { opacity: 1; visibility: visible; }
.auth-card {
  position: relative; width: min(430px, 100%);
  background: var(--surface); border-radius: 24px; padding: 36px 32px 28px;
  box-shadow: 0 30px 70px rgba(38, 58, 62, .22);
  transform: translateY(14px) scale(.98); transition: transform .25s;
  max-height: 92vh; overflow-y: auto;
}
.auth-overlay.open .auth-card { transform: none; }
.auth-card h3 { font-size: 1.35rem; letter-spacing: -.01em; margin-bottom: 8px; }
.auth-sub { font-size: .93rem; color: var(--ink-soft); margin-bottom: 22px; }
.auth-close {
  position: absolute; top: 14px; right: 16px; width: 32px; height: 32px;
  border: 0; background: transparent; font-size: 1.6rem; line-height: 1;
  color: var(--ink-soft); cursor: pointer; border-radius: 50%;
}
.auth-close:hover { background: var(--bg-tint); color: var(--ink); }

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--bg-tint); padding: 5px; border-radius: 999px; margin-bottom: 22px;
}
.auth-tab {
  border: 0; background: transparent; padding: 9px 0; border-radius: 999px;
  font-family: var(--font); font-weight: 700; font-size: .9rem; color: var(--ink-soft);
  cursor: pointer; transition: background .2s, color .2s;
}
.auth-tab.active { background: var(--surface); color: var(--teal-dark); box-shadow: var(--shadow); }

.auth-form { display: grid; gap: 16px; }
.auth-field { display: grid; gap: 7px; }
.auth-field label { font-size: .86rem; font-weight: 700; color: var(--ink); }
.auth-id-row { display: flex; gap: 8px; }
.auth-cca {
  font-family: var(--font); font-size: .9rem; font-weight: 600; color: var(--ink);
  padding: 12px 8px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--bg); max-width: 44%; cursor: pointer;
}
.auth-cca:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(99, 181, 174, .16);
}
.auth-cca[hidden] { display: none; }
.auth-field input {
  font-family: var(--font); font-size: .97rem; color: var(--ink);
  padding: 12px 15px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--bg); width: 100%; transition: border-color .2s, box-shadow .2s;
}
.auth-field input:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(99, 181, 174, .16);
}
.auth-code-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.auth-send {
  font-family: var(--font); font-weight: 700; font-size: .85rem;
  padding: 13px 16px; border-radius: 12px; border: 1.5px solid var(--teal);
  background: var(--teal-soft); color: var(--teal-dark); cursor: pointer; white-space: nowrap;
  transition: background .2s, opacity .2s;
}
.auth-send:hover { background: #d7ebe7; }
.auth-send:disabled { opacity: .55; cursor: default; }
.auth-sentto {
  font-size: .84rem; font-weight: 700; color: var(--ink); margin: -6px 0 0;
  word-break: break-all; direction: ltr; text-align: start;
}
.auth-sentto:empty { display: none; }
.auth-hint { font-size: .84rem; color: var(--teal-dark); margin: -4px 0 0; }
.auth-hint:empty { display: none; }
.auth-error { font-size: .84rem; color: #c9523c; margin: -4px 0 0; min-height: 1em; }
.btn-block { width: 100%; }
.auth-terms { font-size: .76rem; color: var(--ink-soft); line-height: 1.5; text-align: center; margin-top: 4px; }

/* ---------- Chat launcher ---------- */
.chat-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 250;
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #74c2bb, #3f918a); color: #fff;
  box-shadow: 0 14px 34px rgba(63, 145, 138, .38);
  display: grid; place-items: center; transition: transform .2s, box-shadow .2s, opacity .2s;
}
.chat-launcher:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 18px 40px rgba(63, 145, 138, .45); }
.chat-launcher.hidden { opacity: 0; pointer-events: none; transform: scale(.85); }
.chat-dot {
  position: absolute; top: 10px; right: 10px; width: 10px; height: 10px;
  border-radius: 50%; background: #ff8f6b; border: 2px solid #fff;
  animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .7; } }

/* ---------- Chat panel ---------- */
.chat-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 260;
  width: 384px; height: min(586px, calc(100vh - 48px));
  background: var(--surface); border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 70px rgba(38, 58, 62, .22);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(18px) scale(.98);
  transition: opacity .25s, transform .25s, visibility .25s;
}
.chat-panel.open { opacity: 1; visibility: visible; transform: none; }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #f2faf8, #fdf3ee);
}
.chat-avatar {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #74c2bb, #3f918a); color: #fff; font-weight: 800;
}
.chat-head-txt { display: grid; gap: 2px; flex: 1; min-width: 0; }
.chat-head-txt strong { font-size: .96rem; letter-spacing: -.01em; }
.chat-head-txt span { font-size: .76rem; color: var(--ink-soft); }
.chat-mode {
  font-size: .7rem; font-weight: 800; letter-spacing: .04em;
  padding: 4px 9px; border-radius: 999px;
  background: var(--teal-soft); color: var(--teal-dark); white-space: nowrap;
}
.chat-mode.human { background: #ffe9e2; color: #c2603f; }
.chat-close {
  border: 0; background: transparent; font-size: 1.5rem; line-height: 1;
  color: var(--ink-soft); cursor: pointer; width: 28px; height: 28px; border-radius: 50%;
}
.chat-close:hover { background: rgba(0,0,0,.05); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px;
  background: var(--bg);
}
.chat-guest { display: grid; gap: 16px; padding: 8px 0; }
.chat-guest p { font-size: .92rem; color: var(--ink-soft); }
.chat-error { font-size: .86rem; color: #c9523c; text-align: center; }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 88%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-who { font-size: .68rem; font-weight: 700; letter-spacing: .04em; color: var(--ink-soft); text-transform: uppercase; }
.msg-bubble {
  padding: 11px 15px; border-radius: 16px; font-size: .9rem; line-height: 1.55;
  background: var(--surface); box-shadow: var(--shadow); word-break: break-word;
  border-bottom-left-radius: 6px;
}
.msg.mine .msg-bubble {
  background: linear-gradient(135deg, #6fbdb6, #4d9c95); color: #fff;
  border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; box-shadow: none;
}
.msg.agent .msg-bubble { background: #fff4ef; border: 1px solid #ffd9cb; }
.msg-bubble.typing { color: var(--ink-soft); font-style: italic; }

.chat-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-human {
  border: 0; background: transparent; color: var(--coral-dark);
  font-family: var(--font); font-weight: 700; font-size: .8rem;
  padding: 0 4px 8px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.chat-input-row { display: flex; gap: 8px; align-items: center; }
.chat-input-row input {
  flex: 1; font-family: var(--font); font-size: .92rem; color: var(--ink);
  padding: 11px 15px; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--bg); transition: border-color .2s;
}
.chat-input-row input:focus { outline: none; border-color: var(--teal); }
.chat-input-row button {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #74c2bb, #3f918a); color: #fff;
  display: grid; place-items: center; flex: 0 0 auto; transition: transform .15s;
}
.chat-input-row button:active { transform: scale(.94); }

/* ---------- Install prompt ---------- */
.install-bar {
  position: fixed; left: 24px; bottom: 24px; z-index: 240;
  width: min(330px, calc(100vw - 48px));
  background: var(--surface); border-radius: 18px; padding: 18px 20px;
  box-shadow: 0 20px 46px rgba(38, 58, 62, .18);
  display: none; gap: 10px;
}
.install-bar.show { display: grid; }
.install-bar strong { font-size: .95rem; }
.install-bar p { font-size: .84rem; color: var(--ink-soft); }
.install-bar .install-actions { display: flex; gap: 10px; margin-top: 4px; }
.install-bar .btn-sm { padding: 9px 18px; font-size: .84rem; }
.install-skip {
  border: 0; background: transparent; color: var(--ink-soft);
  font-family: var(--font); font-size: .84rem; font-weight: 600; cursor: pointer;
}

/* ---------- RTL ---------- */
[dir="rtl"] .chat-launcher { right: auto; left: 24px; }
[dir="rtl"] .chat-panel { right: auto; left: 24px; }
[dir="rtl"] .install-bar { left: auto; right: 24px; }
[dir="rtl"] .msg.mine .msg-bubble { border-bottom-right-radius: 16px; border-bottom-left-radius: 6px; }

/* ---------- Mobile ---------- */
@media (max-width: 680px) {
  .install-btn { display: none; }
  .chat-launcher { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .chat-panel {
    right: 0; left: 0; bottom: 0; width: 100%;
    height: 100dvh; max-height: 100dvh; border-radius: 0;
  }
  [dir="rtl"] .chat-panel { left: 0; right: 0; }
  .install-bar { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .auth-card { padding: 30px 22px 24px; border-radius: 20px; }
  .chat-body { padding: 14px; }
}

/* legal links in footer */
.footer-legal { margin: 8px 0 0; font-size: .85rem; }
.footer-legal a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.footer-legal a:hover { color: var(--teal-dark); }
