/* Pływający asystent przy prawym dolnym rogu okna. */

.ev-live-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: inline-flex;
  vertical-align: middle;
  margin: 0;
  z-index: 9999;
  font-family: var(--wp--preset--font-family--data);
}

/* --- FAB: the green round chat button stays as on the live site; the amber
   lightning identity is used inside the panel only. --- */

.ev-live-chat__fab {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: #3fb950;
  color: #0d1117;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(63, 185, 80, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ev-live-chat__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(63, 185, 80, 0.45), 0 3px 8px rgba(0, 0, 0, 0.45);
}

.ev-live-chat__fab::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(63, 185, 80, 0.55);
  animation: ev-chat-ring 2.2s ease-out infinite;
}

@keyframes ev-chat-ring {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.ev-live-chat__fab-icon {
  display: flex;
  line-height: 0;
}

.ev-live-chat__fab-icon svg {
  display: block;
}

.ev-live-chat.is-open .ev-live-chat__fab {
  visibility: hidden;
  pointer-events: none;
}

/* --- Panel --- */

.ev-live-chat__panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 10000;
  width: 340px;
  max-width: calc(100vw - 2.5rem);
  height: 460px;
  max-height: calc(100vh - 6rem);
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.92) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.16s ease;
}

.ev-live-chat__panel.is-resizing {
  transition: none;
  user-select: none;
}

.ev-live-chat__panel.is-minimized {
  height: 96px !important;
  max-height: 96px;
}

.ev-live-chat__panel.is-minimized .ev-live-chat__context,
.ev-live-chat__panel.is-minimized .ev-live-chat__messages,
.ev-live-chat__panel.is-minimized .ev-live-chat__notice,
.ev-live-chat__panel.is-minimized .ev-live-chat__typing,
.ev-live-chat__panel.is-minimized .ev-live-chat__handoff,
.ev-live-chat__panel.is-minimized .ev-live-chat__composer {
  display: none !important;
}

.ev-live-chat__resize {
  flex: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-bottom: 1px solid #30363d;
  background: #0d1117;
  cursor: ns-resize;
  touch-action: none;
}

.ev-live-chat__resize:focus-visible {
  outline: 2px solid #f5a623;
  outline-offset: -2px;
}

.ev-live-chat__resize-grip {
  width: 2.5rem;
  height: 3px;
  border-radius: 3px;
  background: #8b949e;
  transition: background 0.15s ease;
}

.ev-live-chat__resize:hover .ev-live-chat__resize-grip,
.ev-live-chat__resize:focus-visible .ev-live-chat__resize-grip {
  background: #f5a623;
}

.ev-live-chat.is-open .ev-live-chat__panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.ev-live-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: #0d1117;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.ev-live-chat__header-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ev-live-chat__brand {
  font-family: var(--wp--preset--font-family--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #f0f6fc;
}

.ev-live-chat__status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #f5a623;
}

.ev-live-chat__availability {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.42rem;
  max-width: 100%;
  margin-top: 0.08rem;
  padding: 0.2rem 0.52rem;
  border: 1px solid rgba(245, 166, 35, 0.38);
  border-radius: 999px;
  color: #ffd27b;
  background: rgba(245, 166, 35, 0.08);
  font-size: 0.68rem;
  line-height: 1.25;
}

.ev-live-chat__availability[hidden] {
  display: none;
}

.ev-live-chat__availability-indicator {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #f5a623;
}

.ev-live-chat__availability.is-operator .ev-live-chat__availability-indicator {
  background: #8b949e;
}

.ev-live-chat__availability.is-operator-joined .ev-live-chat__availability-indicator {
  background: #3fb950;
}

.ev-live-chat__header-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.25rem;
}

.ev-live-chat__reset,
.ev-live-chat__minimize,
.ev-live-chat__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #b1bac4;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ev-live-chat__reset {
  font-size: 1.35rem;
}

.ev-live-chat__reset:hover,
.ev-live-chat__minimize:hover,
.ev-live-chat__close:hover {
  color: #ffd27b;
  background: #21262d;
  border-color: #3d444d;
}

