/**
 * VMO Business Wizard UI Fixes
 * Fixes text overflow, button spacing, and layout issues
 * Version: 1.0.0
 */

/* ========================================
   BUSINESS WIZARD COMPREHENSIVE UI FIXES
   ======================================== */

/* Fix suggestion buttons - prevent text overflow */
.vmo-wizard-suggestions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 15px;
  width: 100%;
}

.vmo-wizard-suggestion {
  background: rgba(0, 255, 255, 0.1);
  border: 1px solid rgba(0, 255, 255, 0.2);
  color: #00e2ff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: normal;
  word-wrap: break-word;
  max-width: 100%;
  text-align: center;
  line-height: 1.5;
  flex: 0 1 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.vmo-wizard-suggestion:hover {
  background: rgba(0, 255, 255, 0.2);
  border-color: rgba(0, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 228, 255, 0.2);
}

/* Fix wizard action buttons layout */
.vmo-wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px 0 10px 0;
  min-height: 60px;
  width: 100%;
}

/* Fix all wizard buttons - no text overflow */
.vmo-wizard-btn {
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.3;
  max-width: 100%;
  box-sizing: border-box;
}

/* Fix primary buttons */
.vmo-wizard-btn-primary {
  background: linear-gradient(135deg, #4ecdc4, #44a08d);
  color: white;
}

.vmo-wizard-btn-primary:hover {
  background: linear-gradient(135deg, #45b7aa, #3e8f7d);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.3);
}

/* Fix secondary buttons */
.vmo-wizard-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #eaffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.vmo-wizard-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Fix outline buttons */
.vmo-wizard-btn-outline {
  background: transparent;
  color: rgba(234, 255, 255, 0.9);
  border: 1px solid rgba(0, 255, 255, 0.4);
  padding: 12px 22px;
}

.vmo-wizard-btn-outline:hover {
  background: rgba(0, 255, 255, 0.12);
  border-color: rgba(0, 255, 255, 0.6);
}

/* Fix start consultation button - MOST IMPORTANT */
.vmo-wizard-btn-start {
  background: transparent !important;
  color: #00e4ff !important;
  border: 2px solid #00e4ff !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  padding: 18px 36px !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 auto !important;
  position: relative !important;
  z-index: 1000001 !important;
  min-width: 320px !important;
  max-width: 90% !important;
  white-space: normal !important;
  text-align: center !important;
  line-height: 1.4 !important;
  word-wrap: break-word !important;
  overflow: visible !important;
  height: auto !important;
  min-height: 56px !important;
}

.vmo-wizard-btn-start:hover {
  background: rgba(0, 228, 255, 0.15) !important;
  color: #ffffff !important;
  border-color: #00e4ff !important;
  transform: translateY(-3px) !important;
  box-shadow: 0 8px 24px rgba(0, 228, 255, 0.4) !important;
}

/* Fix input control buttons - Match main chat styling */
.vmo-wizard-input-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
  flex-wrap: nowrap;
}

.vmo-wizard-input-btn {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 6px !important;
  background: rgba(0, 228, 255, 0.1) !important;
  color: #00e4ff !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.15s ease !important;
  opacity: 0.7 !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 2 !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

.vmo-wizard-input-btn:hover {
  background: rgba(0, 228, 255, 0.2) !important;
  opacity: 1 !important;
  /* Remove scale to prevent horizontal scrollbar/jump */
  transform: none !important;
}

.vmo-wizard-input-btn:active {
  /* Remove scale to prevent flicker */
  transform: none !important;
}

.vmo-wizard-input-btn svg {
  width: 16px !important;
  height: 16px !important;
  fill: currentColor !important;
}

.vmo-wizard-input-btn svg {
  width: 18px !important;
  height: 18px !important;
  fill: currentColor !important;
  flex-shrink: 0 !important;
}

/* Fix textarea container - move down to use empty space */
.vmo-wizard-input-container {
  position: relative;
  width: 100%;
  margin-bottom: 0; /* Remove bottom margin to use vacant space */
  /* Prevent horizontal scrollbar flicker */
  overflow-x: hidden;
}

#vmo-wizard-response {
  width: 100%;
  min-height: 80px;
  max-height: 200px;
  padding: 14px 120px 56px 14px; /* Extra padding-right for buttons and bottom space for controls */
  background: rgba(0, 22, 34, 0.5);
  border: 1px solid rgba(0, 228, 255, 0.3);
  border-radius: 8px;
  color: #ffffff;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  /* Guard against horizontal scroll */
  overflow-x: hidden;
}

#vmo-wizard-response:focus {
  outline: none;
  border-color: #00e4ff;
  box-shadow: 0 0 0 2px rgba(0, 228, 255, 0.2);
  background: rgba(0, 22, 34, 0.7);
}

#vmo-wizard-response::placeholder {
  color: rgba(234, 255, 255, 0.5);
  font-size: 14px;
}

/* Fix conversation display - expand to use more space */
.vmo-wizard-conversation {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  min-height: 400px; /* Increased from 300px */
  max-height: calc(100vh - 300px); /* Reduced from 400px to give more height */
  scroll-behavior: smooth;
}

