/**
 * Enhanced Help System Styles
 * 
 * Styles for the comprehensive help system including:
 * - Help selector modal
 * - Problem reporting forms
 * - AI assistant interface
 * - Support request forms
 * - Modal management and responsive design
 */

/* Help Modal Overlay */
.help-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 20px;
  box-sizing: border-box;
}

/* Desktop/Tablet Side Panel Layout */
@media (min-width: 1024px) {
  .help-modal-overlay {
    background: transparent;
    backdrop-filter: none;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0;
    pointer-events: none; /* Allow clicks through overlay */
  }
  
  .help-modal {
    position: fixed;
    right: -500px; /* Start off-screen for animation */
    top: 0;
    height: 100vh;
    max-height: 100vh;
    max-width: 480px;
    width: 480px;
    border-radius: 0;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    transition: right 0.3s ease;
    pointer-events: auto; /* Re-enable interactions for the panel itself */
  }
  
  /* Animate in */
  .help-modal-overlay.active .help-modal {
    right: 0;
  }
  
  .help-modal.ai-assistant {
    max-width: 520px;
    width: 520px;
    right: -540px; /* Wider initial position for AI assistant */
  }
  
  /* Desktop side panel header adjustments */
  .help-modal-overlay .help-modal-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10002;
    border-bottom: 2px solid #e0e0e0;
  }
  
  /* Add visual indicator for side panel */
  .help-modal-overlay .help-modal-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #2196F3;
  }
  
  /* Close button positioning for desktop */
  .help-modal-overlay .help-modal-close {
    position: relative;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
  }
  
  .help-modal-overlay .help-modal-close:hover {
    background: #e0e0e0;
    border-color: #ccc;
  }
  
  /* Adjust main content to make room for side panel */
  body.help-panel-open #mainContent,
  body.help-panel-open .container {
    margin-right: 480px;
    transition: margin-right 0.3s ease;
  }
  
  /* Visual indicator that main content is interactive */
  body.help-panel-open #mainContent {
    position: relative;
  }
  
  body.help-panel-open #mainContent::before {
    content: '';
    position: absolute;
    top: 0;
    right: -2px;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #2196F3, #1976d2);
    opacity: 0.3;
  }
  
  body.help-panel-open.ai-assistant #mainContent,
  body.help-panel-open.ai-assistant .container {
    margin-right: 520px;
  }
  
  /* Better scrolling for AI responses in side panel */
  .help-modal-overlay .ai-response {
    max-height: calc(100vh - 400px);
    min-height: 150px;
  }
  
  /* Adjust input section for side panel */
  .help-modal-overlay .ai-input-section {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 16px 24px;
    margin: 0 -24px -24px -24px;
    border-top: 1px solid #e0e0e0;
  }
}

/* Main Help Modal Container */
.help-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

/* Larger modal for AI assistant */
.help-modal.ai-assistant {
  max-width: 800px;
  max-height: 85vh;
}

/* Modal Header */
.help-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 16px;
  border-bottom: 1px solid #e0e0e0;
}

.help-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.help-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.help-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

/* Modal Body */
.help-modal-body {
  padding: 24px;
}

/* Help Options (from existing feedback bubble) */
.help-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-option {
  display: flex;
  align-items: flex-start; /* Align to top to better handle different icon sizes */
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  min-height: 80px; /* Ensure consistent height for flag icon */
  flex-wrap: nowrap; /* Prevent wrapping that could cause stacking */
}

.help-option:hover {
  border-color: #2196F3;
  background: #f5f9ff;
  transform: translateY(-2px);
}

.help-option.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  border-color: #ccc;
}

.help-option.disabled:hover {
  border-color: #ccc;
  background: none;
  transform: none;
}

.help-option-icon {
  font-size: 24px;
  margin-right: 16px;
  min-width: 32px;
  text-align: center;
  flex-shrink: 0; /* Prevent icon from shrinking */
}

.help-option-content {
  flex: 1;
  min-width: 200px; /* Ensure minimum width for text content */
  padding-top: 4px; /* Align text with icon top */
}

.help-option-title {
  font-weight: 600;
  font-size: 16px;
  color: #333;
  margin-bottom: 4px;
}

.help-option-description {
  font-size: 14px;
  color: #666;
  margin: 0;
}

/* AI Assistant Styles - removed duplicate max-width */

.ai-session-info {
  background: #f0f7ff;
  border: 1px solid #2196F3;
  border-radius: 6px;
  padding: 12px;
  margin: 12px 24px;
  font-size: 13px;
}

