/* =============================================
   WP LIVE CHAT — Frontend Widget Styles
   ============================================= */
:root {
  --wplc-primary: #6C63FF;
  --wplc-primary-dark: #574fd6;
  --wplc-accent: #FF6584;
  --wplc-bg: #ffffff;
  --wplc-surface: #f7f7fb;
  --wplc-border: #e8e7f4;
  --wplc-text: #1a1a2e;
  --wplc-muted: #8b8a9e;
  --wplc-admin-bubble: #6C63FF;
  --wplc-user-bubble: #f0eeff;
  --wplc-radius: 20px;
  --wplc-shadow: 0 20px 60px rgba(108,99,255,.22), 0 4px 16px rgba(0,0,0,.10);
  --wplc-launcher-size: 42px;
}

/* ── Widget container ── */
.wplc-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Launcher button ── */
.wplc-launcher {
  width: var(--wplc-launcher-size);
  height: var(--wplc-launcher-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wplc-primary) 0%, #a78bfa 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(108,99,255,.45);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  position: relative;
  flex-shrink: 0;
}
.wplc-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 36px rgba(108,99,255,.55);
}
.wplc-launcher:active { transform: scale(.97); }

.wplc-icon-close { display: none; }
.wplc-widget:not(.wplc-widget--closed) .wplc-icon-chat  { display: none; }
.wplc-widget:not(.wplc-widget--closed) .wplc-icon-close { display: block; }

/* Unread dot */
.wplc-unread-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--wplc-accent);
  border: 2px solid #fff;
  animation: wplcPulse 1.6s infinite;
}
@keyframes wplcPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,101,132,.5); }
  50%      { box-shadow: 0 0 0 7px rgba(255,101,132,0); }
}

/* ── Chat box ── */
.wplc-box {
  width: 360px;
  max-height: 520px;
  background: var(--wplc-bg);
  border-radius: var(--wplc-radius);
  box-shadow: var(--wplc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s;
}
.wplc-widget--closed .wplc-box {
  transform: scale(.7) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

/* ── Header ── */
.wplc-box-header {
  background: linear-gradient(135deg, var(--wplc-primary) 0%, #a78bfa 100%);
  padding: 16px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.wplc-box-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wplc-avatar {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.wplc-box-title {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
.wplc-box-subtitle {
  color: rgba(255,255,255,.75);
  font-size: 12px;
}
.wplc-minimize-btn {
  background: rgba(255,255,255,.18);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.wplc-minimize-btn:hover { background: rgba(255,255,255,.3); }

/* ── Name form ── */
.wplc-name-form {
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.wplc-welcome-msg {
  font-size: 15px;
  color: var(--wplc-text);
  margin: 0;
  font-weight: 500;
}
.wplc-name-form input {
  border: 2px solid var(--wplc-border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  color: var(--wplc-text);
  background: var(--wplc-surface);
}
.wplc-name-form input:focus { border-color: var(--wplc-primary); background: #fff; }
.wplc-start-btn {
  background: linear-gradient(135deg, var(--wplc-primary) 0%, #a78bfa 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
}
.wplc-start-btn:hover { opacity: .88; transform: translateY(-1px); }

/* ── Messages ── */
.wplc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  background: var(--wplc-surface);
}
.wplc-messages::-webkit-scrollbar { width: 4px; }
.wplc-messages::-webkit-scrollbar-thumb { background: var(--wplc-border); border-radius: 4px; }

.wplc-msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  animation: wplcFadeIn .22s ease;
}
@keyframes wplcFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wplc-msg--user {
  background: var(--wplc-user-bubble);
  color: var(--wplc-text);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.wplc-msg--admin {
  background: var(--wplc-admin-bubble);
  color: #fff;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.wplc-msg-time {
  font-size: 10px;
  opacity: .55;
  margin-top: 3px;
  text-align: right;
}
.wplc-msg--admin .wplc-msg-time { text-align: left; }
.wplc-typing {
  align-self: flex-start;
  background: var(--wplc-admin-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex; gap: 5px; align-items: center;
}
.wplc-typing span {
  width: 6px; height: 6px;
  background: rgba(255,255,255,.8);
  border-radius: 50%;
  animation: wplcBounce 1.2s infinite;
}
.wplc-typing span:nth-child(2) { animation-delay: .15s; }
.wplc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wplcBounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input area ── */
.wplc-input-area {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--wplc-border);
  background: var(--wplc-bg);
  flex-shrink: 0;
}
.wplc-input-area textarea {
  flex: 1;
  border: 2px solid var(--wplc-border);
  border-radius: 14px;
  padding: 10px 13px;
  font-size: 13.5px;
  resize: none;
  font-family: inherit;
  outline: none;
  max-height: 90px;
  overflow-y: auto;
  transition: border-color .2s;
  line-height: 1.4;
  color: var(--wplc-text);
}
.wplc-input-area textarea:focus { border-color: var(--wplc-primary); }
.wplc-send-btn {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wplc-primary) 0%, #a78bfa 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.wplc-send-btn:hover { transform: scale(1.1); box-shadow: 0 4px 14px rgba(108,99,255,.4); }

/* ── Responsive ── */
@media (max-width: 480px) {
  .wplc-widget {
    bottom: 12px;
    right: 12px;
    left: 12px;
    align-items: flex-end;
  }
  .wplc-box {
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 18px 18px;
  }
}

/* ── Name field required state ── */
.wplc-field-wrap {
  position: relative;
}
.wplc-field-wrap input {
  width: 100%;
  box-sizing: border-box;
}
.wplc-required-star {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--wplc-accent);
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
  line-height: 1;
}
.wplc-input-error {
  border-color: var(--wplc-accent) !important;
  background: #fff5f7 !important;
  animation: wplcShake .3s ease;
}
@keyframes wplcShake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}
.wplc-name-error {
  color: var(--wplc-accent);
  font-size: 12px;
  font-weight: 500;
  margin-top: -4px;
}

/* ── Deleted-chat notice bubble ── */
.wplc-msg--notice {
  background: #fff3cd !important;
  color: #856404 !important;
  font-style: italic;
  align-self: center !important;
  text-align: center;
  font-size: 12.5px;
  border-radius: 10px !important;
  max-width: 90% !important;
}

#wplcWidget.wplc-widget--closed {
  z-index: 0;
}