.ev-live-chat__reset:focus-visible,
.ev-live-chat__minimize:focus-visible,
.ev-live-chat__close:focus-visible {
  outline: 2px solid #f5a623;
  outline-offset: 2px;
}

.ev-live-chat__reset:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* --- Compact product context --- */

.ev-live-chat__context {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.1rem;
  background: rgba(245, 166, 35, 0.06);
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

.ev-live-chat__context-info {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.ev-live-chat__context-image {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid #454c56;
  border-radius: 5px;
  background: #161b22;
  object-fit: cover;
}

.ev-live-chat__context-image[hidden] {
  display: none;
}

.ev-live-chat__context-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #f5a623;
}

.ev-live-chat__context-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f0f6fc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ev-live-chat__context-sku {
  color: #8b949e;
  font-size: 0.66rem;
  line-height: 1.25;
}

.ev-live-chat__context-sku[hidden] {
  display: none;
}

.ev-live-chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ev-live-chat__msg {
  max-width: 82%;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.4;
}

.ev-live-chat__msg p {
  margin: 0 0 0.25rem;
}

.ev-live-chat__msg--them {
  align-self: flex-start;
  background: #21262d;
  border: 1px solid #30363d;
  color: #f0f6fc;
  border-bottom-left-radius: 3px;
}

.ev-live-chat__msg--me {
  align-self: flex-end;
  background: rgba(245, 166, 35, 0.15);
  border: 1px solid rgba(245, 166, 35, 0.4);
  color: #f0f6fc;
  border-bottom-right-radius: 3px;
}

.ev-live-chat__msg--ai .ev-live-chat__from {
  color: #f5a623;
}

.ev-live-chat__sources {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.4rem;
  font-size: 0.72rem;
}

.ev-live-chat__sources a {
  color: #79c0ff;
  overflow-wrap: anywhere;
}

.ev-live-chat__typing {
  flex-shrink: 0;
  margin: 0;
  padding: 0.3rem 1rem;
  color: #8b949e;
  font-size: 0.76rem;
}

.ev-live-chat__handoff {
  align-self: flex-end;
  flex-shrink: 0;
  margin: 0 0.75rem 0.35rem;
  padding: 0.34rem 0.62rem;
  min-height: 34px;
  border: 1px solid rgba(245, 166, 35, 0.55);
  border-radius: 999px;
  background: rgba(245, 166, 35, 0.08);
  color: #ffd27b;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ev-live-chat__handoff:hover {
  background: rgba(245, 166, 35, 0.18);
  border-color: #f5a623;
  color: #ffe2a8;
}

.ev-live-chat__handoff:focus-visible {
  outline: 2px solid #f0f6fc;
  outline-offset: 2px;
}

.ev-live-chat__handoff:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ev-live-chat__time {
  display: block;
  font-size: 0.66rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ev-live-chat__msg--me .ev-live-chat__time {
  text-align: right;
}

.ev-live-chat__typing {
  align-self: flex-start;
  display: flex;
  gap: 0.25rem;
  padding: 0.6rem 0.8rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 10px;
  border-bottom-left-radius: 3px;
}

.ev-live-chat__typing[hidden] {
  display: none;
}

.ev-live-chat__typing-label {
  color: #b1bac4;
}

.ev-live-chat__typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.ev-live-chat__typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b949e;
  animation: ev-chat-typing 1.1s ease-in-out infinite;
}

.ev-live-chat__typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ev-live-chat__typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ev-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ev-live-chat__fab,
  .ev-live-chat__fab::before,
  .ev-live-chat__panel,
  .ev-live-chat__resize-grip {
    animation: none;
    transition: none;
  }

  .ev-live-chat__typing-dots span {
    animation: none;
  }
}

.ev-live-chat__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #30363d;
  background: #0d1117;
  flex-shrink: 0;
}

.ev-live-chat__identity {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem 0.55rem;
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #c9d1d9;
}

.ev-live-chat__identity legend {
  padding: 0 0.25rem;
  color: #f5a623;
  font-size: 0.72rem;
}

