/* Netdata Chat Widget Styles */

/* Theme variables to match Ask Netdata chatbox */
:root {
  --asknet-green: #00ab44;
  --asknet-green-rgb: 0,171,68;
  --asknet-shadow: 0 10px 40px rgba(0,0,0,0.45);
}

.netdata-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --widget-bg: #ffffff;
  --widget-border: rgba(var(--asknet-green-rgb), 0.06);
}


/* Floating Button */
.netdata-chat-button {
  min-width: 140px;
  height: 56px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--asknet-green) 0%, #00d659 100%);
  border: 1px solid var(--widget-border);
  box-shadow: 0 6px 22px rgba(var(--asknet-green-rgb), 0.12), 0 2px 6px rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.3s ease;
  position: relative;
  outline: none;
  padding: 0 18px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  backdrop-filter: blur(10px);
}

.netdata-chat-button .button-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.netdata-chat-button .button-text {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.netdata-chat-button .chat-icon {
  flex-shrink: 0;
}

.netdata-chat-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 171, 68, 0.35);
}

.netdata-chat-button:active {
  transform: scale(0.95);
}

.netdata-chat-button.active {
  background: linear-gradient(135deg, #00D659 0%, var(--asknet-green) 100%);
}

/* subtle glow for active state using pseudo-element so it doesn't affect layout */
.netdata-chat-button.active::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 34px;
  box-shadow: 0 8px 30px rgba(var(--asknet-green-rgb), 0.18);
  opacity: 0.85;
  pointer-events: none;
}

.netdata-chat-button:not(.active):hover .button-text {
  animation: textGlow 1.5s ease-in-out infinite alternate;
}

@keyframes textGlow {
  from {
    text-shadow: none;
  }

  to {
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 4px 12px rgba(0, 171, 68, 0.3);
  }

  50% {
    box-shadow: 0 4px 20px rgba(0, 171, 68, 0.5);
  }

  100% {
    box-shadow: 0 4px 12px rgba(0, 171, 68, 0.3);
  }
}

/* Notification Badge */
.netdata-chat-button .notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4444;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  border: 2px solid white;
  animation: bounce 2s infinite;
}

@keyframes bounce {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-5px);
  }

  60% {
    transform: translateY(-3px);
  }
}

/* Chat Window */
.netdata-chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 420px;
  height: 640px;
  background: var(--widget-bg);
  border-radius: 12px;
  border: 1px solid var(--widget-border);
  box-shadow: var(--asknet-shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  transition: all 0.26s cubic-bezier(0.2, 0, 0, 1);
  pointer-events: none;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  resize: none;
  min-width: 320px;
  min-height: 420px;
}

.netdata-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.netdata-chat-window.minimized {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.netdata-chat-window.resizing {
  transition: none;
  user-select: none;
}

.netdata-chat-window.dragging {
  transition: none;
  cursor: move;
  opacity: 0.95;
}

/* Fullscreen Mode */
.netdata-chat-window.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  bottom: 0 !important;
  right: 0 !important;
  max-height: 100vh !important;
  border-radius: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  background: var(--widget-bg);
  border: none;
}

.netdata-chat-window.fullscreen .netdata-chat-header {
  border-radius: 0;
}

.netdata-chat-window.fullscreen #netdata-chat-iframe {
  border-radius: 0;
  height: calc(100% - 50px);
}

/* Resize Handles */
.resize-handle {
  position: absolute;
  background: transparent;
  z-index: 10;
  transition: background-color 0.2s ease;
}

.resize-handle:hover {
  background: rgba(0, 171, 68, 0.1);
}

.resize-handle:active {
  background: rgba(0, 171, 68, 0.2);
}

/* Corner handles */
.resize-nw,
.resize-ne,
.resize-sw,
.resize-se {
  width: 12px;
  height: 12px;
}

.resize-nw {
  top: 0;
  left: 0;
  cursor: nw-resize;
  border-top-left-radius: 12px;
}

.resize-ne {
  top: 0;
  right: 0;
  cursor: ne-resize;
  border-top-right-radius: 12px;
}

.resize-sw {
  bottom: 0;
  left: 0;
  cursor: sw-resize;
  border-bottom-left-radius: 12px;
}

.resize-se {
  bottom: 0;
  right: 0;
  cursor: se-resize;
  border-bottom-right-radius: 12px;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 171, 68, 0.15) 50%);
}

.resize-se:hover {
  background: linear-gradient(135deg, transparent 40%, rgba(0, 171, 68, 0.3) 40%);
}

.resize-se::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 8px 8px;
  border-color: transparent transparent rgba(0, 171, 68, 0.4) transparent;
  pointer-events: none;
}

/* Edge handles */
.resize-n,
.resize-s {
  left: 12px;
  right: 12px;
  height: 6px;
}

.resize-n {
  top: 0;
  cursor: n-resize;
}

.resize-s {
  bottom: 0;
  cursor: s-resize;
}

.resize-e,
.resize-w {
  top: 12px;
  bottom: 12px;
  width: 6px;
}

.resize-e {
  right: 0;
  cursor: e-resize;
}

.resize-w {
  left: 0;
  cursor: w-resize;
}

