/* auronx-chat-widget.css */

:root {
  --auronx-chat-header-bg: #1e1b4b;
  --auronx-chat-bg: #09090b;
  --auronx-chat-send-bg: #6366f1;
  --auronx-chat-message-bg: #27272a;
  --auronx-chat-input-bg: #1a1a1e;
  --auronx-chat-text: #ffffff;
  --auronx-font-family: system-ui, -apple-system, sans-serif;
}

#auronx-chat-widget-container {
  font-family: var(--auronx-font-family);
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2147483647; /* Max z-index to stay on top */
  pointer-events: none; /* Let clicks pass through the container wrapper */
  text-align: left; /* Prevent host website centering from affecting widget */
}

#auronx-chat-widget-container *,
#auronx-chat-widget-container *::before,
#auronx-chat-widget-container *::after {
  box-sizing: border-box;
}

/* Floating Action Button (Minimized State) */
.auronx-chat-fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 32px;
  background: var(--auronx-chat-send-bg);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.3s ease;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.1);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.auronx-chat-fab.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.auronx-chat-fab:hover {
  transform: scale(1.05);
}

/* Main Chat Window */
.auronx-chat-window {
  position: absolute;
  width: 400px;
  height: 600px;
  min-width: 320px;
  min-height: 400px;
  /* Top & Left will be set by JS immediately, otherwise defaults to bottom-right visually initially */
  background: var(--auronx-chat-bg);
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  border: none;
  transition: opacity 0.3s ease, border-radius 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.auronx-chat-window.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Fullscreen mode modifier */
.auronx-chat-window.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  top: 0 !important;
  left: 0 !important;
  border-radius: 0;
  transition: all 0.3s ease;
}

/* Hide resizers in fullscreen */
.auronx-chat-window.fullscreen .arx-resize-handle {
  display: none !important;
}

/* Header */
.auronx-chat-header {
  height: 72px;
  background: var(--auronx-chat-header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  overflow: hidden;
}

.auronx-chat-header:active {
  cursor: grabbing;
}

.auronx-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auronx-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  overflow: hidden;
  background: #fff;
}

.auronx-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auronx-chat-title {
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
}

.auronx-chat-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

/* School Logo Area */
.auronx-chat-school-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.auronx-chat-school-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auronx-chat-school-logo.placeholder {
  padding: 4px;
  text-align: center;
}

.auronx-chat-school-logo.placeholder span {
  font-size: 8px;
  font-weight: 800;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.2;
}

/* Messages Area */
.auronx-chat-messages {
  flex: 1;
  background: var(--auronx-chat-bg);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auronx-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.auronx-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.auronx-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.auronx-chat-message-row {
  display: flex;
}

.auronx-chat-message-row.user {
  justify-content: flex-end;
}

.auronx-chat-message-row.ai {
  justify-content: flex-start;
}

.auronx-chat-bubble {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
  color: var(--auronx-chat-text);
  word-wrap: break-word;
}

.auronx-chat-message-row.user .auronx-chat-bubble {
  background: var(--auronx-chat-send-bg);
  border-bottom-right-radius: 0;
}

.auronx-chat-message-row.ai .auronx-chat-bubble {
  background: var(--auronx-chat-message-bg);
  border-bottom-left-radius: 0;
}

/* Typing Indicator */
.auronx-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--auronx-chat-message-bg);
  border-radius: 16px;
  border-bottom-left-radius: 0;
  width: fit-content;
}

.auronx-chat-dot {
  width: 6px;
  height: 6px;
  background: #a5b4fc;
  border-radius: 50%;
  animation: auronx-bounce 1.4s infinite ease-in-out both;
}

.auronx-chat-dot:nth-child(1) { animation-delay: -0.32s; }
.auronx-chat-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes auronx-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.auronx-chat-input-area {
  flex-shrink: 0;
  background: var(--auronx-chat-input-bg);
  display: flex;
  align-items: stretch;
  min-height: 60px;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  overflow: hidden;
}

.auronx-chat-input-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 20px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.auronx-chat-powered-by {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 4px;
  padding-left: 20px;
  padding-top: 4px;
  letter-spacing: 0.5px;
  user-select: none;
}

.auronx-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--auronx-chat-text);
  font-size: 14px;
  outline: none;
  width: 100%;
}

.auronx-chat-input::placeholder {
  color: #71717a;
}

.auronx-chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}

.auronx-chat-action-btn {
  background: transparent;
  border: none;
  color: #fff;
  opacity: 0.6;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.auronx-chat-action-btn:hover {
  opacity: 1;
}

.auronx-chat-action-btn.active.mic {
  color: #ef4444;
  opacity: 1;
  animation: auronx-pulse 1.5s infinite;
}

.auronx-chat-action-btn.active.audio {
  color: #4ade80;
  opacity: 1;
}

@keyframes auronx-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

.auronx-chat-send-btn {
  background: var(--auronx-chat-header-bg);
  border: none;
  color: #fff;
  padding: 0 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.auronx-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auronx-chat-send-btn:hover:not(:disabled) {
  opacity: 0.9;
}

/* ==============================================================
   OMNIDIRECTIONAL RESIZE HANDLES
   These invisible divs sit on the edges to capture drag events.
   ============================================================== */
.arx-resize-handle {
  position: absolute;
  z-index: 10;
}
.arx-resize-n { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.arx-resize-s { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.arx-resize-e { top: 8px; bottom: 8px; right: -4px; width: 8px; cursor: e-resize; }
.arx-resize-w { top: 8px; bottom: 8px; left: -4px; width: 8px; cursor: w-resize; }
.arx-resize-ne { top: -4px; right: -4px; width: 16px; height: 16px; cursor: ne-resize; z-index: 11; }
.arx-resize-nw { top: -4px; left: -4px; width: 16px; height: 16px; cursor: nw-resize; z-index: 11; }
.arx-resize-se { bottom: -4px; right: -4px; width: 16px; height: 16px; cursor: se-resize; z-index: 11; }
.arx-resize-sw { bottom: -4px; left: -4px; width: 16px; height: 16px; cursor: sw-resize; z-index: 11; }