.ev-live-chat__identity label {
  font-size: 0.7rem;
  color: #8b949e;
}

.ev-live-chat__identity input {
  width: 100%;
  min-width: 0;
  min-height: 2rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #30363d;
  border-radius: 5px;
  background: #21262d;
  color: #f0f6fc;
  font: inherit;
  font-size: 0.78rem;
}

.ev-live-chat__identity input:focus-visible {
  outline: 2px solid #f5a623;
  outline-offset: 1px;
}

.ev-live-chat__identity small {
  grid-column: 1 / -1;
  color: #8b949e;
  font-size: 0.66rem;
  line-height: 1.35;
}

.ev-live-chat__identity[hidden] {
  display: none;
}

.ev-live-chat__status.is-online {
  color: #3fb950;
}

.ev-live-chat__input {
  min-width: 0;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #f0f6fc;
  font-family: var(--wp--preset--font-family--data);
  font-size: 0.85rem;
  padding: 0.6rem 0.8rem;
}

/* Panel pracownika używa istniejącego endpointu WooCommerce Dispatch. */
.evplc-staff {
  margin-block: 1.75rem;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid #30363d;
  border-top: 3px solid #f5a623;
  border-radius: 10px;
  background: #161b22;
  color: #f0f6fc;
}

.evplc-staff h2,
.evplc-staff p {
  margin-top: 0;
}

.evplc-staff__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.evplc-staff__header h2 {
  margin-bottom: 0.25rem;
  color: #f0f6fc;
}

.evplc-staff__header p,
.evplc-staff__presence,
.evplc-staff__empty {
  color: #a8b1bb;
}

.evplc-staff__presence {
  flex: 0 0 auto;
  font-size: 0.8rem;
}

.evplc-staff__presence.is-online {
  color: #3fb950;
}

.evplc-staff__layout {
  display: grid;
  grid-template-columns: minmax(13rem, 0.75fr) minmax(0, 1.6fr);
  min-height: 22rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
}

.evplc-staff__list {
  max-height: 36rem;
  overflow: auto;
  background: #0d1117;
  border-right: 1px solid #30363d;
}

.evplc-staff__chat-button {
  display: block;
  width: 100%;
  padding: 0.8rem;
  border: 0;
  border-bottom: 1px solid #30363d;
  background: transparent;
  color: #c9d1d9;
  text-align: left;
  cursor: pointer;
}

.evplc-staff__chat-button:hover,
.evplc-staff__chat-button[aria-current="true"] {
  background: #21262d;
}

.evplc-staff__chat-button:focus-visible,
.evplc-staff__composer button:focus-visible {
  outline: 2px solid #f5a623;
  outline-offset: -2px;
}

.evplc-staff__chat-title,
.evplc-staff__chat-preview,
.evplc-staff__chat-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evplc-staff__chat-title {
  color: #f0f6fc;
  font-weight: 700;
}

.evplc-staff__chat-preview,
.evplc-staff__chat-meta {
  margin-top: 0.25rem;
  color: #8b949e;
  font-size: 0.76rem;
}

.evplc-staff__thread {
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: #161b22;
}

.evplc-staff__details {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #30363d;
  color: #c9d1d9;
  font-size: 0.82rem;
}

.evplc-staff__messages {
  display: flex;
  min-height: 16rem;
  max-height: 30rem;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.65rem;
  overflow: auto;
  padding: 1rem;
}

.evplc-staff__message {
  max-width: min(88%, 38rem);
  align-self: flex-start;
  padding: 0.55rem 0.7rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #21262d;
  overflow-wrap: anywhere;
}

.evplc-staff__message--agent,
.evplc-staff__message--ai,
.evplc-staff__message--bot {
  align-self: flex-end;
  border-color: #73561f;
  background: #2c261b;
}

.evplc-staff__message p {
  margin: 0;
  white-space: pre-wrap;
}

.evplc-staff__message-meta {
  display: block;
  margin-bottom: 0.25rem;
  color: #a8b1bb;
  font-size: 0.7rem;
}