/* Chat Header */
.netdata-chat-header {
  background: linear-gradient(135deg, var(--asknet-green) 0%, #00d659 100%);
  color: white;
  padding: 14px 18px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(var(--asknet-green-rgb), 0.12);
  cursor: move;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.netdata-chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.netdata-chat-header:hover::before {
  left: 100%;
}

.netdata-chat-window.fullscreen .netdata-chat-header { cursor: default; }

.netdata-chat-window.dragging .netdata-chat-header {
  cursor: grabbing;
}

.chat-header-title {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

.chat-header-actions button {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  position: relative;
  overflow: hidden;
}

/* make the iframe look like the site chatbox by giving it an inner frame and radius */
#netdata-chat-iframe {
  background: transparent;
  border: none;
  border-radius: 0 0 12px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

/* Dark mode adjustments: change shell/bg colors so frame matches Ask Netdata dark theme */
@media (prefers-color-scheme: dark) {
  .netdata-chat-widget { --widget-bg: rgba(6,6,6,0.96); --widget-border: rgba(var(--asknet-green-rgb), 0.08); }
  .netdata-chat-button { box-shadow: 0 6px 22px rgba(var(--asknet-green-rgb), 0.12), 0 2px 6px rgba(0,0,0,0.6); }
  .netdata-chat-window { box-shadow: 0 12px 50px rgba(0,0,0,0.6); }
  .netdata-chat-header { box-shadow: 0 2px 14px rgba(var(--asknet-green-rgb), 0.08); }
}

/* Light mode tweaks */
@media (prefers-color-scheme: light) {
  .netdata-chat-widget { --widget-bg: #ffffff; --widget-border: rgba(var(--asknet-green-rgb), 0.06); }
}

.chat-header-actions button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.chat-header-actions button:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

.chat-header-actions button:hover::before {
  width: 40px;
  height: 40px;
}

.chat-header-actions button:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.95);
}

.chat-fullscreen-btn svg {
  transition: transform 0.3s ease;
}

.chat-fullscreen-btn:hover svg {
  transform: scale(1.1);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .netdata-chat-widget {
    right: 10px;
    bottom: 10px;
  }

  .netdata-chat-button {
    min-width: 120px;
    height: 48px;
    border-radius: 24px;
    padding: 0 14px;
  }

  .netdata-chat-button .button-text {
    font-size: 13px;
  }

  .netdata-chat-button .button-content {
    gap: 8px;
  }

  .netdata-chat-button .chat-icon {
    width: 20px;
    height: 20px;
  }

  .netdata-chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 80px);
    right: 10px;
    bottom: 64px;
    max-width: 400px;
  }
}

/* Tablet Responsive */
@media (min-width: 481px) and (max-width: 768px) {
  .netdata-chat-window {
    width: 380px;
    height: 500px;
  }
}

/* Animation for smooth transitions */
@media (prefers-reduced-motion: reduce) {

  .netdata-chat-button,
  .netdata-chat-window,
  .chat-header-actions button {
    transition: none;
  }

  .netdata-chat-button.active,
  .notification-badge {
    animation: none;
  }
}

/* Additional Visual Polish */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

.netdata-chat-window.open {
  animation: fadeInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Smooth shadow transitions */
.netdata-chat-window:not(.fullscreen) {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 171, 68, 0.05);
}

.netdata-chat-window:not(.fullscreen):hover {
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(0, 171, 68, 0.1);
}

/* Resize handle visual feedback */
.resize-se::before {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 3px;
  height: 3px;
  background: rgba(0, 171, 68, 0.5);
  border-radius: 50%;
  box-shadow: 4px 0 0 rgba(0, 171, 68, 0.5),
    0 4px 0 rgba(0, 171, 68, 0.5);
}

/* Fullscreen transition enhancement */
.netdata-chat-window.fullscreen {
  animation: enterFullscreen 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes enterFullscreen {
  from {
    border-radius: 12px;
    transform: scale(0.95);
  }

  to {
    border-radius: 0;
    transform: scale(1);
  }
}

.netdata-chat-button.active {
  transform: scale(0.9);
  opacity: 0.8;
}

/* Iframe container improvements */
#netdata-chat-iframe {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  position: relative;
}

#netdata-chat-iframe::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
      transparent,
      rgba(0, 171, 68, 0.2) 20%,
      rgba(0, 171, 68, 0.2) 80%,
      transparent);
}

@media (prefers-color-scheme: dark) {
  .netdata-chat-window {
    background: #1a1a1a;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }

  .resize-handle:hover {
    background: rgba(0, 214, 89, 0.15);
  }

  .resize-se::after {
    border-color: transparent transparent rgba(0, 214, 89, 0.5) transparent;
  }

  .resize-se::before {
    background: rgba(0, 214, 89, 0.6);
    box-shadow: 4px 0 0 rgba(0, 214, 89, 0.6),
      0 4px 0 rgba(0, 214, 89, 0.6);
  }

  #netdata-chat-iframe {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  }
}

/* fix weird edges on the ellipsis */
#netdata-chat-widget .netdata-chat-button {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 10px;

  height: 48px !important;
  padding: 0 18px !important;
  border-radius: 24px !important;

  overflow: visible !important;
  backface-visibility: hidden;
  will-change: auto;

  background-clip: padding-box;
  /* stops tiny fringe on corners */
}

/* Add a 1px inset stroke to hide any residual fringe */
#netdata-chat-widget .netdata-chat-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* Make sure ancestors don’t clip the corners */
#netdata-chat-widget,
.netdata-chat-widget {
  overflow: visible !important;
}