/**
 * Custom Ripple Effect for Navigation
 * Material Design inspired ripple animation
 */

.custom-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(115, 103, 240, 0.6);
  transform: scale(0);
  animation: ripple-animation 0.6s ease-out;
  pointer-events: none;
  z-index: 0;
}

@keyframes ripple-animation {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0.7;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Dark theme ripple adjustment */
[data-bs-theme='dark'] .custom-ripple {
  background: rgba(115, 103, 240, 0.5);
}

/* Menu item specific ripple for active states */
.menu-item.active .menu-link .custom-ripple {
  background: rgba(115, 103, 240, 0.7);
}

/* Remove shadow from active menu items in dark mode */
[data-bs-theme='dark'] .menu-item.active > .menu-link:not(.menu-toggle) {
  box-shadow: none;
}

[data-bs-theme='dark'] .menu.menu-horizontal .menu-inner > .menu-item.active > .menu-link.menu-toggle {
  box-shadow: none;
}

/* Remove shadow from active nav-pills (settings tabs) in dark mode */
[data-bs-theme='dark'] .nav-pills .nav-link.active {
  box-shadow: none;
}

/* Remove shadow from buttons in dark mode */
[data-bs-theme='dark'] .btn {
  box-shadow: none;
}

[data-bs-theme='dark'] .btn.active,
[data-bs-theme='dark'] .btn:active,
[data-bs-theme='dark'] .btn.show {
  box-shadow: none;
}

[data-bs-theme='dark'] .btn:focus-visible {
  box-shadow: none;
}

/* Remove shadow from form controls (textboxes, inputs) when focused in dark mode */
[data-bs-theme='dark'] .form-control:focus,
[data-bs-theme='dark'] .form-control.is-invalid:focus,
[data-bs-theme='dark'] .form-control.is-valid:focus,
[data-bs-theme='dark'] .form-select:focus {
  box-shadow: none;
}

/* Remove shadow from input groups when focused in dark mode */
[data-bs-theme='dark'] .input-group:focus-within,
[data-bs-theme='dark'] .input-group:focus {
  box-shadow: none;
}

[data-bs-theme='dark'] .input-group:focus-within::before,
[data-bs-theme='dark'] .input-group:focus::before {
  box-shadow: none;
}

/* Dropdown item ripple */
.dropdown-item .custom-ripple {
  background: rgba(115, 103, 240, 0.6);
}

/* Theme switcher ripple */
[data-bs-theme-value] .custom-ripple {
  background: rgba(115, 103, 240, 0.6);
}

/* Language switcher ripple */
.lang-switcher .custom-ripple {
  background: rgba(115, 103, 240, 0.6);
}

/* Sidebar menu hover highlight */
.menu-hover-highlight {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 0.375rem;
  background: var(--bs-menu-hover-bg);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  transition:
    transform 0.23s cubic-bezier(0.28, 0.95, 0.35, 1),
    width 0.23s cubic-bezier(0.28, 0.95, 0.35, 1),
    height 0.23s cubic-bezier(0.28, 0.95, 0.35, 1),
    opacity 0.16s ease-out;
  z-index: 0;
}

.menu-hover-highlight.is-visible {
  opacity: 1;
}

.menu-inner.has-hover-highlight .menu-item:not(.active):not(.open) .menu-link:hover,
.menu-inner.has-hover-highlight .menu-item:not(.active):not(.open) .menu-link:focus-visible {
  background-color: transparent;
}

#settings-tab-list.has-hover-highlight [data-settings-tab]:not(.active):hover,
#settings-tab-list.has-hover-highlight [data-settings-tab]:not(.active):focus-visible {
  background-color: transparent;
  color: var(--bs-body-color);
}

#settings-tab-list.has-hover-highlight [data-settings-tab]:not(.active):hover .icon-base,
#settings-tab-list.has-hover-highlight [data-settings-tab]:not(.active):focus-visible .icon-base {
  color: inherit;
}

