/* chat-widget.css — Farm Story theme */

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

/* Toggle button */
.fsmo-chat-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .48);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 28px rgba(26, 92, 58, .22);
  background: linear-gradient(145deg, rgba(255, 255, 255, .5), rgba(210, 235, 215, .38) 52%, rgba(170, 210, 180, .3)), rgba(220, 240, 225, .65);
  color: #fff;
  position: relative;
  transition: transform .15s ease, box-shadow .2s ease;
  font-size: 21px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.fsmo-chat-toggle i {
  color: #2d8a56;
}

.fsmo-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 34px rgba(26, 92, 58, .3);
}

.fsmo-chat-toggle:active {
  transform: translateY(0);
}

/* Pulse rings */
.fsmo-chat-toggle::before,
.fsmo-chat-toggle::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(45, 138, 86, .45);
  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.7;
  }

  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

/* LIVE dot */
.fsmo-chat-live-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  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.3;
  }
}

/* Panel */
.fsmo-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(92vw, 380px);
  height: min(620px, calc(100vh - 190px));
  max-height: 76vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(255, 255, 255, .42);
  color: #1a2e1a;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 18px 48px rgba(0, 0, 0, .14);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  overflow: hidden;
  animation: fsmo-pop .18s ease;
}

.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(45, 138, 86, .1), rgba(255, 255, 255, 0));
  padding: 11px 14px;
  border-bottom: 1px solid rgba(100, 150, 100, .14);
}

.fsmo-chat-header .title {
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  gap: 8px;
  align-items: center;
  color: #1a5c3a;
}

.fsmo-chat-header .title i {
  color: #2d8a56;
}

.fsmo-chat-close {
  background: transparent;
  border: 0;
  color: #5d805d;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}

.fsmo-chat-close:hover {
  background: rgba(255, 255, 255, .6);
  color: #1a5c3a;
}

/* Body */
.fsmo-chat-body {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

/* Messages */
#fsmoChatMessages {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .12);
}

#fsmoChatMessages::-webkit-scrollbar {
  width: 8px;
}

#fsmoChatMessages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .1);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Bubbles */
.fsmo-msg {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
}

.fsmo-msg .bubble {
  display: inline-block;
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px;
  word-break: break-word;
  line-height: 1.4;
  font-size: .88rem;
}

/* Admin (stanga) */
.fsmo-msg.from-admin {
  align-items: flex-start;
}

.fsmo-msg.from-admin .bubble {
  background: rgba(255, 255, 255, .62);
  color: #1a2e1a;
  border: 1px solid rgba(120, 160, 120, .14);
  border-top-left-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
}

/* User (dreapta) */
.fsmo-msg.from-user {
  align-items: flex-end;
}

.fsmo-msg.from-user .bubble {
  background: linear-gradient(135deg, #1a5c3a, #2d8a56);
  color: #fff;
  border-top-right-radius: 6px;
  box-shadow: 0 4px 12px rgba(26, 92, 58, .25);
}

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

/* Form */
#fsmoChatForm {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(100, 150, 100, .12);
  background: rgba(255, 255, 255, .18);
}

#fsmoChatForm .row {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

#fsmoChatForm label {
  font-size: 12px;
  font-weight: 600;
  color: #4e6a4e;
}

#fsmoChatForm input[type="text"],
#fsmoChatForm input[type="email"],
#fsmoChatForm textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(120, 160, 120, .16);
  background: rgba(255, 255, 255, .55);
  color: #1a2e1a;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

#fsmoChatForm textarea {
  min-height: 80px;
  resize: vertical;
}

#fsmoChatForm input:focus,
#fsmoChatForm textarea:focus {
  border-color: rgba(45, 138, 86, .4);
  box-shadow: 0 0 0 3px rgba(45, 138, 86, .12);
}

/* Actions */
#fsmoChatForm .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

#fsmoSendBtn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #1a5c3a, #2d8a56);
  color: #fff;
  font-family: inherit;
  box-shadow: 0 6px 18px rgba(26, 92, 58, .22);
  transition: transform .08s ease, box-shadow .2s ease, opacity .2s ease;
}

#fsmoSendBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(26, 92, 58, .3);
}

#fsmoSendBtn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

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

/* Mobile */
@media (max-width: 600px) {
  .fsmo-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    min-height: 0;
    max-height: 100%;
    border-radius: 0;
    border: none;
    display: grid;
    grid-template-rows: auto 1fr;
  }

  .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: rgba(255, 255, 255, .35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 1;
  }

  #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;
  }
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {

  .fsmo-chat-toggle,
  .fsmo-chat-panel {
    animation: none !important;
    transition: none !important;
  }
}