/* =============================================================================
   FILE: help_system.css
   PURPOSE: Styles for the Assisted Help System (Avatar, Bubble, and Nav Button)
   RELATIONS: templates/base.html, style.css, help_system.js
   ============================================================================= */

/* Nav button specific styles */
.btn-help {
  position: relative;
}

/* Float Help Container */
.help-assistant-container {
  position: fixed !important;
  z-index: 9999 !important;
  display: flex;
  flex-direction: column !important;
  align-items: flex-end !important;
  pointer-events: none !important;
}

/* Avatar Wrapper */
.help-avatar-wrapper {
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  pointer-events: auto; /* Active for clicks */
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.help-avatar-wrapper:not(.active):hover {
  opacity: 0.95;
  box-shadow: 0 12px 36px 0 rgba(31, 38, 135, 0.4);
}

/* Active settled state */
.help-avatar-wrapper.active {
  opacity: 1;
}

.help-avatar-wrapper.active:hover {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.4);
}

.help-avatar-sprite {
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
  background-image: url('../images/avatar_sprite.png') !important;
  background-repeat: no-repeat !important;
  background-size: 4100% 100%;
  background-position: 0% 0px;
}



/* Dialog Speech Bubble */
.help-bubble-wrapper {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 15px;
  max-width: none !important;
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  display: none;
  box-sizing: border-box !important;
}

.help-bubble-wrapper.show {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.help-bubble {
  position: relative;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15),
              inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #1a252f;
  font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  box-sizing: border-box !important;
}

/* Bubble Arrow pointing to Avatar */
.help-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 80px;
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.92) transparent;
  display: block;
  width: 0;
}

/* Speech Text */
.help-bubble-text {
  margin-bottom: 12px;
  font-weight: 500;
  text-align: justify;
}

/* Options Container */
.help-options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* Option Buttons */
.help-option-btn {
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  font-size: 0.88rem;
  font-weight: 600;
  color: #495057;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
}

.help-option-btn:hover {
  background: none !important;
  border-color: transparent !important;
  color: #007bff;
  transform: none !important;
}

.help-option-btn .option-number {
  background: none !important;
  color: inherit;
  width: auto !important;
  height: auto !important;
  border-radius: 0 !important;
  display: inline;
  font-size: 0.88rem;
  font-weight: 700;
}

.help-option-btn:hover .option-number {
  background: none !important;
  color: inherit;
}

/* Close/X Button */
.help-close-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  color: #adb5bd;
  cursor: pointer;
  transition: color 0.2s ease;
  line-height: 1;
  padding: 2px 6px;
}

.help-close-btn:hover {
  color: #dc3545;
}

/* Mobile responsive adjustments */
@media (max-width: 576px) {
  .help-bubble-wrapper {
    width: 290px;
    max-width: calc(100vw - 36px) !important;
  }
  
  .help-avatar-wrapper {
    border-radius: 50% !important;
  }
  
  .help-bubble::after {
    right: 60px;
  }
  
  .help-bubble {
    font-size: 0.85rem;
    padding: 12px;
  }
}

/* Image view mode styling for full bleed image inside speech bubble */
.help-bubble.image-view {
  padding: 0 !important;
  overflow: hidden !important;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.help-bubble.image-view .help-bubble-text {
  margin-bottom: 0 !important;
}

.help-image-content {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

/* Side bubble layout for desktop helper images */
@media (min-width: 577px) {
  .help-bubble-wrapper.side-bubble {
    bottom: 0 !important;
    right: 100% !important;
    margin-right: 15px !important;
    margin-bottom: 0 !important;
  }
  .help-bubble-wrapper.side-bubble .help-bubble::after {
    bottom: 80px !important;
    right: -10px !important;
    border-width: 10px 0 10px 10px !important;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.92) !important;
  }
}

/* Mixed view mode (Image + Description text) adaptive styling */
.help-bubble.mixed-view {
  padding: 16px !important;
  display: flex !important;
  box-sizing: border-box !important;
}

/* Horizontal Column Layout (Desktop standard) */
.help-bubble.mixed-view.mixed-layout-horizontal {
  flex-direction: row !important;
  gap: 16px !important;
}

.help-bubble.mixed-view.mixed-layout-horizontal .mixed-image-col {
  width: 66.66% !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
}

.help-bubble.mixed-view.mixed-layout-horizontal .mixed-text-col {
  width: 33.33% !important;
  flex-grow: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
}

/* Vertical Stack Layout (Mobile & Ultra-wide/chata images in desktop) */
.help-bubble.mixed-view.mixed-layout-vertical {
  flex-direction: column !important;
  gap: 12px !important;
}

.help-bubble.mixed-view.mixed-layout-vertical .mixed-image-col {
  width: 100% !important;
  display: block !important;
}

.help-bubble.mixed-view.mixed-layout-vertical .mixed-text-col {
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
}

/* Image wrapper content */
.mixed-image-col img.help-image-content {
  max-width: 100% !important;
  max-height: calc(100vh - 130px) !important;
  width: auto !important;
  height: auto !important;
  display: block !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* Scrollbar and typing space for mixed text column */
.mixed-text-col {
  max-height: 100% !important;
  overflow-y: auto !important;
  padding-right: 6px !important;
}

/* Styling scrollbar for premium look */
.mixed-text-col::-webkit-scrollbar {
  width: 6px;
}
.mixed-text-col::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}
.mixed-text-col::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
.mixed-text-col::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Mobile responsive force vertical */
@media (max-width: 576px) {
  .help-bubble.mixed-view {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 12px !important;
  }
  .help-bubble.mixed-view .mixed-image-col,
  .help-bubble.mixed-view .mixed-text-col {
    width: 100% !important;
  }
  /* Prevent text column from collapsing due to indeterminate max-height inside vertical flex container on mobile */
  .help-bubble.mixed-view .mixed-text-col {
    max-height: none !important;
    overflow-y: visible !important;
  }
}
