/**
 * ADN WhatsApp Button - Frontend Styles
 * Author: ADN GLOBAL (https://adnglobal.my)
 */

:root {
  --adn-wa-primary: #22a63a;
  --adn-wa-primary-hover: #1d9133;
  --adn-wa-header-bg: #179848;
  --adn-wa-online: #25d366;
  --adn-wa-card-bg: #f5f6f8;
  --adn-wa-card-hover: #edf0f3;
  --adn-wa-text-main: #111827;
  --adn-wa-text-sub: #6b7280;
  --adn-wa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Container */
.adn-wa-widget-wrapper {
  position: fixed;
  z-index: 999999;
  font-family: var(--adn-wa-font);
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.adn-wa-widget-wrapper *,
.adn-wa-widget-wrapper *::before,
.adn-wa-widget-wrapper *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Positions */
.adn-wa-pos-bottom-right {
  bottom: 24px;
  right: 24px;
}

.adn-wa-pos-bottom-left {
  bottom: 24px;
  left: 24px;
}

/* Floating Trigger Buttons */
.adn-wa-trigger-container {
  display: flex;
  justify-content: flex-end;
}

.adn-wa-pos-bottom-left .adn-wa-trigger-container {
  justify-content: flex-start;
}

/* Pill Button (Closed state) */
.adn-wa-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  background-color: var(--adn-wa-primary);
  color: #ffffff !important;
  text-decoration: none !important;
  padding: 12px 24px 12px 20px;
  border-radius: 9999px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.adn-wa-pill-btn:hover {
  background-color: var(--adn-wa-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
}

.adn-wa-pill-btn .adn-wa-pill-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.adn-wa-pill-btn .adn-wa-pill-icon svg {
  width: 100%;
  height: 100%;
  fill: #ffffff;
}

.adn-wa-pill-btn .adn-wa-pill-text {
  letter-spacing: -0.01em;
}

/* Circular Close Button (Open state) */
.adn-wa-circle-btn {
  display: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: var(--adn-wa-primary);
  color: #ffffff;
  border: none;
  outline: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.adn-wa-circle-btn:hover {
  background-color: var(--adn-wa-primary-hover);
  transform: scale(1.06);
}

.adn-wa-circle-btn svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* Chatbox Popup */
.adn-wa-box {
  position: absolute;
  bottom: 64px;
  width: 350px;
  max-width: calc(100vw - 40px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.25s;
  z-index: 10;
}

.adn-wa-pos-bottom-right .adn-wa-box {
  right: 0;
  transform-origin: bottom right;
}

.adn-wa-pos-bottom-left .adn-wa-box {
  left: 0;
  transform-origin: bottom left;
}

/* Speech bubble pointer / notch at bottom */
.adn-wa-box::after {
  content: "";
  position: absolute;
  bottom: -9px;
  width: 18px;
  height: 18px;
  background-color: #ffffff;
  transform: rotate(45deg);
  box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.04);
  z-index: 1;
}

.adn-wa-pos-bottom-right .adn-wa-box::after {
  right: 17px;
}

.adn-wa-pos-bottom-left .adn-wa-box::after {
  left: 17px;
}

/* Active State (Widget Opened) */
.adn-wa-widget-wrapper.adn-wa-active .adn-wa-box {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.adn-wa-widget-wrapper.adn-wa-active .adn-wa-pill-btn {
  display: none;
}

.adn-wa-widget-wrapper.adn-wa-active .adn-wa-circle-btn {
  display: flex;
}

/* Header */
.adn-wa-header {
  background-color: var(--adn-wa-header-bg);
  padding: 18px 20px 16px 20px;
  color: #ffffff;
  position: relative;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
}

.adn-wa-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.adn-wa-header-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.adn-wa-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.85;
  transition: opacity 0.2s, background-color 0.2s;
}

.adn-wa-close-btn:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.15);
}

.adn-wa-close-btn svg {
  width: 16px;
  height: 16px;
  stroke: #ffffff;
  stroke-width: 2.4;
}

.adn-wa-header-subtitle {
  font-size: 13.5px;
  line-height: 1.45;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 400;
}

/* Body / Agent List */
.adn-wa-body {
  padding: 14px 14px 6px 14px;
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.adn-wa-body::-webkit-scrollbar {
  width: 5px;
}

.adn-wa-body::-webkit-scrollbar-track {
  background: transparent;
}

.adn-wa-body::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 10px;
}

/* Agent Item Card */
.adn-wa-agent-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--adn-wa-card-bg);
  border-radius: 14px;
  margin-bottom: 10px;
  text-decoration: none !important;
  color: inherit !important;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
  border: 1px solid transparent;
}

