/* Wolf Chat Widget — Styles */

/* Bubble */
.wolf-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--wolf-gold, #f7941d);
  color: var(--wolf-text-inverse);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(247, 148, 29, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--wolf-z-chat-bubble);
  transition: transform 0.15s, box-shadow 0.15s;
  animation: wolf-chat-entrance 0.3s ease-out;
}

@keyframes wolf-chat-entrance {
  from { opacity: 0; transform: translateY(16px) scale(0.8); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wolf-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(247, 148, 29, 0.35);
}

.wolf-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: var(--wolf-text-inverse);
}

.wolf-chat-bubble__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--wolf-status-error);
  color: var(--wolf-text-inverse);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--wolf-font-family);
}

.wolf-chat-bubble__badge[hidden] {
  display: none;
}

/* Window */
.wolf-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 500px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(27, 58, 107, 0.15);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.25),
    0 4px 12px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  z-index: var(--wolf-z-chat-window);
  font-family: var(--wolf-font-family);
  animation: wolf-chat-slide-up 0.2s ease-out;
  background: var(--wolf-bg);
}

.wolf-chat-window[hidden] {
  display: none;
}

@keyframes wolf-chat-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.wolf-chat-header {
  background: var(--wolf-blue);
  color: var(--wolf-text-inverse);
  padding: 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wolf-chat-header__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.wolf-chat-header__dot--online { background: var(--wolf-status-success); }
.wolf-chat-header__dot--offline { background: var(--wolf-status-error); }

.wolf-chat-header__title {
  font-size: 1.5rem;
  font-weight: 600;
  flex: 1;
}

.wolf-chat-header__phone {
  display: block;
  font-size: 1.2rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  margin-top: 2px;
}

.wolf-chat-header__phone:hover,
.wolf-chat-header__phone:focus-visible {
  color: var(--wolf-text-inverse);
  text-decoration: underline;
}

.wolf-chat-header__close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 2.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.wolf-chat-header__close:hover,
.wolf-chat-header__close:focus-visible {
  color: var(--wolf-text-inverse);
}

/* Messages */
.wolf-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--wolf-bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.wolf-chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 1.4rem;
  line-height: 1.45;
  word-wrap: break-word;
}

.wolf-chat-msg--visitor {
  align-self: flex-end;
  background: var(--wolf-gold, #f7941d);
  color: var(--wolf-text-inverse);
  border-bottom-right-radius: 4px;
}

.wolf-chat-msg--staff {
  align-self: flex-start;
  background: var(--wolf-bg);
  color: var(--wolf-text);
  border: 1px solid var(--wolf-border);
  border-bottom-left-radius: 4px;
}

.wolf-chat-msg__from {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--wolf-blue);
  margin-bottom: 3px;
}

.wolf-chat-msg__time {
  font-size: 1.2rem;
  opacity: 0.5;
  margin-top: 3px;
}

.wolf-chat-msg--system {
  align-self: center;
  background: transparent;
  color: var(--wolf-text-muted);
  font-size: 1.2rem;
  font-style: italic;
  padding: 4px 0;
}

/* Live verification */
.wolf-chat-live-verify {
  padding: 10px 12px;
  background: var(--wolf-bg-warning-soft);
  border-top: 1px solid rgba(247, 148, 29, 0.2);
  border-bottom: 1px solid rgba(247, 148, 29, 0.2);
  flex-shrink: 0;
}

.wolf-chat-live-verify[hidden] {
  display: none;
}

.wolf-chat-live-verify__text {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--wolf-status-warning-dark);
}

.wolf-chat-live-verify__turnstile {
  display: flex;
  justify-content: center;
}

/* Input */
.wolf-chat-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--wolf-border);
  background: var(--wolf-bg);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.wolf-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--wolf-border-light);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 1.4rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.wolf-chat-input:focus-visible {
  outline: none;
  border-color: var(--wolf-gold, #f7941d);
  box-shadow: var(--wolf-shadow-focus);
}

.wolf-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--wolf-gold, #f7941d);
  color: var(--wolf-text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.wolf-chat-send:hover,
.wolf-chat-send:focus-visible {
  background: var(--wolf-gold-hover);
}

.wolf-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Info bar (optional name/email) */
.wolf-chat-info-bar {
  padding: 8px 12px;
  background: var(--wolf-bg-panel);
  border-top: 1px solid var(--wolf-border);
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  overflow: hidden;
}

.wolf-chat-info-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--wolf-border-faint);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 1.3rem;
  font-family: inherit;
  box-sizing: border-box;
}

.wolf-chat-info-bar input:focus-visible {
  outline: none;
  border-color: var(--wolf-gold);
  box-shadow: var(--wolf-shadow-focus);
}

.wolf-chat-info-bar[hidden] {
  display: none;
}

/* Offline form */
.wolf-chat-offline {
  flex: 1;
  padding: 20px 16px;
  background: var(--wolf-bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.wolf-chat-offline[hidden] {
  display: none;
}

.wolf-chat-offline__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--wolf-text);
  margin: 0;
}

.wolf-chat-offline__subtitle {
  font-size: 1.3rem;
  color: var(--wolf-text-body);
  margin: 0;
}

.wolf-chat-offline input,
.wolf-chat-offline textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--wolf-border-light);
  border-radius: 4px;
  font-size: 1.4rem;
  font-family: inherit;
  box-sizing: border-box;
}

.wolf-chat-offline input:focus-visible,
.wolf-chat-offline textarea:focus-visible {
  outline: none;
  border-color: var(--wolf-gold);
  box-shadow: var(--wolf-shadow-focus);
}

.wolf-chat-offline textarea {
  resize: vertical;
  min-height: 80px;
}

.wolf-chat-offline__submit {
  padding: 8px 16px;
  background: var(--wolf-gold, #f7941d);
  color: var(--wolf-text-inverse);
  border: none;
  border-radius: 4px;
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.wolf-chat-offline__submit:hover,
.wolf-chat-offline__submit:focus-visible {
  background: var(--wolf-gold-hover);
}

.wolf-chat-offline__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wolf-chat-offline__success {
  text-align: center;
  color: var(--wolf-status-success);
  font-weight: 600;
}

.wolf-chat-offline__turnstile {
  display: flex;
  justify-content: center;
}

/* Mobile */
@media (max-width: 480px) {
  /* Body scroll lock — mobile only */
  body.wolf-chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  /* Hide bubble when chat is open — mobile only */
  body.wolf-chat-open .wolf-chat-bubble {
    display: none;
  }

  .wolf-chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: var(--wolf-z-overlay);
  }

  .wolf-chat-messages {
    flex: 1;
    min-height: 0;
    overscroll-behavior: contain;
  }

  /* Prevent iOS auto-zoom on focus — must be >= 16px */
  .wolf-chat-input,
  .wolf-chat-info-bar input,
  .wolf-chat-offline input,
  .wolf-chat-offline textarea {
    font-size: 1.6rem;
  }

  .wolf-chat-input-row {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .wolf-chat-info-bar {
    padding: 6px 12px;
  }

  .wolf-chat-bubble {
    bottom: 16px;
    right: 16px;
  }
}
