body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f8f9fa;
  color: #1A1A1A;
  line-height: 1.4;
}

/* Top bar styles */
.top-bar {
  background-color: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px 16px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.top-bar a {
  color: #0033CC;
  text-decoration: none;
  font-weight: 500;
}

.top-bar a:hover {
  text-decoration: underline;
}

.top-bar-branding {
  font-weight: bold;
  overflow-wrap: break-word;
  max-width: 60%;
}

.top-bar-workshop {
  display: flex;
  align-items: center;
}

.early-bird {
  font-weight: bold;
  margin-left: 6px;
}

.app-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  max-width: 1400px;
  margin: 1rem auto;
  padding: 1rem;
}

.sidebar {
  background: #FFFFFF;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 1rem;
  height: fit-content;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow-y: auto;
  position: sticky;
  top: 20px;
}

.main-content {
  background: #FFFFFF;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 1rem;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
  padding-bottom: 150px; /* Increased padding to allow more scrollable space beyond the content */
}

h1, h2, h3 {
  color: #0033CC;
  margin-top: 0;
}

.step-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.step-item {
  margin-bottom: 0.5rem;
  padding: 0.75rem;
  border-left: 4px solid #dee2e6;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: all 0.2s;
}

.step-item:hover:not(.disabled) {
  background: #f8f9fa;
}

.step-item.active {
  border-left-color: #0033CC;
  background: #f8f9fa;
  font-weight: 500;
}

.step-item.completed {
  border-left-color: #FFD700;
}

.step-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.step-number {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: #dee2e6;
  color: #1A1A1A;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  margin-right: 8px;
}

.step-item.active .step-number {
  background: #0033CC;
  color: #FFFFFF;
}

.step-item.completed .step-number {
  background: #FFD700;
  color: #1A1A1A;
}

.docs-section {
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
}

.status-bar {
  margin-top: 1rem;
  padding: 0.5rem;
  border-radius: 4px;
  text-align: center;
  display: none;
}

.status-bar.success {
  background: #d4edda;
  color: #155724;
}

.status-bar.error {
  background: #f8d7da;
  color: #721c24;
}

.status-bar.loading {
  background: #e9ecef;
  color: #495057;
}

.status-bar.loading:after {
  content: "...";
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0% { content: "."; }
  33% { content: ".."; }
  66% { content: "..."; }
}

.btn, button, .button-group, input[type="button"], input[type="submit"] {
  position: relative;
  z-index: 200; /* Higher than floating bar to ensure buttons are always clickable */
}

/* Ensure table containers and interactive UI elements appear above the floating bar */
.table-container, .handsontable, .grid-container {
  position: relative;
  z-index: 150;
}

.btn {
  background: #FFD700;
  color: #1A1A1A;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.btn-primary {
  background: #0033CC;
  color: #FFFFFF;
}

.next-step-btn {
  display: none !important; /* Hide all inline next buttons */
}

.step-content {
  display: none;
  margin-top: 1rem;
  position: relative;
  min-height: 400px;
}

.step-content.active {
  display: block;
}

/* Ensure proper stacking context */
.main-content {
  position: relative;
  z-index: 0;
  padding-bottom: 150px;
}

/* Floating action bar styles */
.floating-action-bar {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  padding: 1rem;
  z-index: 100;
  width: 95%;
  max-width: 1400px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 2;
}

.step-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dee2e6;
  color: #1A1A1A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.step-indicator.active {
  background: #0033CC;
  color: white;
  transform: scale(1.1);
}

.step-indicator.completed {
  background: #FFD700;
  color: #1A1A1A;
}

.connector-line {
  height: 2px;
  background: #dee2e6;
  flex-grow: 1;
  transition: background 0.3s ease;
}

.connector-line.completed {
  background: #FFD700;
}

.actions-container {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
}

.floating-status {
  flex: 2;
  padding: 0.5rem;
  border-radius: 4px;
  text-align: center;
  display: none;
  font-size: 0.875rem;
}

#floating-next-btn {
  min-width: 120px;
}

