/* ELKÜ kodulehe AI-abiline (2026-11-17): avalehe kast (.hp-abi, includes/sections/abi.php) ja nurganupp (.abi-w, includes/abi_widget.php). */

/* ---- ühine: vestluse mullid, näidisküsimused, vorm ---- */
.hp-abi-log { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.hp-abi-log[hidden], .hp-abi-chips[hidden] { display: none; }
.hp-abi-msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; font-size: .98rem; overflow-wrap: anywhere; }
.hp-abi-msg.q { align-self: flex-end; background: #399b15; color: #fff; border-bottom-right-radius: 4px; }
.hp-abi-msg.a { align-self: flex-start; background: #f3f6ee; color: #2c3324; border-bottom-left-radius: 4px; }
.hp-abi-msg.a a { color: #256b0d; font-weight: 600; text-decoration: underline; }
.hp-abi-msg.err { align-self: flex-start; background: #fdf1e3; color: #7a4d00; border-bottom-left-radius: 4px; }
.hp-abi-dots span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: #8aa37b; animation: hpAbiDot 1s infinite ease-in-out; }
.hp-abi-dots span:nth-child(2) { animation-delay: .15s; } .hp-abi-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes hpAbiDot { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
.hp-abi-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.hp-abi-chip { border: 1px solid #cfdcc3; background: #f7faf3; color: #2c3324; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .92rem; cursor: pointer; text-align: left; }
.hp-abi-chip:hover, .hp-abi-chip:focus-visible { border-color: #399b15; background: #eaf5e2; }
.hp-abi-form { display: flex; gap: 8px; position: relative; }
.hp-abi-form .hp-abi-q { flex: 1; min-width: 0; border: 1px solid #cfd6c6; border-radius: 12px; padding: 13px 14px; font: inherit; font-size: 1rem; background: #fff; color: #2c3324; }
.hp-abi-form .hp-abi-q:focus { outline: 2px solid rgba(57,155,21,.3); border-color: #399b15; }
.hp-abi-form button { border: 0; border-radius: 12px; background: #ef8f00; color: #fff; font: inherit; font-weight: 700; padding: 0 20px; min-height: 48px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.hp-abi-form button:disabled { opacity: .6; cursor: default; }
.abi-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.abi-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- veisepea: pilt + (vajadusel) animatsioon selle peal ---- */
.abi-face { position: relative; display: block; border-radius: 50%; overflow: hidden; background: #f3f1ea; flex: 0 0 auto; }
.abi-face img, .abi-face video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.abi-face video { opacity: 0; transition: opacity .2s; }
.abi-anim .abi-face video, .abi-face.is-anim video { opacity: 1; }

/* ---- avalehe kast ---- */
.hp-abi-card { max-width: 860px; margin: 0 auto; background: #fff; border: 1px solid #e3e8dc; border-radius: 20px; padding: 26px 28px; box-shadow: 0 10px 30px rgba(40,60,20,.07); }
.hp-abi-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.hp-abi-head h2 { margin: 0 0 4px; }
.hp-abi-head .sec-sub { margin: 0; }
.hp-abi-head .abi-face { width: 64px; height: 64px; border: 2px solid #e3e8dc; }
.hp-abi-note { margin: 12px 0 0; font-size: .82rem; color: #6c7462; }
.hp-abi-note a { color: inherit; text-decoration: underline; }

/* ---- nurganupp ja vestluse aken ---- */
.abi-w { position: fixed; right: 20px; bottom: 20px; z-index: 985; font-family: inherit; }
body.show-dbar .abi-w { bottom: calc(var(--ds-dbar-h, 56px) + 16px); }
.abi-launch { width: 66px; height: 66px; padding: 0; border: 3px solid #fff; border-radius: 50%; background: #f3f1ea; cursor: pointer; box-shadow: 0 6px 20px rgba(30,40,20,.28); display: block; transition: transform .15s ease, box-shadow .15s ease; position: relative; }
.abi-launch:hover, .abi-launch:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(30,40,20,.34); outline: none; }
.abi-launch .abi-face { width: 100%; height: 100%; }
.abi-launch::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 13px; height: 13px; border-radius: 50%; background: #399b15; border: 2px solid #fff; }
.abi-open .abi-launch { display: none; }
.abi-tease { position: absolute; right: 78px; bottom: 12px; width: max-content; max-width: 230px; background: #fff; color: #2c3324; border: 1px solid #dfe5d6; border-radius: 14px 14px 4px 14px; padding: 9px 30px 9px 12px; font-size: .9rem; line-height: 1.35; box-shadow: 0 6px 18px rgba(30,40,20,.16); cursor: pointer; animation: abiTease .3s ease-out; }
.abi-tease[hidden] { display: none; }
.abi-tease button { position: absolute; right: 4px; top: 2px; border: 0; background: none; font-size: 1.15rem; line-height: 1; color: #8a917f; cursor: pointer; padding: 4px 6px; }
@keyframes abiTease { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.abi-panel { width: 380px; max-width: calc(100vw - 24px); max-height: min(620px, calc(100vh - 110px)); background: #fff; border: 1px solid #dfe5d6; border-radius: 18px; box-shadow: 0 18px 50px rgba(30,40,20,.3); display: flex; flex-direction: column; overflow: hidden; animation: abiTease .2s ease-out; }
.abi-panel[hidden] { display: none; }
.abi-phead { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #2f3a2a; color: #fff; }
.abi-phead .abi-face { width: 42px; height: 42px; border: 2px solid rgba(255,255,255,.7); }
.abi-phead b { display: block; font-size: 1rem; line-height: 1.2; } .abi-phead span { display: block; font-size: .78rem; opacity: .8; }
.abi-phead > div { flex: 1; min-width: 0; }
.abi-phead button { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; }
.abi-phead button:hover { background: rgba(255,255,255,.24); }
.abi-plog { flex: 1; margin: 0; padding: 14px 14px 4px; max-height: none; min-height: 60px; }
.abi-pchips { padding: 12px 14px 0; margin: 0; }
.abi-pchips .hp-abi-chip { font-size: .88rem; padding: 7px 12px; }
.abi-pform { padding: 12px 14px 0; }
.abi-pform button { padding: 0 16px; }
.abi-pnote { margin: 0; padding: 8px 14px 12px; font-size: .74rem; line-height: 1.35; color: #7a8170; }
.abi-pnote a { color: inherit; text-decoration: underline; }

@media (max-width: 767px) {
  .abi-w { right: 12px; bottom: 76px; }                         /* mobiili alumise nupuriba kohal */
  .abi-launch { width: 58px; height: 58px; }
  .abi-tease { right: 68px; max-width: 200px; }
  .abi-open.abi-w { right: 0; left: 0; bottom: 0; z-index: 1200; }
  .abi-panel { width: 100%; max-width: none; max-height: 86vh; border-radius: 18px 18px 0 0; border-width: 1px 0 0; }
  .hp-abi-card { padding: 20px 16px; border-radius: 16px; }
  .hp-abi-card .hp-abi-form button span { display: none; }
  .hp-abi-msg { max-width: 96%; }
  .hp-abi-head .abi-face { width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) { .hp-abi-dots span, .abi-tease, .abi-panel { animation: none; } .abi-face video { display: none; } }
@media print { .abi-w { display: none; } }

/* ---- meeskonna vestlus (2026-11-17) ---- */
.hp-abi-msg.pend { opacity: .65; }
.hp-abi-msg.staff { background: #e9f2fb; color: #1d2c3a; border: 1px solid #cfe0f1; }
.hp-abi-who { display: block; font-size: .78rem; font-weight: 700; color: #2c5d8a; margin-bottom: 2px; }
.hp-abi-msg.sys { align-self: center; max-width: 94%; background: #fff8ea; color: #6b4e12; border: 1px dashed #e8c98a; font-size: .86rem; text-align: center; border-radius: 12px; }
.hp-abi-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.abi-panel .hp-abi-bar { padding: 10px 14px 0; margin: 0; }
.hp-abi-human { border: 1px solid #cfdcc3; background: #fff; color: #2f6f12; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; }
.hp-abi-human:hover { border-color: #399b15; background: #f1f8ec; }
.hp-abi-human[hidden], .hp-abi-state[hidden], .hp-abi-cform[hidden] { display: none; }
.hp-abi-state { font-size: .84rem; font-weight: 700; color: #2c5d8a; display: inline-flex; align-items: center; gap: 6px; }
.hp-abi-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #39a0e0; animation: hpAbiDot 1.2s infinite ease-in-out; }
.hp-abi-cform { flex: 1 1 100%; background: #f7faf3; border: 1px solid #dfe8d5; border-radius: 12px; padding: 10px; display: grid; gap: 6px; font-size: .86rem; }
.hp-abi-cform div { display: flex; gap: 6px; flex-wrap: wrap; }
.hp-abi-cform input { flex: 1 1 120px; min-width: 0; border: 1px solid #cfd6c6; border-radius: 10px; padding: 9px 10px; font: inherit; font-size: .9rem; }
.hp-abi-cform button { border: 0; border-radius: 10px; background: #399b15; color: #fff; font-weight: 700; padding: 0 14px; min-height: 40px; cursor: pointer; }
.hp-abi-cerr { color: #a33; }

/* 2026-11-17: suurem nupp + püsiv silt „Küsi abiliselt“, et abiline leitaks üles */
.abi-w { display: flex; align-items: flex-end; gap: 10px; }
.abi-launch { width: 84px; height: 84px; border-width: 4px; }
.abi-launch::after { width: 16px; height: 16px; right: 4px; bottom: 4px; }
.abi-label { order: -1; margin-bottom: 14px; background: #fff; border: 1px solid #dfe5d6; border-radius: 14px 14px 4px 14px; padding: 8px 14px; box-shadow: 0 6px 18px rgba(30,40,20,.16); text-align: left; cursor: pointer; font: inherit; color: #2c3324; line-height: 1.2; transition: transform .15s; }
.abi-label:hover { transform: translateY(-2px); }
.abi-label b { display: block; font-size: .95rem; color: #256b0d; }
.abi-label span { display: block; font-size: .76rem; color: #6c7462; margin-top: 2px; }
.abi-open .abi-label, .abi-w:has(.abi-tease:not([hidden])) .abi-label { display: none; }
.abi-tease { right: 96px; bottom: 22px; }
.abi-panel { order: 1; }
@media (max-width: 767px) {
  .abi-launch { width: 66px; height: 66px; border-width: 3px; }
  .abi-label { padding: 6px 10px; margin-bottom: 10px; }
  .abi-label span { display: none; }
  .abi-tease { right: 76px; }
}
/* 2026-11-17 (ülevaatus): telefonis ei kata abiline esimest ekraani — ainult ümmargune nupp, ilma mulli ja sildita */
@media (max-width: 767px) {
  .abi-tease, .abi-label { display: none !important; }
  .abi-launch { width: 56px; height: 56px; }
}

/* 2026-11-18 (kasutaja: abilise ikoon liiga väike, ei pane tähele): suurem nupp, roheline silt, pulseeriv rõngas */
.abi-launch { width: 112px; height: 112px; border-width: 4px; box-shadow: 0 10px 28px rgba(30,40,20,.32); }
.abi-launch::after { width: 20px; height: 20px; right: 6px; bottom: 6px; border-width: 3px; }
.abi-launch::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid #399b15; animation: abiRing 2.6s ease-out infinite; pointer-events: none; }
@keyframes abiRing { 0% { transform: scale(1); opacity: .75; } 70% { transform: scale(1.32); opacity: 0; } 100% { transform: scale(1.32); opacity: 0; } }
.abi-label { background: #399b15; border-color: #2f8411; margin-bottom: 26px; padding: 11px 18px; box-shadow: 0 8px 22px rgba(40,110,15,.35); }
.abi-label b { color: #fff; font-size: 1.08rem; }
.abi-label span { color: rgba(255,255,255,.88); font-size: .82rem; }
.abi-tease { right: 124px; bottom: 34px; }
@media (max-width: 767px) {
  .abi-launch { width: 70px; height: 70px; border-width: 3px; }
  .abi-launch::after { width: 15px; height: 15px; right: 3px; bottom: 3px; }
}
@media (prefers-reduced-motion: reduce) { .abi-launch::before { animation: none; opacity: 0; } }