.evplc-staff__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  padding: 0.75rem;
  border-top: 1px solid #30363d;
}

.evplc-staff__composer textarea {
  width: 100%;
  min-width: 0;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  border: 1px solid #30363d;
  border-radius: 7px;
  background: #0d1117;
  color: #f0f6fc;
  font: inherit;
}

.evplc-staff__composer button {
  align-self: end;
  min-height: 2.6rem;
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 7px;
  background: #f5a623;
  color: #0d1117;
  font-weight: 700;
  cursor: pointer;
}

.evplc-staff__composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.evplc-staff__error {
  margin: 0;
  padding: 0 0.75rem 0.75rem;
  color: #ff7b72;
}

.evplc-staff [hidden] {
  display: none;
}

.ev-live-chat__input:focus {
  outline: none;
  border-color: #f5a623;
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}

.ev-live-chat__input::placeholder {
  color: #8b949e;
}

.ev-live-chat__send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  border: none;
  background: #f5a623;
  color: #0d1117;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.ev-live-chat__send:hover {
  background: #ffb84d;
}

.ev-live-chat__send:active {
  transform: scale(0.94);
}

.ev-live-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

/* --- Sender label above each bubble (You / EV Parts UK / Auto-reply) --- */

.ev-live-chat__from {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b949e;
  margin-bottom: 0.2rem;
}

.ev-live-chat__msg--me .ev-live-chat__from {
  text-align: right;
  color: #f5a623;
}

/* --- System messages (reopened, product switched — server-localized) --- */

.ev-live-chat__msg--system {
  align-self: center;
  max-width: 92%;
  background: transparent;
  border: none;
  color: #8b949e;
  font-size: 0.76rem;
  font-style: italic;
  text-align: center;
  padding: 0.2rem 0.6rem;
}

.ev-live-chat__msg--system .ev-live-chat__time {
  display: none;
}

/* --- Auto-reply bubbles: same "them" shape, a quieter accent so it reads
   as a bot rather than Tomek himself replying. --- */

.ev-live-chat__msg--bot {
  border-color: rgba(245, 166, 35, 0.35);
}

.ev-live-chat__msg--bot .ev-live-chat__from {
  color: #f5a623;
}

/* --- Unread badge: a new agent message arriving while the panel is
   closed marks the FAB instead of silently waiting to be noticed. --- */

.ev-live-chat.has-unread .ev-live-chat__fab {
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.55), 0 6px 20px rgba(63, 185, 80, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.ev-live-chat.has-unread .ev-live-chat__fab::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f85149;
  border: 2px solid #0d1117;
}

/* --- Status / error notices between the messages and the composer --- */

.ev-live-chat__notice {
  margin: 0;
  padding: 0.55rem 1.1rem;
  font-size: 0.76rem;
  flex-shrink: 0;
}

.ev-live-chat__notice[hidden] {
  display: none;
}

.ev-live-chat__notice--closed {
  background: rgba(139, 148, 158, 0.12);
  color: #8b949e;
  border-top: 1px solid #30363d;
}

.ev-live-chat__notice--error {
  background: rgba(248, 81, 73, 0.12);
  color: #ff7b72;
  border-top: 1px solid rgba(248, 81, 73, 0.4);
}

/* --- Product context chip: JS-populated, hidden until a product is known. --- */

.ev-live-chat__context[hidden] {
  display: none;
}

/* --- Honeypot: off-screen rather than display:none/visibility:hidden, so
   it still looks fillable to a form-filling bot while staying invisible
   and (via tabindex="-1") unreachable to a real visitor. --- */

.ev-live-chat__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

@media (max-width: 480px) {
  .ev-live-chat {
    right: 1rem;
    bottom: 1rem;
  }

  .ev-live-chat__panel {
    right: 1rem;
    bottom: 1rem;
    width: calc(100vw - 2rem);
    height: calc(100vh - 7rem);
  }

  .evplc-staff__layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .evplc-staff__list {
    max-height: 13rem;
    border-right: 0;
    border-bottom: 1px solid #30363d;
  }

  .evplc-staff__header {
    flex-direction: column;
  }
}
