/* WA Chat Widget — public stylesheet */

:root {
  --wacw-accent:       #25D366;
  --wacw-accent-dark:  #1da851;
  --wacw-accent-light: #e8f8ee;
  --wacw-text:         #1a1a2e;
  --wacw-muted:        #6b7280;
  --wacw-border:       #e5e7eb;
  --wacw-surface:      #ffffff;
  --wacw-shadow-color: rgba(0,0,0,.16);
  --wacw-shadow:       0 8px 32px var(--wacw-shadow-color);
  --wacw-radius:       16px;
  --wacw-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Root ── */
#wacw-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: var(--wacw-font);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

#wacw-root.wacw--left {
  right: auto;
  left: 20px;
  align-items: flex-start;
}

/* ── Trigger button ── */
.wacw-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  background: var(--wacw-accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--wacw-font);
  box-shadow: 0 4px 20px var(--wacw-shadow-color);
  transition: transform .18s ease, box-shadow .18s ease, background .15s;
  user-select: none;
}

.wacw-trigger:hover {
  background: var(--wacw-accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--wacw-shadow-color);
}

.wacw-trigger:active { transform: translateY(0); }

.wacw-trigger-icon svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.wacw-trigger-icon,
.wacw-trigger-label {
  pointer-events: none;
}

/* ── Panel ── */
.wacw-panel {
  background: var(--wacw-surface);
  border-radius: var(--wacw-radius);
  box-shadow: var(--wacw-shadow);
  width: 340px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

.wacw-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Panel header ── */
.wacw-panel-header {
  background: var(--wacw-accent);
  color: #fff;
  padding: 16px 16px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wacw-header-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wacw-header-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wacw-header-sub {
  font-size: 12px;
  opacity: .85;
  margin-top: 2px;
}

.wacw-close,
.wacw-back-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.wacw-close svg,
.wacw-back-btn svg {
  width: 18px;
  height: 18px;
}

.wacw-close:hover,
.wacw-back-btn:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* ── Selected agent mini-header ── */
.wacw-selected-agent {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--wacw-border);
  background: var(--wacw-accent-light);
  flex-shrink: 0;
}

.wacw-ah-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--wacw-accent);
}

.wacw-ah-meta {
  display: flex;
  flex-direction: column;
}

.wacw-ah-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--wacw-text);
}

.wacw-ah-title {
  font-size: 12px;
  color: var(--wacw-muted);
}

/* ── Panel body ── */
.wacw-panel-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ── Agent list ── */
.wacw-agent-list {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.wacw-no-agents {
  padding: 20px;
  text-align: center;
  color: var(--wacw-muted);
  font-size: 14px;
}

.wacw-agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1.5px solid var(--wacw-border);
  border-radius: 12px;
  background: var(--wacw-surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .15s, background .15s, transform .12s;
  font-family: var(--wacw-font);
}

.wacw-agent-card:hover {
  border-color: var(--wacw-accent);
  background: var(--wacw-accent-light);
  transform: translateX(2px);
}

.wacw-agent-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.wacw-agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.wacw-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
}

.wacw-agent-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wacw-agent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--wacw-text);
}

.wacw-agent-title {
  font-size: 12px;
  color: var(--wacw-muted);
}

.wacw-agent-arrow svg {
  width: 16px;
  height: 16px;
  color: var(--wacw-muted);
  flex-shrink: 0;
}

/* ── Form ── */
.wacw-form-wrap {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wacw-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wacw-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.wacw-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--wacw-text);
}

.wacw-req {
  color: #ef4444;
  margin-left: 2px;
}

.wacw-input {
  padding: 9px 12px;
  border: 1.5px solid var(--wacw-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--wacw-font);
  color: var(--wacw-text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
  width: 100%;
  box-sizing: border-box;
}

.wacw-input:focus {
  border-color: var(--wacw-accent);
  box-shadow: 0 0 0 3px var(--wacw-accent-light);
}

.wacw-input.wacw-field--error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px #fee2e2;
}

.wacw-textarea {
  resize: vertical;
  min-height: 72px;
}

.wacw-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}

/* ── Form error ── */
.wacw-form-error {
  font-size: 13px;
  color: #dc2626;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
}

/* ── Send button ── */
.wacw-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--wacw-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--wacw-font);
  cursor: pointer;
  transition: background .15s, transform .12s;
  width: 100%;
}

