/* css/chat-widget.css */

/* Root */
.fsmo-chat-root {
  position: fixed;
  right: 18px;
  bottom: 95px; /* deasupra cookie banner-ului */
  z-index: 9999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}

/* Toggle button */
.fsmo-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.58);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.78), 0 18px 38px rgba(49,89,120,.24);
  background:
    linear-gradient(145deg, rgba(255,255,255,.58), rgba(220,233,238,.38) 52%, rgba(174,199,209,.3)),
    rgba(226,237,241,.76);
  color: #fff;
  position: relative;
  transition: transform .15s ease, box-shadow .2s ease;
  font-size: 22px;
  backdrop-filter: blur(24px) saturate(1.45);
  -webkit-backdrop-filter: blur(24px) saturate(1.45);
}
.fsmo-chat-toggle i {
  color: #3178ff;
  text-shadow: 0 8px 20px rgba(49,120,255,.28);
}
.fsmo-chat-toggle:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.86), 0 22px 46px rgba(49,89,120,.3); }
.fsmo-chat-toggle:active { transform: translateY(0); }

/* Pulse rings — "live support" effect */
.fsmo-chat-toggle::before,
.fsmo-chat-toggle::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 2px solid rgba(49,120,255,.55);
  opacity: 0;
  pointer-events: none;
}
.fsmo-chat-toggle::before { animation: chat-ring 2.2s ease-out infinite; }
.fsmo-chat-toggle::after  { animation: chat-ring 2.2s ease-out infinite 0.9s; }

@keyframes chat-ring {
  0%   { transform: scale(1);   opacity: 0.75; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* "LIVE" dot pe toggle */
.fsmo-chat-live-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 11px; height: 11px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: live-blink 1.4s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* Panel */
.fsmo-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(92vw, 380px);
  max-height: 76vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    linear-gradient(145deg, rgba(255,255,255,.6), rgba(220,233,238,.42) 54%, rgba(174,199,209,.3)),
    rgba(226,237,241,.84);
  color: #17313a;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.78), 0 22px 54px rgba(51,77,91,.24);
  backdrop-filter: blur(28px) saturate(1.45);
  -webkit-backdrop-filter: blur(28px) saturate(1.45);
  overflow: hidden;
  animation: fsmo-pop .18s ease;
}

/* * MODIFICARE: Această regulă forțează panoul să fie ascuns
* dacă are atributul [hidden]. Fără !important, regula
* "display: grid" de mai sus o suprascrie.
*/
.fsmo-chat-panel[hidden] {
  display: none !important;
}


@keyframes fsmo-pop {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Header */
.fsmo-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(49,120,255,.14), rgba(255,255,255,0));
  padding: 10px 12px;
  border-bottom: 1px solid rgba(40,72,86,.13);
}
.fsmo-chat-header .title {
  font-weight: 700;
  letter-spacing: .2px;
  display: flex; gap: 8px; align-items: center;
}
.fsmo-chat-close {
  background: transparent;
  border: 0;
  color: #526b73;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}
.fsmo-chat-close:hover { background: rgba(255,255,255,.5); color: #3178ff; }

/* Body */
.fsmo-chat-body {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 320px;
  max-height: 76vh;
}

/* Mesaje – lista e creată de JS cu id=fsmoChatMessages */
#fsmoChatMessages {
  overflow-y: auto;
  padding: 10px 14px;
  background:
    radial-gradient(1200px 600px at 90% 120%, rgba(64,185,162,.12), transparent 60%),
    radial-gradient(900px 600px at -20% 10%, rgba(49,120,255,.12), transparent 55%),
    rgba(255,255,255,.22);
}

/* Bare de scroll fine */
#fsmoChatMessages::-webkit-scrollbar { width: 10px; }
#fsmoChatMessages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
#fsmoChatMessages:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); }

/* Bule */
.fsmo-msg { margin: 8px 0; display: flex; flex-direction: column; }
.fsmo-msg .bubble {
  display: inline-block;
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 16px;
  word-break: break-word;
  line-height: 1.35;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* Admin (stânga) */
.fsmo-msg.from-admin { align-items: flex-start; }
.fsmo-msg.from-admin .bubble {
  background: rgba(226,237,241,.62);
  color: #17313a;
  border-top-left-radius: 6px;
  border: 1px solid rgba(40,72,86,.12);
}

/* User (dreapta) */
.fsmo-msg.from-user { align-items: flex-end; }
.fsmo-msg.from-user .bubble {
  background: linear-gradient(135deg, #3178ff, #40b9a2);
  color: #fff;
  border-top-right-radius: 6px;
}

/* Meta timp */
.fsmo-msg .meta {
  font-size: 11px;
  opacity: .65;
  margin-top: 4px;
}

/* Formular */
#fsmoChatForm {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(40,72,86,.13);
  background: linear-gradient(180deg, rgba(255,255,255,.24), rgba(255,255,255,0));
}
#fsmoChatForm .row {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}
#fsmoChatForm label {
  font-size: 12px;
  color: #526b73;
}
#fsmoChatForm input[type="text"],
#fsmoChatForm input[type="email"],
#fsmoChatForm textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(58,90,105,.18);
  background: rgba(226,237,241,.58);
  color: #17313a;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#fsmoChatForm textarea { min-height: 86px; resize: vertical; }
#fsmoChatForm input:focus,
#fsmoChatForm textarea:focus {
  border-color: rgba(49,120,255,.42);
  box-shadow: 0 0 0 3px rgba(49,120,255,.16);
}

/* Actions */
#fsmoChatForm .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
#fsmoSendBtn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #3178ff, #40b9a2);
  color: #fff;
  box-shadow: 0 8px 22px rgba(49,120,255,.28);
  transition: transform .08s ease, box-shadow .2s ease, opacity .2s ease;
}
#fsmoSendBtn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(49,120,255,.34); }
#fsmoSendBtn:disabled { opacity: .6; cursor: not-allowed; }

/* Status */
.fsmo-chat-status {
  margin: 6px 2px 0;
  min-height: 18px;
  font-size: 12px;
  letter-spacing: .2px;
}

/* Mobile — chat panel fullscreen, se adaptează la tastatură via JS */
@media (max-width: 600px) {
  /* Panoul: fullscreen, JS îi setează top+height când tastatura apare */
  .fsmo-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* JS suprascrie cu visualViewport.height */
    max-height: 100%;
    border-radius: 0;
    border: none;
    display: grid;
    grid-template-rows: auto 1fr;
    /* NU transform pe root — ar strica fixed positioning */
  }

  .fsmo-chat-header {
    padding: 14px 16px;
    min-height: 54px;
  }

  #fsmoChatMessages {
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #fsmoChatForm {
    position: sticky;
    bottom: 0;
    background: #0b1220;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 1;
  }

  /* font 16px previne zoom automat pe iOS */
  #fsmoChatForm textarea,
  #fsmoChatForm input[type="text"],
  #fsmoChatForm input[type="email"] {
    font-size: 16px;
  }

  #fsmoChatForm textarea { min-height: 50px; max-height: 110px; }
  #fsmoSendBtn { padding: 12px 18px; font-size: 15px; }
}

/* Clasa utilitară pentru a ascunde câmpurile Name/Email */
.hidden {
  display: none !important;
}

/* Reduce-motion */
@media (prefers-reduced-motion: reduce) {
  .fsmo-chat-toggle, .fsmo-chat-panel { animation: none !important; transition: none !important; }
}