/* Fix message bubbles */
.vmo-ai-message,
.vmo-user-message {
  margin-bottom: 18px;
  animation: messageSlideIn 0.3s ease-out;
  max-width: 100%;
  word-wrap: break-word;
}

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

.vmo-message-content {
  padding: 14px 18px;
  border-radius: 10px;
  line-height: 1.6;
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.vmo-ai-message .vmo-message-content {
  background: rgba(0, 228, 255, 0.1);
  border: 1px solid rgba(0, 228, 255, 0.2);
  color: #eaffff;
}

.vmo-user-message .vmo-message-content {
  background: rgba(78, 205, 196, 0.15);
  border: 1px solid rgba(78, 205, 196, 0.3);
  color: #ffffff;
  margin-left: auto;
  max-width: 80%;
}

/* Fix wizard intro message */
.vmo-wizard-intro-large {
  font-size: 16px;
  line-height: 1.7;
  padding: 24px;
  max-width: 100%;
}

.vmo-wizard-intro-large h3 {
  font-size: 26px !important;
  margin-bottom: 18px !important;
  line-height: 1.3 !important;
  color: #00e4ff;
}

.vmo-wizard-intro-large p {
  font-size: 16px !important;
  line-height: 1.6 !important;
  margin-bottom: 16px !important;
  color: #eaffff;
}

.vmo-wizard-intro-large strong {
  color: #00e4ff;
  font-weight: 700;
}

/* Fix services list */
.vmo-wizard-services-list {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  text-align: left;
  display: block;
  width: 100%;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.vmo-wizard-services-list li {
  padding: 12px 20px;
  margin-bottom: 10px;
  background: rgba(0, 228, 255, 0.08);
  border-left: 3px solid #00e4ff;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.5;
  color: #eaffff;
  word-wrap: break-word;
}

.vmo-wizard-services-list li strong {
  color: #00e4ff;
  display: block;
  margin-bottom: 4px;
}

/* Fix progress bar - MUST BE VISIBLE */
.vmo-wizard-progress {
  display: flex !important;
  align-items: center;
  gap: 15px;
  width: 100%;
  max-width: 600px;
  visibility: visible !important;
  opacity: 1 !important;
}

.vmo-progress-bar {
  flex: 1;
  height: 10px;
  background: rgba(0, 228, 255, 0.15);
  border-radius: 10px;
  overflow: hidden;
  min-width: 200px;
  visibility: visible !important;
  display: block !important;
}

.vmo-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00e4ff, #4ecdc4);
  border-radius: 10px;
  transition: width 0.5s ease;
  min-width: 5%;
  visibility: visible !important;
}

.vmo-progress-text {
  font-size: 13px;
  color: #00e4ff;
  white-space: nowrap;
  font-weight: 600;
  visibility: visible !important;
  box-shadow: 0 0 10px rgba(0, 228, 255, 0.5);
}

.vmo-progress-text {
  font-size: 13px;
  font-weight: 600;
  color: #00e4ff;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}

/* Responsive fixes for mobile */
@media (max-width: 768px) {
  .vmo-wizard-btn {
    min-width: 90px;
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  
  .vmo-wizard-btn-start {
    min-width: 280px !important;
    padding: 16px 28px !important;
    font-size: 16px !important;
  }
  
  .vmo-wizard-suggestion {
    padding: 8px 14px;
    font-size: 0.82rem;
    flex: 1 1 auto;
    min-width: 120px;
  }
  
  .vmo-wizard-input-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
  }
  
  #vmo-wizard-response {
    padding-right: 110px;
    min-height: 70px;
  }
  
  .vmo-wizard-conversation {
    padding: 15px;
    max-height: calc(100vh - 450px);
  }
  
  .vmo-wizard-intro-large {
    padding: 18px;
  }
  
  .vmo-wizard-intro-large h3 {
    font-size: 22px !important;
  }
  
  .vmo-wizard-services-list li {
    padding: 10px 16px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .vmo-wizard-btn {
    min-width: 80px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  .vmo-wizard-btn-start {
    min-width: 240px !important;
    padding: 14px 24px !important;
    font-size: 15px !important;
  }
  
  .vmo-wizard-actions {
    gap: 8px;
  }
  
  .vmo-wizard-suggestion {
    flex: 1 1 100%;
    min-width: 100%;
  }
  
  .vmo-wizard-input-controls {
    gap: 6px;
    right: 8px;
    bottom: 8px;
  }
  
  .vmo-wizard-input-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
  }
  
  .vmo-wizard-input-btn svg {
    width: 16px !important;
    height: 16px !important;
  }
}

/* Fix z-index stacking issues */
.vmo-wizard-container {
  position: relative;
  z-index: 1000000;
  /* Prevent horizontal scrollbar propagation */
  overflow-x: hidden;
}

.vmo-wizard-input-area {
  position: relative;
  z-index: 1000001;
  background: rgba(0, 10, 20, 0.95);
  padding: 10px 20px !important; /* Reduced from 20px to 10px vertical, force with !important */
  border-top: 1px solid rgba(0, 228, 255, 0.2);
  /* Prevent horizontal scroll due to inner controls */
  overflow-x: hidden;
}

/* Prevent any text selection issues */
.vmo-wizard-btn,
.vmo-wizard-input-btn {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Smooth transitions for better UX */
.vmo-wizard-btn,
.vmo-wizard-input-btn,
.vmo-wizard-suggestion {
  will-change: transform;
}

/* Ensure tooltips/titles are visible */
.vmo-wizard-input-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #00e4ff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000002;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Loading states */
.vmo-wizard-btn:disabled,
.vmo-wizard-input-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.vmo-wizard-btn.loading,
.vmo-wizard-input-btn.loading {
  position: relative;
  color: transparent !important;
}

.vmo-wizard-btn.loading::after,
.vmo-wizard-input-btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #00e4ff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Success/Error states */
.vmo-wizard-btn-success {
  background: linear-gradient(135deg, #4CAF50, #45a049) !important;
  color: white !important;
  border: none !important;
}

.vmo-wizard-btn-success:hover {
  background: linear-gradient(135deg, #45a049, #3d8b40) !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4) !important;
}

.vmo-wizard-btn-error {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
  color: white !important;
  border: none !important;
}

.vmo-wizard-btn-error:hover {
  background: linear-gradient(135deg, #ee5a52, #dc4c46) !important;
}

/* Accessibility improvements */
.vmo-wizard-btn:focus,
.vmo-wizard-input-btn:focus,
.vmo-wizard-suggestion:focus {
  outline: 2px solid #00e4ff;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .vmo-wizard-input-controls,
  .vmo-wizard-actions {
    display: none !important;
  }
}

/* ========================================
   PHASE 2: RECOMMENDATIONS UI STYLES
   ======================================== */

/* Recommendations Container */
.vmo-recommendations-container {
  background: rgba(20, 20, 40, 0.6);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
  margin: 15px 0;
  max-width: 100%;
}

/* Recommendation Category */
.vmo-recommendation-category {
  margin-bottom: 25px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 15px;
}

.vmo-recommendation-category h4 {
  color: #00e2ff;
  font-size: 1.1rem;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  font-weight: 600;
}

/* Recommendation Items */
.vmo-recommendation-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vmo-recommendation-item {
  display: flex;
  align-items: flex-start;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  transition: background 0.2s ease;
}

.vmo-recommendation-item:hover {
  background: rgba(0, 255, 255, 0.05);
}

.vmo-recommendation-item input[type="checkbox"] {
  margin: 4px 12px 0 0;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #00e2ff;
  flex-shrink: 0;
}

.vmo-recommendation-item label {
  color: #e0e0e0;
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
  flex: 1;
  user-select: none;
}

.vmo-recommendation-item input[type="checkbox"]:checked + label {
  color: #00e2ff;
  font-weight: 500;
}

/* Recommendations Actions */
.vmo-recommendations-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 255, 255, 0.2);
  flex-wrap: wrap;
}

.vmo-btn-primary,
.vmo-btn-secondary {
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  line-height: 1;
}

.vmo-btn-primary {
  background: linear-gradient(135deg, #00e2ff 0%, #0099ff 100%);
  color: #000;
  box-shadow: 0 4px 15px rgba(0, 226, 255, 0.3);
}

.vmo-btn-primary:hover {
  background: linear-gradient(135deg, #00f7ff 0%, #00aaff 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 226, 255, 0.4);
}

.vmo-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #00e2ff;
  border: 1px solid rgba(0, 255, 255, 0.3);
}

.vmo-btn-secondary:hover {
  background: rgba(0, 255, 255, 0.15);
  border-color: rgba(0, 255, 255, 0.5);
  transform: translateY(-2px);
}

.vmo-btn-large {
  padding: 16px 36px;
  font-size: 1.1rem;
}

/* Responsive Design for Recommendations */
@media (max-width: 768px) {
  .vmo-recommendations-container {
    padding: 15px;
  }
  
  .vmo-recommendation-category {
    padding: 12px;
  }
  
  .vmo-recommendation-category h4 {
    font-size: 1rem;
  }
  
  .vmo-recommendation-item label {
    font-size: 0.9rem;
  }
  
  .vmo-recommendations-actions {
    flex-direction: column;
  }
  
  .vmo-btn-primary,
  .vmo-btn-secondary {
    width: 100%;
    padding: 14px 20px;
  }
}

/* Loading/Processing State */
.vmo-recommendations-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 15px;
}

.vmo-recommendations-loading .spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0, 255, 255, 0.2);
  border-top-color: #00e2ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   RESTORED NEWER FIXES (Excluding Z-Index Conflicts)
   ======================================== */

/* Ensure disclaimer modal is visible and clickable */
.vmo-disclaimer-box {
  position: relative;
  z-index: 1000005 !important;
  pointer-events: auto !important;
  background: rgba(0, 10, 20, 0.95) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

/* Fix system messages */
.vmo-wizard-system-message {
  z-index: 1000002 !important;
  position: relative !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Fix blurry text in inputs */
input, textarea, select {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
