/* axionia-chat.css */
:root {
  --axionia-primary: #0f172a; /* Slate 900 */
  --axionia-secondary: #1e293b; /* Slate 800 */
  --axionia-accent: #38bdf8; /* Sky 400 */
  --axionia-accent-hover: #0ea5e9; /* Sky 500 */
  --axionia-bg: #f8fafc; /* Slate 50 */
  --axionia-border: #e2e8f0; /* Slate 200 */
  --axionia-text: #0f172a;
  --axionia-text-light: #64748b; /* Slate 500 */
  --axionia-white: #ffffff;
}

#axionia-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ax-greeting-pill {
  background: var(--axionia-white);
  color: var(--axionia-text);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  position: relative;
  border: 1px solid var(--axionia-border);
}

/* Triangle pointer for the pill */
.ax-greeting-pill::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: var(--axionia-white);
  transform: rotate(45deg);
  border-right: 1px solid var(--axionia-border);
  border-bottom: 1px solid var(--axionia-border);
}

.ax-greeting-pill.ax-show {
  opacity: 1;
  transform: translateY(0);
}

.ax-bubble-toggle {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: var(--axionia-primary);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid transparent;
  color: var(--axionia-white);
  animation: ax-widget-pulse 2s infinite;
}

@keyframes ax-widget-pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--axionia-primary-rgb, 15, 23, 42), 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(var(--axionia-primary-rgb, 15, 23, 42), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--axionia-primary-rgb, 15, 23, 42), 0); }
}

.ax-bubble-toggle:hover {
  transform: scale(1.08) translateY(-4px);
  border-color: rgba(255, 255, 255, 0.1);
  animation: none;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

.ax-bubble-toggle.ax-opened {
  background: var(--axionia-secondary);
  animation: none;
}

.ax-icon {
  width: 32px;
  height: 32px;
  fill: currentColor;
  transition: transform 0.3s ease, opacity 0.3s ease;
  position: absolute;
}

.ax-icon-chat {
  opacity: 1;
  transform: rotate(0) scale(1);
}
.ax-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.ax-opened .ax-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
.ax-opened .ax-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.ax-chat-window {
  width: 380px;
  height: 620px;
  max-height: calc(100vh - 120px);
  background: var(--axionia-bg);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.ax-chat-window.ax-show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ax-chat-header {
  background: var(--axionia-primary);
  padding: 24px 20px;
  color: var(--axionia-white);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.ax-chat-header::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  background: radial-gradient(
    circle,
    rgba(56, 189, 248, 0.2) 0%,
    rgba(0, 0, 0, 0) 70%
  );
  border-radius: 50%;
  animation: ax-pulse 4s infinite alternate ease-in-out;
}

@keyframes ax-pulse {
  from {
    transform: scale(1);
    opacity: 0.8;
  }
  to {
    transform: scale(1.5);
    opacity: 1;
  }
}

.ax-chat-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.ax-chat-subtitle {
  font-size: 13px;
  color: var(--axionia-accent);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.ax-pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--axionia-accent);
  border-radius: 50%;
  animation: ax-blink 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes ax-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.ax-chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.ax-chat-body::-webkit-scrollbar {
  width: 6px;
}
.ax-chat-body::-webkit-scrollbar-thumb {
  background: var(--axionia-border);
  border-radius: 4px;
}

.ax-msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: ax-slide-up 0.3s ease-out forwards;
}

@keyframes ax-slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ax-msg-wrapper.ax-user {
  align-self: flex-end;
}
.ax-msg-wrapper.ax-bot {
  align-self: flex-start;
}

.ax-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--axionia-text);
  word-break: break-word;
}

.ax-msg-wrapper.ax-user .ax-msg-bubble {
  background: var(--axionia-primary);
  color: var(--axionia-white);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ax-msg-wrapper.ax-bot .ax-msg-bubble {
  background: var(--axionia-white);
  border: 1px solid var(--axionia-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.ax-msg-bubble p:first-child {
  margin-top: 0;
}
.ax-msg-bubble p:last-child {
  margin-bottom: 0;
}
.ax-msg-bubble p {
  margin-bottom: 10px;
}
.ax-msg-bubble strong {
  font-weight: 700;
  color: inherit;
}
.ax-msg-bubble ul,
.ax-msg-bubble ol {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.ax-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 4px;
}
.ax-typing span {
  width: 6px;
  height: 6px;
  background: var(--axionia-text-light);
  border-radius: 50%;
  animation: ax-typing-dots 1.4s infinite ease-in-out both;
}
.ax-typing span:nth-child(1) {
  animation-delay: -0.32s;
}
.ax-typing span:nth-child(2) {
  animation-delay: -0.16s;
}
@keyframes ax-typing-dots {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.ax-chat-footer {
  padding: 16px 20px;
  background: var(--axionia-white);
  border-top: 1px solid var(--axionia-border);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.ax-input-box {
  flex: 1;
  background: var(--axionia-bg);
  border: 1px solid var(--axionia-border);
  border-radius: 20px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}

.ax-input-box:focus-within {
  border-color: var(--axionia-accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
  background: var(--axionia-white);
}

.ax-input-box input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--axionia-text);
}
.ax-input-box input::placeholder {
  color: var(--axionia-text-light);
}

.ax-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--axionia-primary);
  color: var(--axionia-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ax-send-btn:hover {
  background: var(--axionia-accent-hover);
  transform: scale(1.05);
}
.ax-send-btn:disabled {
  background: var(--axionia-border);
  color: var(--axionia-text-light);
  cursor: not-allowed;
  transform: none;
}
.ax-send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
  flex-shrink: 0;
}
.ax-send-btn svg path {
  fill: currentColor;
}

/* Suggestions */
.ax-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.ax-sugg-btn {
  background: transparent;
  border: 1px solid var(--axionia-accent);
  color: var(--axionia-accent);
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.ax-sugg-btn:hover {
  background: var(--axionia-accent);
  color: var(--axionia-white);
}

/* Responsive & Mobile Optimizations (Full Screen) */
@media (max-width: 480px) {
  #axionia-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  .ax-bubble-toggle {
    width: 60px;
    height: 60px;
  }

  /* Chat window occupies full screen but respects safe-areas */
  .ax-chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    border: none;
    z-index: 9999998;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  .ax-chat-header {
    padding: 18px 16px;
    border-radius: 0;
  }

  .ax-msg-wrapper {
    max-width: 95%;
  }

  .ax-chat-footer {
    padding: 12px 16px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
  }

  .ax-send-btn {
    width: 40px;
    height: 40px;
  }

  /* Move toggle button above the chat when opened to be used as closer */
  .ax-bubble-toggle.ax-opened {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0));
    right: 16px;
    width: 45px;
    height: 45px;
    z-index: 9999999;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    color: var(--axionia-text);
  }

  .ax-bubble-toggle.ax-opened:hover {
    transform: none;
  }
}