/* Hide hover highlight on mobile/touch devices */
@media (max-width: 1199.98px) {
  .menu-hover-highlight {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* Hide hover highlight on touch devices */
@media (hover: none) and (pointer: coarse) {
  .menu-hover-highlight {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }
}

/* Settings navigation sizing */
.settings-tab-list .nav-link {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 0.5rem;
}

.settings-tab-list .nav-link .icon-base {
  font-size: 1rem;
}

/* ============================================
   AI Chatbot Agent Styles
   ============================================ */

/* Chatbot Container */
#ai-chatbot-container {
  position: fixed;
  z-index: 999999;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7367f0 0%, #9e95f5 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.4);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999999;
}

/* Position based on RTL/LTR */
html:not([dir='rtl']) .chatbot-toggle {
  right: 24px;
}

html[dir='rtl'] .chatbot-toggle {
  left: 24px;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(115, 103, 240, 0.5);
}

.chatbot-toggle:active {
  transform: scale(0.97);
  transform-origin: center center;
}

.chatbot-toggle.is-active {
  background: linear-gradient(135deg, #9e95f5 0%, #7367f0 100%);
}

.chatbot-toggle .icon-base {
  font-size: 28px;
  transition: transform 0.3s ease;
}

.chatbot-toggle.is-active .icon-base {
  transform: rotate(180deg);
}

/* Safe bottom space so FAB never overlaps page content */
@media (min-width: 1200px) {
  .content-wrapper,
  #app-content {
    padding-bottom: 96px !important;
  }
}

/* Notification Badge */
.chatbot-notification-badge {
  position: absolute;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff4c51;
  border: 2px solid white;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html:not([dir='rtl']) .chatbot-notification-badge {
  right: 8px;
}

html[dir='rtl'] .chatbot-notification-badge {
  left: 8px;
}

.chatbot-notification-badge.has-notification {
  opacity: 1;
  transform: scale(1);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* Chatbot Panel */
.chatbot-panel {
  position: fixed;
  bottom: 96px;
  width: 420px;
  max-width: calc(100vw - 48px);
  max-width: calc(100dvw - 48px);
  max-width: calc(100svw - 48px);
  height: 600px;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  max-height: calc(100svh - 120px);
  background: var(--bs-body-bg);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--bs-border-color);
  overflow: hidden;
}

html:not([dir='rtl']) .chatbot-panel {
  right: 24px;
}

html[dir='rtl'] .chatbot-panel {
  left: 24px;
}

.chatbot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Maximized State */
.chatbot-panel.is-maximized {
  width: calc(100vw - 48px) !important;
  width: calc(100dvw - 48px) !important;
  height: calc(100vh - 48px) !important;
  height: calc(100dvh - 48px) !important;
  max-width: calc(100vw - 48px) !important;
  max-width: calc(100dvw - 48px) !important;
  max-height: calc(100vh - 48px) !important;
  max-height: calc(100dvh - 48px) !important;
  bottom: 24px !important;
  border-radius: 16px;
}

html:not([dir='rtl']) .chatbot-panel.is-maximized {
  right: 24px !important;
  left: auto !important;
}

html[dir='rtl'] .chatbot-panel.is-maximized {
  left: 24px !important;
  right: auto !important;
}

.chatbot-panel.is-maximized.is-open {
  transform: translateY(0) scale(1);
}

/* Chatbot Header */
.chatbot-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bs-body-bg);
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7367f0 0%, #9e95f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.chatbot-header h6 {
  font-size: 14px;
  font-weight: 600;
  color: var(--bs-body-color);
}

.chatbot-header small {
  font-size: 12px;
  color: var(--bs-text-muted);
}

.chatbot-header-actions {
  display: flex;
  gap: 4px;
}

/* Messages Area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bs-body-bg);
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--bs-text-muted);
}

/* Message Styles */
.chatbot-message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bot-message {
  align-self: flex-start;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.bot-message .message-avatar {
  background: linear-gradient(135deg, #7367f0 0%, #9e95f5 100%);
  color: white;
}

.user-message .message-avatar {
  background: var(--bs-gray-200);
  color: var(--bs-body-color);
}

[data-bs-theme='dark'] .user-message .message-avatar {
  background: var(--bs-gray-800);
}

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 75%;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
}

.bot-message .message-bubble {
  background: var(--bs-gray-100);
  color: var(--bs-body-color);
  border-top-left-radius: 4px;
}

[data-bs-theme='dark'] .bot-message .message-bubble {
  background: var(--bs-gray-800);
}

.user-message .message-bubble {
  background: linear-gradient(135deg, #7367f0 0%, #9e95f5 100%);
  color: white;
  border-top-right-radius: 4px;
}

.message-bubble p {
  font-size: 14px;
  line-height: 1.5;
}

.message-time {
  padding: 0 4px;
}

.user-message .message-time {
  text-align: right;
}

.message-time small {
  font-size: 11px;
}

/* Quick Actions */
.chatbot-quick-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--bs-border-color);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bs-body-bg);
  flex-shrink: 0;
}

.quick-action-btn {
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-action-btn:hover {
  background: var(--bs-gray-100);
  border-color: #7367f0;
  color: #7367f0;
  transform: translateY(-1px);
}

[data-bs-theme='dark'] .quick-action-btn:hover {
  background: var(--bs-gray-800);
}

.quick-action-btn .icon-base {
  font-size: 14px;
}

/* Input Area */
.chatbot-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  flex-shrink: 0;
}

.chatbot-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 24px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  transition: all 0.2s ease;
}

.chatbot-input-wrapper:focus-within {
  border-color: #7367f0;
  box-shadow: 0 0 0 3px rgba(115, 103, 240, 0.1);
}

