/**
 * Pinetrix AI Chatbot — Stylesheet
 * ------------------------------------------------------------------
 * Everything is scoped under #pinetrix-chatbot-root so it can be
 * dropped into any WordPress theme without leaking styles onto the
 * rest of the page, and without being affected by the theme's own
 * global CSS resets.
 *
 * Design tokens are declared as CSS custom properties on the root
 * element, so the whole palette can be re-themed from one place.
 * ------------------------------------------------------------------
 */

#pinetrix-chatbot-root {
  /* ---- Design tokens ------------------------------------------------ */
  --pt-bg-glass: rgba(255, 255, 255, 0.664);
  --pt-bg-glass-strong: rgba(0, 0, 0, 0.92);
  --pt-bg-panel: #0b1020;
  --pt-border: rgba(0, 0, 0, 0.918);
  --pt-blue-500: #000000;
  --pt-blue-400: #60a5fa;
  --pt-blue-300: #ffffff;
  --pt-blue-glow: rgba(255, 21, 21, 0.575);
  --pt-text-primary: #eef2ff;
  --pt-text-secondary: #a3b1d1;
  --pt-text-muted: #000000;
  --pt-online: #34d399;
  --pt-danger: #f32e2e;
  --pt-radius-lg: 20px;
  --pt-radius-md: 14px;
  --pt-radius-sm: 10px;
  --pt-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 4px 16px rgba(0, 0, 0, 0.3);
  --pt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pt-z: 2147483000; /* sit above almost anything a theme might use */

  all: initial;
  * , *::before, *::after { box-sizing: border-box; }

  font-family: var(--pt-font);
  color-scheme: dark;
  position: fixed;
  inset: 0;
  pointer-events: none; /* re-enabled on interactive children */
  z-index: var(--pt-z);
}

#pinetrix-chatbot-root button {
  font-family: inherit;
  cursor: pointer;
}

#pinetrix-chatbot-root a {
  color: rgb(34, 94, 192);
}

/* ===================================================================
   Launcher button
   =================================================================== */
.pt-launcher {
  pointer-events: auto;
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid var(--pt-border);
  background: linear-gradient(145deg, var(--pt-blue-500), #af1e2a);
  box-shadow: 0 10px 30px var(--pt-blue-glow), 0 4px 12px rgba(255, 254, 254, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: pt-float 3.2s ease-in-out infinite;
}

.pt-launcher:hover,
.pt-launcher:focus-visible {
  transform: scale(1.06);
  box-shadow: 0 14px 38px var(--pt-blue-glow), 0 6px 16px rgba(165, 156, 156, 0.4);
}

.pt-launcher:focus-visible {
  outline: 2px solid var(--pt-blue-300);
  outline-offset: 3px;
}

.pt-launcher svg { width: 26px; height: 26px; }

.pt-launcher .pt-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: var(--pt-online);
  border: 2px solid #0b1020;
  border-radius: 50%;
}

@keyframes pt-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ===================================================================
   Panel (main window)
   =================================================================== */
.pt-panel {
  pointer-events: auto;
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(620px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--pt-radius-lg);
  border: 1px solid var(--pt-border);
  background: var(--pt-bg-glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--pt-shadow);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

.pt-panel.pt-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
}

.pt-panel.pt-minimized {
  height: 60px;
}

/* Force scrollbar to be visible and style it */
#pinetrix-chatbot-root .pt-messages {
  overflow-y: auto; /* Ensures content scrolls */
  scrollbar-width: thick; /* For Firefox */
  scrollbar-color: #000000 transparent; /* Thumb color and track color */
}

/* For Chrome, Edge, and Safari */
#pinetrix-chatbot-root .pt-messages::-webkit-scrollbar {
  width: 14px; /* Width of the scrollbar */
}

#pinetrix-chatbot-root .pt-messages::-webkit-scrollbar-track {
  background: transparent; /* Track color */
}

#pinetrix-chatbot-root .pt-messages::-webkit-scrollbar-thumb {
  background-color: #000000; /* Thumb color (matches your blue accent) */
  border-radius: 10px; /* Rounded edges */
  border: 2px solid transparent; /* Creates a padding effect around the thumb */
}

/* ---- Header -------------------------------------------------------- */
.pt-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--pt-bg-glass-strong);
  border-bottom: 1px solid var(--pt-border);
}

