/*
  Widgetul de chat — asistenta Seti.
  Paleta e cea a portalului: portocaliu #ff4500 pe fundal #0d1117.
  Se încarcă doar pe paginile unde widgetul chiar apare, deci regula care ascunde
  squad-promo pe mobil de mai jos e implicit limitată la acele pagini.
*/

:root {
  --seti-orange: #ff4500;
  --seti-bg: #0d1117;
  --seti-surface: #161b24;
  --seti-line: rgba(255, 255, 255, .08);
  --seti-text: #f1f5f9;
  --seti-muted: rgba(255, 255, 255, .5);
}

/* Pe mobil chatul și cardul de team finder ar sta unul peste altul. Chatul câștigă. */
@media (max-width: 600px) {
  #squad-promo {
    display: none !important;
  }
}

/* ---------- Butonul plutitor ---------- */

/*
  Straturi pe portal: squad-promo 700, header site 1000, meniu mobil 9999.
  Panoul trebuie peste header — pe mobil e pe tot ecranul, iar headerul îi acoperea
  bara cu butonul de închidere — dar sub meniul mobil, care rămâne deasupra a tot.
*/
#seti-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1090;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px) scale(.9);
  transition: opacity .35s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1),
              bottom .3s ease;
}

/*
  Cardul de team finder stă în același colț. Când apare, butonul urcă deasupra lui
  și coboară la loc când se închide. Înălțimea vine din squad-promo, măsurată la
  afișare. Doar pe desktop — pe mobil cardul e ascuns (vezi regula de mai sus).
*/
@media (min-width: 601px) {
  body.has-squad-promo #seti-launcher {
    bottom: calc(24px + var(--squad-promo-height, 200px) + 16px);
  }
}

#seti-launcher.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#seti-launcher.is-hidden {
  opacity: 0;
  transform: translateY(14px) scale(.9);
  pointer-events: none;
}

.seti-launcher-bubble {
  order: 1;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  padding: 0;
  border-radius: 12px;
  background: var(--seti-surface);
  border: 1px solid var(--seti-line);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  color: var(--seti-text);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 38px;
  transition: max-width .45s ease, padding .45s ease;
}

/* Trebuie să încapă cea mai lungă întrebare din `config/chat.php`, pe un rând. */
#seti-launcher.has-teaser .seti-launcher-bubble {
  max-width: 340px;
  padding: 0 15px;
}

#seti-launcher:hover .seti-launcher-bubble {
  border-color: rgba(255, 69, 0, .4);
}

.seti-launcher-avatar {
  order: 2;
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 50%;
  background: var(--seti-bg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 0 0 2px rgba(255, 69, 0, .55);
  transition: box-shadow .25s ease, transform .25s ease;
}

/*
  Inelul care pleacă din margine, se lărgește și se stinge. Doar cât timp chatul
  e închis (butonul n-are `is-hidden`). Un puls la 10 secunde, nu continuu.
*/
.seti-launcher-avatar::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid #ff4500;
  box-shadow: 0 0 14px rgba(255, 69, 0, .85);
  pointer-events: none;
  opacity: 0;
}

#seti-launcher.is-visible:not(.is-hidden) .seti-launcher-avatar::before {
  animation: seti-pulse-ring 10s ease-out infinite;
}

#seti-launcher.is-visible:not(.is-hidden) .seti-launcher-avatar {
  animation: seti-pulse-glow 10s ease-out infinite;
}

@keyframes seti-pulse-ring {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  18% {
    transform: scale(1.7);
    opacity: 0;
  }
  18.01%,
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@keyframes seti-pulse-glow {
  0%,
  8% {
    box-shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 0 0 3px #ff4500, 0 0 22px rgba(255, 69, 0, .8);
  }
  20%,
  100% {
    box-shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 0 0 2px rgba(255, 69, 0, .55);
  }
}

@media (prefers-reduced-motion: reduce) {
  #seti-launcher.is-visible:not(.is-hidden) .seti-launcher-avatar,
  #seti-launcher.is-visible:not(.is-hidden) .seti-launcher-avatar::before {
    animation: none;
  }
}

#seti-launcher:hover .seti-launcher-avatar {
  transform: scale(1.06);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .55), 0 0 0 3px var(--seti-orange);
}

.seti-launcher-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}

/* Punctul verde: semnalează că răspunde acum, nu că e cineva online. */
.seti-launcher-avatar::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid var(--seti-bg);
}

/* ---------- Panoul ---------- */

#seti-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  width: 396px;
  height: min(620px, calc(100vh - 48px));
  border-radius: 20px;
  background: var(--seti-bg);
  border: 1px solid var(--seti-line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .7);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .28s ease, transform .28s cubic-bezier(.34, 1.4, .64, 1);
}

#seti-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/*
  `display: flex` pe un selector de ID bate `[hidden] { display: none }` din
  stylesheetul browserului. Fără regula asta panoul rămâne în pagină invizibil,
  peste buton, și înghite clickul.
*/
#seti-panel[hidden] {
  display: none;
}

.seti-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 15px 18px;
  border-bottom: 1px solid var(--seti-line);
  background: linear-gradient(135deg, rgba(255, 69, 0, .13), transparent 65%);
}

.seti-header img {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 69, 0, .5);
}

.seti-header-meta {
  flex: 1;
  min-width: 0;
}

.seti-header-name {
  margin: 0;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 21px;
  letter-spacing: 1.6px;
  color: var(--seti-text);
}

.seti-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--seti-muted);
}

.seti-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.seti-icon-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 255, 255, .38);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.seti-icon-btn:hover {
  background: rgba(255, 255, 255, .07);
  color: var(--seti-text);
}

