/* ============================================================
   AI Assistant Panel — assistant.css
   Floating chat button + slide-out panel for AdminLTE 2.x
   ============================================================ */

:root {
  --assistant-primary:   #20808D;
  --assistant-primary-dk:#176870;
  --assistant-bg:        #f8f9fa;
  --assistant-user-bg:   #20808D;
  --assistant-user-text: #ffffff;
  --assistant-bot-bg:    #e9ecef;
  --assistant-bot-text:  #333333;
  --assistant-radius:    12px;
  --assistant-shadow:    0 4px 24px rgba(0,0,0,0.18);
  --assistant-z-btn:     9990;
  --assistant-z-panel:   9991;
}

/* ============================================================
   FLOATING BUTTON
   ============================================================ */
#ai-assistant-btn {
  position:        fixed;
  bottom:          24px;
  right:           24px;
  width:           56px;
  height:          56px;
  border-radius:   50%;
  background:      var(--assistant-primary);
  color:           #fff;
  border:          none;
  cursor:          pointer;
  z-index:         var(--assistant-z-btn);
  box-shadow:      var(--assistant-shadow);
  display:         flex;
  align-items:     center;
  justify-content: center;
  transition:      background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  outline:         none;
  padding:         0;
}

#ai-assistant-btn:hover {
  background:   var(--assistant-primary-dk);
  transform:    scale(1.08);
  box-shadow:   0 6px 28px rgba(0,0,0,0.24);
}

#ai-assistant-btn:active {
  transform: scale(0.96);
}

#ai-assistant-btn svg,
#ai-assistant-btn i {
  pointer-events: none;
}

/* Pulse ring — subtle attention animation */
#ai-assistant-btn::after {
  content:       '';
  position:      absolute;
  top:           -4px;
  left:          -4px;
  right:         -4px;
  bottom:        -4px;
  border-radius: 50%;
  border:        2px solid rgba(32, 128, 141, 0.4);
  animation:     ai-pulse 2.5s ease-out infinite;
  pointer-events: none;
}

@keyframes ai-pulse {
  0%   { transform: scale(1);    opacity: 0.7; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}

/* ============================================================
   PANEL OVERLAY
   ============================================================ */
#ai-assistant-panel {
  position:   fixed;
  top:        0;
  right:      -360px; /* hidden off-screen */
  width:      350px;
  height:     100%;
  background: var(--assistant-bg);
  z-index:    var(--assistant-z-panel);
  display:    flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.16);
  transition: right 0.3s ease;
  /* AdminLTE has a fixed top navbar ~50px */
  padding-top: 0;
  border-left: 1px solid rgba(0,0,0,0.08);
}

#ai-assistant-panel.open {
  right: 0;
}

/* ============================================================
   PANEL HEADER
   ============================================================ */
#ai-assistant-header {
  background:  var(--assistant-primary);
  color:       #fff;
  padding:     14px 16px;
  display:     flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height:  52px;
}

#ai-assistant-header .ai-title {
  font-size:   15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display:     flex;
  align-items: center;
  gap:         8px;
}

#ai-assistant-header .ai-title svg,
#ai-assistant-header .ai-title i {
  opacity: 0.9;
}

#ai-assistant-close {
  background:  transparent;
  border:      none;
  color:       #fff;
  cursor:      pointer;
  padding:     4px 6px;
  border-radius: 4px;
  font-size:   18px;
  line-height: 1;
  opacity:     0.85;
  transition:  opacity 0.15s, background 0.15s;
}

#ai-assistant-close:hover {
  opacity:    1;
  background: rgba(255,255,255,0.15);
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */
#ai-assistant-messages {
  flex:          1;
  overflow-y:    auto;
  padding:       16px 14px;
  display:       flex;
  flex-direction: column;
  gap:           10px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
#ai-assistant-messages::-webkit-scrollbar {
  width: 4px;
}
#ai-assistant-messages::-webkit-scrollbar-thumb {
  background:    rgba(32,128,141,0.3);
  border-radius: 2px;
}

/* ============================================================
   CHAT BUBBLES
   ============================================================ */