/* Timer styles removed - timer is now hidden from users */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.ai-session-notice {
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-ended {
  text-align: center;
  padding: 20px;
  background: #fff3e0;
  border-radius: 8px;
  border: 1px solid #ff9800;
}

.session-ended p {
  margin: 0 0 12px 0;
}

.session-ended button {
  margin-top: 12px;
}

/* AI Suggestions */
.ai-suggestions {
  margin: 20px 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.ai-suggestions.collapsed .suggestion-chips {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.ai-suggestions:not(.collapsed) .suggestion-chips {
  max-height: 200px;
  opacity: 1;
}

.suggestions-label {
  font-weight: 500;
  color: #333;
  margin-bottom: 10px;
  font-size: 14px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-suggestion-chip {
  padding: 8px 12px;
  background: #f0f0f0;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #e0e0e0;
}

.ai-suggestion-chip:hover {
  background: #2196F3;
  color: white;
  border-color: #2196F3;
}

/* Suggestions toggle button */
.suggestions-toggle {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  margin-top: 8px;
}

/* AI Input Section */
.ai-input-section {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-question-input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s;
}

.ai-question-input:focus {
  outline: none;
  border-color: #2196F3;
}

.ai-question-input:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

.ai-ask-button {
  align-self: flex-start;
}

/* AI Response */
.ai-response {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-top: 16px;
  min-height: 200px;
  max-height: 600px;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 15px;
  word-wrap: break-word;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #ccc #f8f9fa; /* Firefox */
}

/* Webkit scrollbar styling */
.ai-response::-webkit-scrollbar {
  width: 8px;
}

.ai-response::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 4px;
}

.ai-response::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.ai-response::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

.ai-response:empty {
  display: none;
}

.ai-response p {
  margin: 0 0 12px 0;
}

.ai-response p:last-child {
  margin-bottom: 0;
}

.ai-response code {
  background: #f0f0f0;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.ai-response strong {
  color: #1976d2;
}

.ai-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
  font-style: italic;
}

.ai-error {
  color: #d32f2f;
  background: #ffebee;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #f8bbd9;
}

/* Streaming cursor appears after the content */
.ai-response.streaming .response-content::after {
  content: '▊';
  animation: blink 1s infinite;
  color: #2196F3;
  margin-left: 2px;
}

/* Fallback for when response-content doesn't exist yet */
.ai-response.streaming::after {
  content: '▊';
  animation: blink 1s infinite;
  color: #2196F3;
  margin-left: 2px;
}

/* Smooth content updates */
.ai-response {
  transition: none; /* Disable transitions during streaming to prevent flickering */
}

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

/* Form Styles */
.problem-form,
.support-form {
  max-width: 600px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: #333;
  font-size: 14px;
}

.form-select,
.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: #2196F3;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  background-color: white;
  cursor: pointer;
}

/* Severity Options */
.severity-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.severity-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.severity-option input[type="radio"] {
  margin: 0;
}

.severity-option label {
  margin: 0;
  cursor: pointer;
  font-size: 14px;
}

/* Context Preview */
.context-preview {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
}

.context-preview-title {
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
  font-size: 14px;
}

.context-item {
  display: flex;
  margin: 6px 0;
  font-size: 13px;
}

.context-label {
  font-weight: 500;
  margin-right: 8px;
  min-width: 80px;
  color: #555;
}

.context-value {
  color: #666;
  word-break: break-all;
  flex: 1;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: #2196F3;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #1976d2;
}

.btn-secondary {
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
}

.btn-secondary:hover:not(:disabled) {
  background: #e0e0e0;
  color: #333;
}

/* Success/Error Message Modals */
.success-message,
.error-message,
.analyze-first {
  max-width: 400px;
  text-align: center;
}

.success-icon,
.error-icon,
.analyze-first-icon {
  font-size: 48px;
  margin: 20px 0;
}

.success-message p,
.error-message p,
.analyze-first-message p {
  margin: 16px 0;
  line-height: 1.5;
}

.analyze-first-instructions {
  font-size: 13px;
  color: #666;
  margin-top: 8px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .help-modal-overlay {
    padding: 10px;
  }
  
  .help-modal {
    max-height: 95vh;
  }
  
  .help-modal-header,
  .help-modal-body {
    padding: 16px;
  }
  
  .help-option {
    padding: 12px;
  }
  
  .help-option-icon {
    font-size: 20px;
    margin-right: 12px;
    min-width: 28px;
  }
  
  .help-option-title {
    font-size: 15px;
  }
  
  .help-option-description {
    font-size: 13px;
  }
  
  .ai-assistant {
    max-width: none;
  }
  
  .suggestion-chips {
    flex-direction: column;
  }
  
  .ai-suggestion-chip {
    text-align: center;
    border-radius: 8px;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
  
  .severity-options {
    gap: 8px;
  }
  
  .context-item {
    flex-direction: column;
    gap: 2px;
  }
  
  .context-label {
    min-width: auto;
    font-weight: 600;
  }
}

/* Small Mobile Screens */
@media (max-width: 480px) {
  .help-modal-overlay {
    padding: 5px;
  }
  
  .help-modal-header {
    padding: 12px;
  }
  
  .help-modal-body {
    padding: 12px;
  }
  
  .ai-session-info {
    margin: 12px 0;
    padding: 8px;
  }
  
  .ai-response {
    max-height: 400px;
    min-height: 120px;
    padding: 16px;
    font-size: 14px;
  }
  
  .ai-response::-webkit-scrollbar {
    width: 6px; /* Thinner scrollbar for mobile */
  }
}

/* High contrast and accessibility improvements */
@media (prefers-contrast: high) {
  .help-option {
    border-width: 3px;
  }
  
  .help-option:hover {
    border-color: #0d47a1;
    background: #e3f2fd;
  }
  
  .ai-suggestion-chip:hover {
    background: #0d47a1;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .help-option,
  .ai-suggestion-chip,
  .btn,
  .form-select,
  .form-input,
  .form-textarea {
    transition: none;
  }
  
  .pulse,
  .blink {
    animation: none;
  }
  
  .help-option:hover {
    transform: none;
  }
}

/* ========================================
 * CAPTCHA (Turnstile) Styles
 * ======================================== */

.captcha-container {
  margin: 1rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 65px; /* Standard Turnstile widget height */
}

/* Development notice */
.dev-captcha-notice {
  background: #f0f8ff;
  border: 1px solid #b3d9ff;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  font-size: 0.9rem;
  color: #0066cc;
  font-style: italic;
}

/* CAPTCHA error states */
.captcha-error {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}

.captcha-error p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: #e53e3e;
}

.captcha-error-detail {
  font-size: 0.8rem !important;
  color: #a0a0a0 !important;
  font-style: italic;
}

/* Turnstile widget styling adjustments */
.captcha-container .cf-turnstile {
  margin: 0 auto;
}

/* Loading state for CAPTCHA container */
.captcha-container.loading {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  position: relative;
}

.captcha-container.loading::after {
  content: "Loading security verification...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9rem;
  color: #6c757d;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Mobile responsiveness for CAPTCHA */
@media (max-width: 480px) {
  .captcha-container {
    min-height: 65px;
    margin: 0.75rem 0;
  }
  
  .dev-captcha-notice,
  .captcha-error {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  
  .captcha-error-detail {
    font-size: 0.75rem !important;
  }
}

/* ========================================
 * German Flag Icon Styles
 * ======================================== */

/* German flag as thumbnail in help options */
.help-option-icon.german-flag {
  display: flex;
  flex-direction: column;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #ddd;
  margin-right: 16px; /* Ensure proper spacing like other icons */
  margin-top: 4px; /* Align better with text baseline */
  flex-shrink: 0; /* Prevent shrinking in flex layout */
  align-self: flex-start; /* Ensure icon stays at top */
}

.flag-stripe {
  flex: 1;
  width: 100%;
}

.flag-stripe.black {
  background-color: #000000;
}

.flag-stripe.red {
  background-color: #DD0000;
}

.flag-stripe.gold {
  background-color: #FFCE00;
}

/* Hover effect for German flag */
.help-option:hover .help-option-icon.german-flag {
  transform: scale(1.05);
  transition: all 0.2s ease;
  border-color: #999;
}

/* Ensure other help option icons maintain their emoji styling */
.help-option-icon:not(.german-flag) {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure proper layout for Ask AI option with German flag */
.help-option[data-help-type="ask-ai"] {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  flex-wrap: nowrap !important;
}

.help-option[data-help-type="ask-ai"] .help-option-content {
  flex: 1 1 auto !important;
  margin-left: 0 !important;
  min-width: 200px !important;
}

/* Mobile adjustments for German flag */
@media (max-width: 480px) {
  .help-option-icon.german-flag {
    width: 40px;
    height: 40px;
  }
  
  .help-option[data-help-type="ask-ai"] .help-option-content {
    min-width: 150px !important;
  }
}