/* ---------- Mesaje ---------- */

.seti-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .14) transparent;
}

.seti-body::-webkit-scrollbar {
  width: 6px;
}

.seti-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14);
  border-radius: 3px;
}

.seti-msg {
  max-width: 84%;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: seti-in .3s ease both;
}

@keyframes seti-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.seti-msg-assistant {
  align-self: flex-start;
  border-radius: 4px 15px 15px 15px;
  background: var(--seti-surface);
  border: 1px solid var(--seti-line);
  color: rgba(255, 255, 255, .88);
}

.seti-msg-user {
  align-self: flex-end;
  border-radius: 15px 4px 15px 15px;
  background: linear-gradient(135deg, #ff5c1a, var(--seti-orange));
  color: #fff;
}

.seti-msg p {
  margin: 0 0 8px;
}

.seti-msg p:last-child {
  margin-bottom: 0;
}

.seti-msg a {
  color: #ff8b5e;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.seti-msg-user a {
  color: #fff;
}

.seti-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 15px;
  border-radius: 4px 15px 15px 15px;
  background: var(--seti-surface);
  border: 1px solid var(--seti-line);
}

.seti-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .45);
  animation: seti-bounce 1.3s infinite;
}

.seti-typing span:nth-child(2) { animation-delay: .18s; }
.seti-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes seti-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

.seti-error {
  align-self: center;
  max-width: 92%;
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .3);
  color: #fca5a5;
  font-size: 12.5px;
  text-align: center;
}

/* ---------- Sugestii ---------- */

.seti-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 0 4px;
}

.seti-chip {
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(255, 69, 0, .09);
  border: 1px solid rgba(255, 69, 0, .3);
  color: #ffb494;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.seti-chip:hover {
  background: rgba(255, 69, 0, .2);
  color: #fff;
}

/* ---------- Carduri inline (nume, escaladare) ---------- */

.seti-card {
  padding: 15px;
  border-radius: 14px;
  background: var(--seti-surface);
  border: 1px solid rgba(255, 69, 0, .22);
  animation: seti-in .3s ease both;
}

.seti-card-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--seti-text);
}

.seti-card-text {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--seti-muted);
}

.seti-field {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--seti-line);
  color: var(--seti-text);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  transition: border-color .18s ease;
}

.seti-field::placeholder {
  color: rgba(255, 255, 255, .28);
}

.seti-field:focus {
  outline: none;
  border-color: rgba(255, 69, 0, .55);
}

textarea.seti-field {
  resize: none;
  min-height: 72px;
  line-height: 1.5;
}

.seti-card-error {
  margin: 0 0 8px;
  font-size: 12px;
  color: #fca5a5;
}

.seti-btn {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  background: var(--seti-orange);
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 15px;
  letter-spacing: 1.4px;
  cursor: pointer;
  transition: opacity .18s ease;
}

.seti-btn:hover:not(:disabled) {
  opacity: .88;
}

.seti-btn:disabled {
  opacity: .5;
  cursor: default;
}

.seti-btn-ghost {
  width: 100%;
  margin-top: 7px;
  padding: 8px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--seti-muted);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  cursor: pointer;
}

.seti-btn-ghost:hover {
  color: var(--seti-text);
}

/* ---------- Zona de scris ---------- */

.seti-footer {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--seti-line);
  background: var(--seti-bg);
}

.seti-input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 7px 7px 7px 14px;
  border-radius: 14px;
  background: var(--seti-surface);
  border: 1px solid var(--seti-line);
  transition: border-color .18s ease;
}

.seti-input-row:focus-within {
  border-color: rgba(255, 69, 0, .45);
}

#seti-input {
  flex: 1;
  max-height: 108px;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--seti-text);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}

#seti-input:focus {
  outline: none;
}

#seti-input::placeholder {
  color: rgba(255, 255, 255, .3);
}

#seti-send {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 11px;
  background: var(--seti-orange);
  color: #fff;
  cursor: pointer;
  transition: opacity .18s ease, transform .18s ease;
}

#seti-send:hover:not(:disabled) {
  transform: scale(1.06);
}

#seti-send:disabled {
  opacity: .32;
  cursor: default;
  transform: none;
}

#seti-send svg {
  width: 17px;
  height: 17px;
}

.seti-foot-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, .3);
}

.seti-human-link {
  padding: 0;
  border: none;
  background: none;
  color: rgba(255, 255, 255, .42);
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  white-space: nowrap;
}

.seti-human-link:hover {
  color: #ffb494;
}

/* ---------- Mobil ---------- */

@media (max-width: 600px) {
  #seti-launcher {
    right: 16px;
    bottom: 16px;
  }

  #seti-launcher.has-teaser .seti-launcher-bubble {
    max-width: min(210px, calc(100vw - 120px));
    white-space: normal;
    line-height: 1.4;
    padding: 9px 12px;
  }

  .seti-launcher-avatar {
    width: 58px;
    height: 58px;
    flex-basis: 58px;
  }

  #seti-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: auto;
    height: 100dvh;
    border-radius: 0;
    border: none;
    transform-origin: bottom center;
  }

  /* Pe telefoanele cu breton, bara chatului ar intra sub ceasul sistemului. */
  .seti-header {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  /* Ținta de atingere pentru închidere trebuie să fie una de deget, nu de mouse. */
  .seti-icon-btn {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    background: rgba(255, 255, 255, .07);
    color: rgba(255, 255, 255, .75);
  }

  .seti-msg {
    max-width: 88%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #seti-launcher,
  #seti-panel,
  .seti-msg,
  .seti-card,
  .seti-launcher-bubble {
    transition: none;
    animation: none;
  }
}