.file-upload {
  border: 2px dashed #dee2e6;
  border-radius: 4px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-upload:hover, .file-upload.dragover {
  border-color: #0033CC;
  background: #f8f9fa;
}

.file-upload input {
  display: none;
}

.table-container {
  height: 400px;
  overflow: auto;
  margin-top: 1rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.analysis-section {
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 1rem;
}

.analysis-item {
  margin-bottom: 2rem;
}

.analysis-meta {
  color: #6c757d;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.suggestion {
  background: #f8f9fa;
  border-left: 4px solid #0033CC;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0 4px 4px 0;
}

.suggestion-meta {
  display: flex;
  justify-content: space-between;
  color: #6c757d;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

#ai-thinking {
  font-style: italic;
  color: #6c757d;
  display: none;
}

.analysis-text {
  width: 100%;
  min-height: 150px;
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-family: inherit;
  resize: vertical;
}

.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid #dee2e6;
  margin-bottom: 0.5rem;
}

.tab-button {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  margin-right: 0.25rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-button.active {
  border-bottom-color: #0033CC;
  font-weight: 500;
}

.tab-contents {
  margin-bottom: 1rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.grid-container {
  height: 300px;
  width: 100%;
}

.progress {
  background-color: #dee2e6;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
}

.crawl-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1rem;
  text-align: center;
}

.stat-item {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  background: #f8f9fa;
  min-width: 100px;
}

.stat-item.success {
  background: #d4edda;
  color: #155724;
}

.stat-item.error {
  background: #f8d7da;
  color: #721c24;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
}

.stat-label {
  font-size: 0.875rem;
}

.crawl-config {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.config-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-item label {
  font-weight: 500;
}

.config-item input {
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  width: 100%;
}

.button-group {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

/* Add new styles for vertical stacking */
.analysis-vertical {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

/* Analysis Structured Display Styles */
.structured-analysis {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 14px;
  line-height: 1.5;
}

.analysis-group {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.analysis-heading {
  color: #0033CC;
  margin-bottom: 1rem;
  font-size: 18px;
  font-weight: 600;
}

.analysis-subheading {
  color: #333;
  margin: 1rem 0 0.5rem;
  font-size: 16px;
  font-weight: 500;
}

.highlighted-heading {
  background-color: #f8f9fa;
  padding: 0.5rem;
  border-left: 3px solid #0033CC;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
}

.tag-item {
  background-color: #e9ecef;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 13px;
}

.pattern-card {
  background-color: #f8f9fa;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
  border-left: 3px solid #0033CC;
}

.pattern-name {
  font-weight: 500;
  margin: 0;
  display: inline-block;
}

.pattern-frequency {
  background-color: #e9ecef;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 8px;
}

.pattern-comment {
  margin: 8px 0;
  color: #555;
}

.examples-heading {
  font-size: 14px;
  margin: 8px 0;
  color: #555;
}

.examples-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: #555;
}

.analysis-list {
  margin: 0;
  padding-left: 20px;
}

.type-card {
  background-color: #f8f9fa;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 4px;
}

.type-name {
  margin: 0 0 8px 0;
  font-weight: 500;
}

.type-characteristics {
  margin: 0 0 10px 0;
  color: #555;
}

.insights-list {
  padding-left: 20px;
}

.insights-list.actionable li {
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 2px solid #0033CC;
}

.why-list {
  padding-left: 20px;
  color: #555;
}

.edit-json-container {
  text-align: right;
  margin-top: 1rem;
}

.edit-json-btn {
  font-size: 12px;
  padding: 2px 8px;
  background-color: #f8f9fa;
  color: #333;
  border: 1px solid #dee2e6;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  width: 80%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.json-editor {
  width: 100%;
  height: 400px;
  font-family: monospace;
  padding: 8px;
  border: 1px solid #dee2e6;
}

.json-error {
  color: #721c24;
  padding: 8px 0;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

/* Batch Progress Container */
.batch-progress-container {
  margin: 1rem 0;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

/* Suggestion Modal */
.modal-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  max-height: 70vh;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
}

.modal-close-btn:hover {
  color: #212529;
}

/* Comparison View Styles */
.comparison-container {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.comparison-column {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 0.5rem;
}

.comparison-column h4 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: #6c757d;
}

.comparison-content {
  padding: 0.5rem;
  background-color: #f8f9fa;
  border-radius: 4px;
  min-height: 3rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.comparison-content.suggested {
  background-color: #e8f4f8;
  border-left: 3px solid #0033CC;
}

/* Table styles for suggestion rows */
tr.has-suggestion {
  background-color: #e8f4f8;
}

.view-suggestion-btn {
  background-color: #0033CC;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
}

.view-suggestion-btn:hover {
  background-color: #002299;
}

/* Inline suggestion styles */
.suggested-col {
  background-color: #e8f4f8 !important;
  font-style: italic;
}

.current-col {
  background-color: #f8f9fa !important;
}

.reasoning-col {
  background-color: #f8f9fa !important;
  font-size: 0.9em;
  color: #555;
}

.has-suggestion-row td {
  border-top: 1px solid #c0d0e0 !important;
  border-bottom: 1px solid #c0d0e0 !important;
}

.editable-cell {
  font-style: italic;
  border-left: 2px solid #0033CC !important;
}

/* Styles for crawl result rows */
.crawl-table tbody tr.success-row td {
  background-color: #e6ffed; /* Light green */
}
.crawl-table tbody tr.error-row td {
  background-color: #ffeef0; /* Light red */
  color: #a81127;
}
.crawl-table tbody tr.warning-row td {
  background-color: #fff3cd; /* Light yellow */
}

table.crawl-table {
  width: 100%;
  border-collapse: collapse;
}

table.crawl-table th, table.crawl-table td {
  padding: 8px;
  border-bottom: 1px solid #dee2e6;
  text-align: left;
}

table.crawl-table th {
  background-color: #f8f9fa;
  font-weight: 500;
}

@media (max-width: 992px) {
  .top-bar-branding {
    max-width: 50%;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
    padding: 0.5rem;
    margin: 0;
    width: 100%;
  }
  
  .sidebar {
    position: relative;
    top: 0;
    width: 100%;
    max-height: none;
    margin-bottom: 1rem;
  }
  
  .main-content {
    padding: 0.75rem;
    min-height: auto;
    padding-bottom: 120px;
  }
  
  .top-bar {
    flex-direction: column;
    padding: 8px;
    gap: 4px;
    text-align: center;
  }
  
  .top-bar-branding {
    max-width: 100%;
    margin-bottom: 4px;
  }
  
  .table-container {
    height: 300px;
    overflow-x: auto;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.3rem;
  }
  
  h3 {
    font-size: 1.1rem;
  }
  
  .btn {
    padding: 0.75rem 1rem;
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .analysis-grid {
    grid-template-columns: 1fr;
  }
  
  .config-grid {
    grid-template-columns: 1fr;
  }
  
  .floating-action-bar {
    width: 90%;
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.5rem;
  }
  
  .nav-container {
    width: 100%;
    justify-content: space-between;
  }
  
  .actions-container {
    width: 100%;
  }
  
  .file-upload {
    padding: 1rem;
  }
  
  .step-item {
    padding: 0.5rem;
  }
  
  .docs-section {
    padding: 0.75rem;
  }
  
  .crawl-config {
    padding: 0.75rem;
  }
  
  .sheet-tabs {
    overflow-x: auto;
    white-space: nowrap;
    display: block;
    padding-bottom: 0.5rem;
  }
  
  /* Make handsontable responsive */
  .handsontable {
    width: 100% !important;
    overflow-x: auto !important;
  }
  
  /* Fix for comparison container */
  .comparison-container {
    flex-direction: column;
  }
  
  /* Touch-friendly improvements */
  input, select, button, .btn {
    min-height: 44px; /* Apple's recommended touch target size */
  }
  
  /* Modal improvements */
  .modal-content {
    max-height: 85vh;
    width: 95%;
  }
  
  .modal-body {
    max-height: 60vh;
  }
  
  /* Table improvements */
  .handsontable .htCore td {
    padding: 8px 4px;
  }
  
  /* For small phone screens */
  @media (max-width: 480px) {
    .app-container {
      padding: 0.25rem;
    }
    
    .main-content {
      padding: 0.5rem;
    }
    
    h1 {
      font-size: 1.3rem;
    }
    
    .top-bar {
      padding: 6px;
      font-size: 12px;
    }
    
    .step-number {
      width: 20px;
      height: 20px;
      line-height: 20px;
    }
    
    .modal-content {
      width: 95%;
    }
  }
}

/* Range slider container for the number + slider combination */
.range-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-slider {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: #dee2e6;
  border-radius: 5px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #0033CC;
  cursor: pointer;
  transition: background 0.15s ease;
}

.range-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #0033CC;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
}

.range-slider::-webkit-slider-thumb:hover {
  background: #002299;
}

.range-slider::-moz-range-thumb:hover {
  background: #002299;
}

.range-container input[type="number"] {
  width: 60px;
  text-align: center;
}