.pt-header-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(120deg, rgba(250, 248, 248, 0.699), #fffefe);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.pt-header-logo img { width: 26px; height: 26px; display: block; }

.pt-header-info { flex: 1 1 auto; min-width: 0; }
.pt-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pt-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-header-status {
  font-size: 12px;
  color: var(--pt-text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.pt-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pt-online);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}

.pt-header-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.pt-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgb(255, 48, 48);
  color: rgb(255, 255, 255);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.pt-icon-btn:hover, .pt-icon-btn:focus-visible {
  background: rgb(255, 48, 48);
  color: rgb(255, 255, 255);
}
.pt-icon-btn:focus-visible { outline: 2px solid var(--pt-blue-300); outline-offset: 1px; }
.pt-icon-btn svg { width: 16px; height: 16px; }

/* ---- Messages ------------------------------------------------------- */
.pt-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pt-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.pt-messages::-webkit-scrollbar { width: 6px; }
.pt-messages::-webkit-scrollbar-thumb {
  background: rgba(147, 197, 253, 0.25);
  border-radius: 10px;
}

.pt-msg {
  max-width: 84%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: pt-msg-in 0.22s ease both;
}
@keyframes pt-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.pt-msg-bubble {
  padding: 10px 13px;
  border-radius: var(--pt-radius-md);
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.pt-msg-bubble a { text-decoration: underline; }
.pt-msg-bubble strong { color: rgb(0, 0, 0); }
.pt-msg-bubble code {
  background: rgba(255, 255, 255, 0.35);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.pt-msg-time {
  font-size: 10.5px;
  color: var(--pt-text-muted);
  padding: 0 4px;
}

.pt-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}
.pt-msg-user .pt-msg-bubble {
  background: linear-gradient(145deg, var(--pt-blue-500), #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.pt-msg-assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.pt-msg-assistant .pt-msg-bubble {
  background: rgba(255, 255, 255, 0.719);
  border: 1px solid rgba(0, 0, 0, 0.404);
  color: rgb(0, 0, 0);
  border-bottom-left-radius: 4px;
}

.pt-msg-error .pt-msg-bubble {
  background: rgba(255, 66, 66, 0.842);
  border: 1px solid rgba(255, 39, 39, 0.87);
  color: #fecaca;
}

/* ---- Typing indicator ------------------------------------------------ */
.pt-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: rgba(255, 254, 254, 0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--pt-radius-md);
  border-bottom-left-radius: 4px;
}
.pt-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pt-blue-300);
  animation: pt-bounce 1.1s infinite ease-in-out;
}
.pt-typing span:nth-child(2) { animation-delay: 0.15s; }
.pt-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pt-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Suggested prompts ------------------------------------------------ */
.pt-suggestions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
}
.pt-suggestion-chip {
  border: 1px solid var(--pt-border);
  background: rgba(245, 55, 55, 0.973);
  color: var(--pt-blue-300);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.pt-suggestion-chip:hover, .pt-suggestion-chip:focus-visible {
  background: var(--pt-blue-500);
  color: #fff;
  border-color: var(--pt-blue-500);
}
.pt-suggestion-chip:focus-visible { outline: 2px solid var(--pt-blue-300); outline-offset: 1px; }

#pinetrix-chatbot-root .pt-suggestions {
  max-height: 140px; /* Limits the height */
  padding: 8px 14px;
  background : linear-gradient(120deg, rgba(250, 248, 248, 0.699), rgba(0, 0, 0, 0.63));
  border :#000000 1px solid;
}
#pinetrix-chatbot-root .pt-suggestions.pt-hidden {
  display: none;
}

/* ---- Composer / input area ------------------------------------------- */
.pt-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--pt-border);
  background: var(--pt-bg-glass-strong);
}

.pt-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 100px;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: var(--pt-radius-sm);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--pt-text-primary);
  font-size: 13.5px;
  line-height: 1.4;
}
.pt-input::placeholder { color: rgba(245, 245, 245, 0.637); }
.pt-input:focus-visible {
  outline: none;
  border-color: var(--pt-blue-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.pt-send-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--pt-blue-500), #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.pt-send-btn svg { width: 16px; height: 16px; }
.pt-send-btn:hover:not(:disabled) { transform: scale(1.05); }
.pt-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pt-send-btn:focus-visible { outline: 2px solid var(--pt-blue-300); outline-offset: 2px; }

.pt-footer-note {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--pt-text-muted);
  text-align: center;
  padding: 6px 10px 10px;
}
.pt-footer-note a { color: var(--pt-text-muted); text-decoration: underline; }

/* ===================================================================
   Visually-hidden utility (for screen-reader-only text)
   =================================================================== */
.pt-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ===================================================================
   Mobile responsiveness
   =================================================================== */
@media (max-width: 480px) {
  .pt-panel {
    right: 12px;
    left: 12px;
    bottom: 88px;
    width: auto;
    height: min(72vh, 640px);
  }
  .pt-launcher { right: 16px; bottom: 16px; }
}

/* ===================================================================
   Reduced motion
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
  .pt-launcher,
  .pt-panel,
  .pt-msg,
  .pt-typing span {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