.adn-wa-agent-item:hover {
  background-color: var(--adn-wa-card-hover);
  transform: translateY(-1px);
  border-color: #e5e7eb;
}

.adn-wa-agent-avatar-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  margin-right: 12px;
}

.adn-wa-agent-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background-color: #e5e7eb;
}

.adn-wa-status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background-color: var(--adn-wa-online);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.adn-wa-status-dot.offline {
  background-color: #9ca3af;
}

.adn-wa-agent-info {
  flex: 1;
  min-width: 0;
}

.adn-wa-agent-name-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1.3;
}

.adn-wa-agent-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--adn-wa-text-main);
  white-space: nowrap;
}

.adn-wa-agent-separator {
  color: var(--adn-wa-text-sub);
  font-weight: 400;
}

.adn-wa-agent-role {
  font-size: 13.5px;
  color: #1f2937;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adn-wa-agent-desc {
  font-size: 12.5px;
  color: var(--adn-wa-text-sub);
  margin-top: 3px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer */
.adn-wa-footer {
  padding: 10px 16px 14px 16px;
  text-align: center;
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
  border-top: 1px solid #f1f5f9;
  background-color: #ffffff;
  position: relative;
  z-index: 2;
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .adn-wa-pos-bottom-right,
  .adn-wa-pos-bottom-left {
    bottom: 16px;
    right: 16px;
    left: auto;
  }

  .adn-wa-box {
    width: calc(100vw - 32px);
    bottom: 60px;
    right: 0 !important;
    left: auto !important;
  }

  .adn-wa-pill-btn {
    min-height: 44px;
    font-size: 14px;
    padding: 10px 18px 10px 16px;
    max-width: calc(100vw - 32px);
    white-space: normal;
    text-align: left;
  }
}

/* Kunci gaya butang supaya CSS tema (button { background: ... }) tidak mengatasinya */
.adn-wa-widget-wrapper button.adn-wa-pill-btn,
.adn-wa-widget-wrapper button.adn-wa-circle-btn {
  background: var(--adn-wa-primary) !important;
  background-color: var(--adn-wa-primary) !important;
  background-image: none !important;
  color: #ffffff !important;
  border: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-family: var(--adn-wa-font) !important;
  margin: 0 !important;
}

.adn-wa-widget-wrapper button.adn-wa-pill-btn {
  font-size: 16px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  padding: 12px 24px 12px 20px !important;
  border-radius: 9999px !important;
  min-height: 48px !important;
  width: auto !important;
  height: auto !important;
}

.adn-wa-widget-wrapper button.adn-wa-circle-btn {
  padding: 0 !important;
  border-radius: 50% !important;
  width: 52px !important;
  height: 52px !important;
}

.adn-wa-widget-wrapper button.adn-wa-pill-btn:hover,
.adn-wa-widget-wrapper button.adn-wa-pill-btn:focus,
.adn-wa-widget-wrapper button.adn-wa-pill-btn:active,
.adn-wa-widget-wrapper button.adn-wa-circle-btn:hover,
.adn-wa-widget-wrapper button.adn-wa-circle-btn:focus,
.adn-wa-widget-wrapper button.adn-wa-circle-btn:active {
  background: var(--adn-wa-primary-hover) !important;
  background-color: var(--adn-wa-primary-hover) !important;
  color: #ffffff !important;
}

.adn-wa-widget-wrapper button.adn-wa-pill-btn .adn-wa-pill-icon svg {
  fill: #ffffff !important;
}

@media (max-width: 480px) {
  .adn-wa-widget-wrapper button.adn-wa-pill-btn {
    font-size: 14px !important;
    padding: 10px 18px 10px 16px !important;
    min-height: 44px !important;
  }
}

.adn-wa-widget-wrapper button.adn-wa-close-btn,
.adn-wa-widget-wrapper button.adn-wa-close-btn:focus,
.adn-wa-widget-wrapper button.adn-wa-close-btn:active {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  box-shadow: none !important;
}

.adn-wa-widget-wrapper button.adn-wa-close-btn:hover {
  background: rgba(255, 255, 255, 0.15) !important;
}