.ai-msg {
  display:        flex;
  flex-direction: column;
  max-width:      82%;
  animation:      ai-bubble-in 0.2s ease;
}

@keyframes ai-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self:  flex-end;
  align-items: flex-end;
}

.ai-msg.bot {
  align-self:  flex-start;
  align-items: flex-start;
}

.ai-bubble {
  padding:       9px 13px;
  border-radius: var(--assistant-radius);
  font-size:     13px;
  line-height:   1.5;
  white-space:   pre-wrap;
  word-break:    break-word;
}

.ai-msg.user .ai-bubble {
  background:          var(--assistant-user-bg);
  color:               var(--assistant-user-text);
  border-bottom-right-radius: 3px;
}

.ai-msg.bot .ai-bubble {
  background:         var(--assistant-bot-bg);
  color:              var(--assistant-bot-text);
  border-bottom-left-radius: 3px;
}

.ai-msg-time {
  font-size:  10px;
  color:      #aaa;
  margin-top: 3px;
  padding:    0 2px;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
#ai-typing-indicator {
  display:     none;
  align-self:  flex-start;
  padding:     10px 14px;
  background:  var(--assistant-bot-bg);
  border-radius: var(--assistant-radius);
  border-bottom-left-radius: 3px;
  animation:   ai-bubble-in 0.2s ease;
}

#ai-typing-indicator.visible {
  display: flex;
  gap:     5px;
  align-items: center;
}

.ai-dot {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  background:    #999;
  animation:     ai-dot-bounce 1.2s infinite ease-in-out;
}

.ai-dot:nth-child(1) { animation-delay: 0s;    }
.ai-dot:nth-child(2) { animation-delay: 0.2s;  }
.ai-dot:nth-child(3) { animation-delay: 0.4s;  }

@keyframes ai-dot-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1;   }
}

/* ============================================================
   INPUT AREA
   ============================================================ */
#ai-assistant-input-area {
  padding:     12px 12px 14px;
  background:  #fff;
  border-top:  1px solid #dee2e6;
  display:     flex;
  gap:         8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#ai-assistant-input {
  flex:          1;
  border:        1px solid #ced4da;
  border-radius: 20px;
  padding:       8px 14px;
  font-size:     13px;
  outline:       none;
  resize:        none;
  max-height:    90px;
  min-height:    36px;
  overflow-y:    auto;
  line-height:   1.4;
  transition:    border-color 0.2s;
  font-family:   inherit;
}

#ai-assistant-input:focus {
  border-color: var(--assistant-primary);
  box-shadow:   0 0 0 2px rgba(32,128,141,0.15);
}

#ai-assistant-send {
  width:         36px;
  height:        36px;
  border-radius: 50%;
  background:    var(--assistant-primary);
  color:         #fff;
  border:        none;
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  flex-shrink:   0;
  transition:    background 0.2s, transform 0.15s;
  outline:       none;
  padding:       0;
}

#ai-assistant-send:hover {
  background: var(--assistant-primary-dk);
  transform:  scale(1.08);
}

#ai-assistant-send:active {
  transform: scale(0.93);
}

#ai-assistant-send:disabled {
  opacity:  0.5;
  cursor:   not-allowed;
  transform: none;
}

/* ============================================================
   MOBILE — full width below 768px
   ============================================================ */
@media (max-width: 767px) {
  #ai-assistant-panel {
    width:      100%;
    right:      -100%;
  }

  #ai-assistant-panel.open {
    right: 0;
  }

  #ai-assistant-btn {
    bottom: 16px;
    right:  16px;
    width:  50px;
    height: 50px;
  }
}

/* ============================================================
   BACKDROP (mobile only)
   ============================================================ */
#ai-assistant-backdrop {
  display:    none;
  position:   fixed;
  inset:      0;
  background: rgba(0,0,0,0.3);
  z-index:    9989;
  animation:  ai-fade-in 0.25s ease;
}

#ai-assistant-backdrop.visible {
  display: block;
}

@keyframes ai-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#ai-assistant-upload-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eef6f7;
  color: var(--assistant-primary);
  border: 1px solid #cfe2e5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#ai-assistant-upload-btn:hover {
  background: #dff0f2;
}