.wacw-send-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.wacw-send-btn:hover { background: var(--wacw-accent-dark); transform: translateY(-1px); }
.wacw-send-btn:active { transform: translateY(0); }

/* ── Mobile ── */
@media (max-width: 480px) {
  #wacw-root {
    bottom: 12px;
    right: 12px;
    left: auto;
    align-items: flex-end;
  }
  #wacw-root.wacw--left {
    right: auto;
    left: 12px;
    align-items: flex-start;
  }

  .wacw-panel {
    width: 320px;
    max-width: calc(100vw - 24px);
  }

  .wacw-trigger-label { display: none; }

  .wacw-trigger {
    padding: 13px;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    justify-content: center;
  }
}

/* ── v1.1 additions: availability, offline, validation hints ── */

/* Agent availability label */
.wacw-agent-avail {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.wacw-avail--online { color: #16a34a; }
.wacw-avail--offline { color: #9ca3af; }

/* Offline card state */
.wacw-agent-card--offline {
  opacity: .65;
  cursor: not-allowed;
}
.wacw-agent-card--offline:hover {
  border-color: var(--wacw-border);
  background: var(--wacw-surface);
  transform: none;
}

/* Online dot variants */
.wacw-online-dot.wacw-dot--online  { background: #22c55e; }
.wacw-online-dot.wacw-dot--offline { background: #d1d5db; }

/* Selected agent header dot */
.wacw-ah-dot {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
}
.wacw-ah-dot--online  { background: #22c55e; }
.wacw-ah-dot--offline { background: #d1d5db; }

.wacw-ah-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.wacw-ah-avail {
  font-size: 11px;
  color: #6b7280;
  margin-top: 1px;
}

/* Validation hint (inline field error text) */
.wacw-field-hint {
  display: block;
  font-size: 12px;
  color: #dc2626;
  margin-top: 4px;
  min-height: 16px;
  line-height: 1.3;
}

/* ── v1.2: GDPR checkbox, inline button ── */

.wacw-gdpr-wrap {
  padding: 10px 0 4px;
  border-top: 1px solid var(--wacw-border);
  margin-top: 4px;
}

.wacw-gdpr-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--wacw-muted);
  cursor: pointer;
  line-height: 1.4;
}

.wacw-gdpr-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--wacw-accent);
}

.wacw-gdpr-label a {
  color: var(--wacw-accent);
  text-decoration: underline;
}

.wacw-send-btn--disabled {
  opacity: .5;
  cursor: not-allowed;
}

.wacw-send-btn--disabled:hover {
  background: var(--wacw-accent);
  transform: none;
}

/* Inline shortcode button */
.wacw-inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 50px;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 3px 14px var(--wacw-shadow-color);
  transition: filter .15s, transform .15s;
  user-select: none;
}

.wacw-inline-btn:hover {
  filter: brightness(.88);
  transform: translateY(-1px);
}

/* ── v1.3: Greeting bubble ── */
.wacw-bubble {
  position: relative;
  background: #fff;
  border: 1.5px solid var(--wacw-border);
  border-radius: 12px 12px 4px 12px;
  padding: 10px 32px 10px 14px;
  box-shadow: 0 4px 18px var(--wacw-shadow-color);
  max-width: 260px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(.96);
  transition: opacity .28s ease, transform .28s ease;
  align-self: flex-end;
  margin-bottom: 4px;
}

.wacw-bubble--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* small triangle pointer towards trigger */
.wacw-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 18px;
  width: 14px;
  height: 8px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-left: 1.5px solid var(--wacw-border);
  border-right: 1.5px solid var(--wacw-border);
}

#wacw-root.wacw--left .wacw-bubble {
  border-radius: 12px 12px 12px 4px;
  align-self: flex-start;
}

#wacw-root.wacw--left .wacw-bubble::after {
  right: auto;
  left: 18px;
}

.wacw-bubble-text {
  font-size: 13px;
  color: var(--wacw-text);
  line-height: 1.4;
  pointer-events: none;
}

.wacw-bubble-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: var(--wacw-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  pointer-events: all;
}

.wacw-bubble-close:hover { background: var(--wacw-border); }

@media (max-width: 480px) {
  .wacw-bubble { max-width: 220px; font-size: 12px; }
}
