/**
 * Typing Cursor Fix
 * Fixes cursor positioning and visibility issues
 * 
 * @package SENNA_Launcher
 * @since 4.1.0
 */

/* ===========================================
   TYPING CURSOR FIX
   =========================================== */

/* Ensure cursor stays at the end of text */
.sfs-message-content {
  position: relative;
  display: inline-block;
  width: 100%;
}

.sfs-message-content.main-question {
  font-size: 18px;
  font-weight: 500;
  color: #1b4332;
  margin: 20px 0;
}

/* Fix cursor positioning */
.typing-cursor {
  display: inline-block !important;
  vertical-align: text-bottom;
  margin-left: 2px;
  font-weight: 300;
  color: inherit;
  animation: blink 1s infinite;
}

/* Prevent cursor from appearing in middle of text */
.sfs-message-content.typing-initialized .typing-cursor {
  position: relative;
  z-index: 1;
}

/* Hide cursor after typing completes */
.sfs-message-content.typing-complete .typing-cursor {
  display: none !important;
}

/* Text container within message */
.sfs-message-content > span:first-child {
  display: inline;
}

/* ===========================================
   VISUAL CARD SELECTION FIX
   =========================================== */

/* Prevent cards from going blank on selection */
.visual-card.selected {
  background: linear-gradient(
    135deg,
    rgba(27, 67, 50, 0.08) 0%,
    rgba(45, 106, 79, 0.05) 100%
  ) !important;
  border: 2px solid #2d6a4f !important;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(27, 67, 50, 0.15);
}

/* Ensure content stays visible */
.visual-card.selected .visual-card-icon,
.visual-card.selected .visual-card-title,
.visual-card.selected .visual-card-description {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Keep original colors for content */
.visual-card.selected .visual-card-icon {
  background: rgba(27, 67, 50, 0.1) !important;
}

.visual-card.selected .visual-card-icon svg {
  stroke: #2d6a4f !important;
  fill: none !important;
  opacity: 1 !important;
}

.visual-card.selected .visual-card-title {
  color: #1b4332 !important;
  font-weight: 600;
}

.visual-card.selected .visual-card-description {
  color: #4a5a54 !important;
}

/* Selection indicator */
.visual-card.selected::after {
  content: "✓";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: #2d6a4f;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.3);
  animation: checkmarkPop 0.3s ease;
}

@keyframes checkmarkPop {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* ===========================================
   MOBILE RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
  .sfs-message-content.main-question {
    font-size: 16px;
  }

  .visual-card.selected::after {
    width: 20px;
    height: 20px;
    font-size: 12px;
    top: 8px;
    right: 8px;
  }
}

/* ===========================================
   CURSOR ANIMATION
   =========================================== */

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* Ensure proper z-index layering */
.sfs-message-content {
  z-index: 1;
}

.typing-cursor {
  z-index: 2;
}

/* Fix for when both classes are present */
.senna-intro.sfs-message-content,
.sfs-message-content.main-question {
  display: block;
  clear: both;
}

/* Prevent text selection during typing */
.sfs-message-content.typing-initialized {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.sfs-message-content.typing-complete {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}