.chatbot-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--bs-body-color);
  font-size: 14px;
  resize: none;
  min-height: 20px;
  max-height: 120px;
  line-height: 1.5;
  padding: 0;
}

.chatbot-input::placeholder {
  color: var(--bs-text-muted);
}

.chatbot-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 4px;
}

.chatbot-input-footer small {
  font-size: 11px;
}

/* Debug chatbot is available on all screen sizes */

/* Responsive Design */
@media (max-width: 768px) {
  .chatbot-panel {
    width: calc(100vw - 32px);
    width: calc(100dvw - 32px);
    width: calc(100svw - 32px);
    height: calc(100vh - 100px);
    height: calc(100dvh - 100px);
    height: calc(100svh - 100px);
    bottom: 16px;
  }

  html:not([dir='rtl']) .chatbot-panel {
    right: 16px;
  }

  html[dir='rtl'] .chatbot-panel {
    left: 16px;
  }

  .chatbot-toggle {
    bottom: 16px;
  }

  html:not([dir='rtl']) .chatbot-toggle {
    right: 16px;
  }

  html[dir='rtl'] .chatbot-toggle {
    left: 16px;
  }
}

/* Mobile nav safe margin - push chatbot FAB above mobile bottom nav */
@media (max-width: 1199.98px) {
  .chatbot-toggle {
    bottom: 76px; /* Clear mobile bottom nav (~60px + 16px spacing) */
  }

  .chatbot-panel {
    bottom: 148px; /* Above FAB (76px) + FAB height (56px) + 16px spacing */
  }

  .message-content {
    max-width: 85%;
  }

  .quick-action-btn {
    font-size: 11px;
    padding: 6px 10px;
  }
}

/* Mobile - Full Screen Mode */
@media (max-width: 576px) {
  .chatbot-panel {
    width: 100vw;
    width: 100dvw;
    width: 100svw;
    height: 100vh;
    height: 100dvh;
    height: 100svh;
    max-width: 100vw;
    max-width: 100dvw;
    max-width: 100svw;
    max-height: 100vh;
    max-height: 100dvh;
    max-height: 100svh;
    bottom: 0;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0;
  }

  .chatbot-header {
    padding: 20px 16px;
  }

  .chatbot-messages {
    padding: 16px;
  }

  .chatbot-input-area {
    padding: 12px 16px;
  }
}

/* RTL Support */
html[dir='rtl'] .bot-message .message-bubble {
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}

html[dir='rtl'] .user-message .message-bubble {
  border-top-right-radius: 12px;
  border-top-left-radius: 4px;
}

html[dir='rtl'] .user-message .message-time {
  text-align: left;
}

/* Smooth Transitions */
.chatbot-panel * {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Typing Indicator (3 bouncing dots) */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7367f0;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Typing Cursor for Streaming Text */
.streaming-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #7367f0;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s ease-in-out infinite;
}

@keyframes cursorBlink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* Dark mode adjustments for indicators */
[data-bs-theme='dark'] .typing-indicator span {
  background: #9e95f5;
}

[data-bs-theme='dark'] .typing-cursor {
  background: #9e95f5;
}

/* Accessibility Focus Styles */
.chatbot-toggle:focus-visible,
.quick-action-btn:focus-visible,
.chatbot-header-actions button:focus-visible,
.chatbot-input-wrapper button:focus-visible {
  outline: 2px solid #7367f0;
  outline-offset: 2px;
}

.chatbot-input:focus-visible {
  outline: none;
}

/* Dark Theme Adjustments */
[data-bs-theme='dark'] .chatbot-panel {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-bs-theme='dark'] .chatbot-toggle {
  box-shadow: 0 4px 12px rgba(115, 103, 240, 0.3);
}

[data-bs-theme='dark'] .chatbot-toggle:hover {
  box-shadow: 0 6px 20px rgba(115, 103, 240, 0.4);
}

/* Ripple effect for chatbot buttons */
#ai-chatbot-container .custom-ripple {
  background: rgba(115, 103, 240, 0.4);
}

.quick-action-btn .custom-ripple {
  background: rgba(115, 103, 240, 0.3);
}

/* Darker warning badge in dark mode */
[data-bs-theme='dark'] .badge.text-bg-warning,
[data-bs-theme='dark'] .badge.bg-warning {
  background-color: #8c5e00 !important;
  color: var(--bs-white) !important;
}

/* Darker primary badge in dark mode */
[data-bs-theme='dark'] .badge.text-bg-primary,
[data-bs-theme='dark'] .badge.bg-primary {
  background-color: #4a3a8f !important;
  color: var(--bs-white) !important;
}

/* Refresh button spin on hover */
.refresh-spin-hover:hover i {
  animation: spin-once 0.6s ease-in-out;
}

@keyframes spin-once {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}