/* css/chat-widget.css */

/* Root */
.fsmo-chat-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  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: 56px;
  height: 56px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.2);
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}
.fsmo-chat-toggle:hover { transform: translateY(-1px); box-shadow: 0 16px 40px rgba(0,0,0,.4), 0 4px 10px rgba(0,0,0,.25); }
.fsmo-chat-toggle:active { transform: translateY(0); }

/* 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: #0b1220; /* dark slate */
  color: #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 2px 10px rgba(0,0,0,.3);
  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(34,197,94,.18), rgba(34,197,94,0));
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.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: #cbd5e1;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}
.fsmo-chat-close:hover { background: rgba(255,255,255,.06); color: #fff; }

/* 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(34,197,94,.08), transparent 60%),
    radial-gradient(900px 600px at -20% 10%, rgba(59,130,246,.06), transparent 55%),
    #0b1220;
}

/* 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: #111827; /* zinc-900 */
  color: #e5e7eb;
  border-top-left-radius: 6px;
  border: 1px solid rgba(255,255,255,.06);
}

/* User (dreapta) */
.fsmo-msg.from-user { align-items: flex-end; }
.fsmo-msg.from-user .bubble {
  background: #10b981; /* emerald-500 */
  color: #062b1f;
  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(255,255,255,.06);
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
}
#fsmoChatForm .row {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}
#fsmoChatForm label {
  font-size: 12px;
  color: #cbd5e1;
}
#fsmoChatForm input[type="text"],
#fsmoChatForm input[type="email"],
#fsmoChatForm textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(15,23,42,.85);
  color: #e5e7eb;
  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(34,197,94,.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,.22);
}

/* 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, #16a34a, #22c55e);
  color: #052e1c;
  box-shadow: 0 8px 22px rgba(16,185,129,.35);
  transition: transform .08s ease, box-shadow .2s ease, opacity .2s ease;
}
#fsmoSendBtn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(16,185,129,.42); }
#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 tweaks */
@media (max-width: 520px) {
  .fsmo-chat-panel {
    right: 0;
    bottom: 72px;
    width: min(96vw, 420px);
    max-height: 78vh;
    border-radius: 16px;
  }
  #fsmoChatMessages { max-height: 56vh; }
}

/* 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; }
}