/* Qualitative Analyzer Specific Styles */

/* Theme distribution badges */
.badge--qualitative {
  background-color: #8b5cf6;
  color: white;
}

/* How it works grid */
.how-it-works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.step-card {
  text-align: center;
  padding: 1.5rem;
  background: var(--gray-50, #f9fafb);
  border-radius: 8px;
}

.step-number {
  background: var(--primary, #3b82f6);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

.step-card h4 {
  margin: 0.5rem 0;
  font-size: 1.1rem;
}

.step-card p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--gray-700, #374151);
}

/* Transcript Viewer */
.transcript-viewer {
  margin: 2rem 0;
}

.viewer-controls {
  margin-bottom: 1rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-bar input[type="text"] {
  flex: 1;
  min-width: 250px;
  padding: 0.75rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 6px;
  font-size: 1rem;
}

.search-icon {
  margin-right: 0.25rem;
}

.filter-controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-controls label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-controls select {
  padding: 0.5rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 4px;
}

.match-counter {
  margin-left: auto;
  font-weight: 600;
  color: var(--primary, #3b82f6);
}

/* Transcript Display */
.transcript-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transcript-nav {
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.transcript-nav h3 {
  grid-column: 1 / -1;
}

.transcript-nav .nav-details {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.transcript-nav h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
}

.section-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.section-nav-item {
  padding: 0.5rem 0.75rem;
  background: var(--gray-50, #f9fafb);
  border-left: 3px solid var(--primary, #3b82f6);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.section-nav-item:hover {
  background: var(--gray-100, #f3f4f6);
  transform: translateX(2px);
}

.section-nav-item.activity {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.section-nav-item.activity:hover {
  background: #fef3c7;
}

.nav-details {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200, #e5e7eb);
}

.nav-details summary {
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.nav-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.stat-label {
  color: var(--gray-600, #4b5563);
}

.stat-value {
  font-weight: 600;
  color: var(--primary, #3b82f6);
}

.transcript-display {
  max-height: 600px;
  overflow-y: auto;
  background: white;
}

.transcript-lines {
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

.transcript-line {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--gray-100, #f3f4f6);
  cursor: pointer;
  transition: background-color 0.2s;
}

.transcript-line:hover {
  background-color: var(--gray-50, #f9fafb);
}

.transcript-line.selected {
  background-color: #dbeafe;
  border: 2px solid #3b82f6;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
  margin: 2px 0;
}

.transcript-line.coded {
  border-left: 3px solid;
}

.transcript-line.highlighted {
  background-color: #fef3c7;
}

.transcript-line.section-header {
  background: linear-gradient(90deg, #dbeafe 0%, transparent 100%);
  font-weight: bold;
  font-size: 1.05rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--primary, #3b82f6);
  color: var(--primary-dark, #1e40af);
}

.transcript-line.activity-marker {
  background: linear-gradient(90deg, #fef3c7 0%, transparent 100%);
  font-weight: bold;
  padding: 0.75rem 1rem;
  border-left: 4px solid #f59e0b;
  color: #b45309;
}

.transcript-line.stage-direction {
  font-style: italic;
  color: var(--gray-600, #4b5563);
  background: var(--gray-50, #f9fafb);
}

.line-number {
  display: inline-block;
  width: 50px;
  color: var(--gray-500, #6b7280);
  -webkit-user-select: none;
  user-select: none;
}

.speaker-label {
  display: inline-block;
  font-weight: bold;
  color: var(--primary-dark, #2563eb);
  min-width: 120px;
  margin-right: 0.5rem;
}

.timestamp {
  display: inline-block;
  color: var(--gray-500, #6b7280);
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.line-text {
  display: inline;
}

.inline-direction {
  font-style: italic;
  color: var(--gray-500, #6b7280);
  font-size: 0.9em;
}

.code-label {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  font-weight: 500;
}

.line-codes {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}


/* Coding Panel */
.coding-panel {
  margin: 2rem 0;
}

.code-manager {
  padding: 1rem;
}

.code-input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.code-input-group input[type="text"] {
  flex: 1;
  min-width: 150px;
  padding: 0.75rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 6px;
}

.code-input-group input[type="color"] {
  width: 60px;
  height: 42px;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 6px;
  cursor: pointer;
}

.code-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.code-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--gray-50, #f9fafb);
  border-radius: 6px;
  border-left: 4px solid;
}

.code-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--gray-300, #d1d5db);
}

.code-name {
  flex: 1;
  font-weight: 600;
}

.code-count {
  color: var(--gray-600, #4b5563);
  font-size: 0.9rem;
}

.code-actions {
  display: flex;
  gap: 0.5rem;
}

.code-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--gray-200, #e5e7eb);
  color: var(--gray-700, #374151);
}

.code-actions button:hover {
  background: var(--gray-300, #d1d5db);
}

.code-actions .delete {
  background: #fee;
  color: #c00;
}

.code-actions .delete:hover {
  background: #fcc;
}

/* Coded Segments */
.coded-segments-list {
  max-height: 400px;
  overflow-y: auto;
}

.coded-segment {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--gray-50, #f9fafb);
  border-radius: 6px;
  border-left: 4px solid;
}

.segment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.segment-code {
  font-weight: 600;
  font-size: 0.9rem;
}

.segment-location {
  font-size: 0.85rem;
  color: var(--gray-600, #4b5563);
}

.segment-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--gray-800, #1f2937);
  font-style: italic;
}

.segment-speaker {
  font-weight: bold;
  color: var(--primary, #3b82f6);
  margin-right: 0.5rem;
}

.segment-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.segment-actions button {
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--gray-200, #e5e7eb);
  color: var(--gray-700, #374151);
}

/* Export Section */
.export-section {
  margin: 2rem 0;
}

.export-options {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.export-settings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0;
}

/* Manual Entry */
.manual-entry-block {
  padding: 1rem;
}

.manual-entry-block textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 1rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray-500, #6b7280);
}

/* Chart placeholders */
.chart-placeholder {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50, #f9fafb);
  border-radius: 8px;
  padding: 2rem;
}

.chart-note {
  text-align: center;
  color: var(--gray-600, #4b5563);
  font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .how-it-works-grid {
    grid-template-columns: 1fr;
  }
  
  .transcript-nav {
    grid-template-columns: 1fr;
  }
  
  .transcript-nav {
    position: static;
    max-height: 300px;
  }
  
  .search-bar {
    flex-direction: column;
  }
  
  .search-bar input[type="text"] {
    width: 100%;
  }
  
  .filter-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .match-counter {
    margin-left: 0;
  }
  
  .export-options {
    flex-direction: column;
  }
  
  .export-options button {
    width: 100%;
  }
}

/* Context menu (for right-click coding) */
.context-menu {
  position: fixed;
  background: white;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 0.5rem 0;
  z-index: 1000;
  min-width: 180px;
}

.context-menu-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.context-menu-item:hover {
  background: var(--gray-100, #f3f4f6);
}

.context-menu-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--gray-300, #d1d5db);
}

/* Selection highlight */
::selection {
  background: #bfdbfe;
  color: #1e3a8a;
}

/* Code assignment popup */
.code-popup {
  position: fixed;
  background: white;
  border: 2px solid var(--primary, #3b82f6);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  padding: 0;
  z-index: 2000;
  min-width: 280px;
  max-width: 400px;
}

.code-popup.hidden {
  display: none;
}

.code-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
  background: var(--gray-50, #f9fafb);
}

.code-popup-header h4 {
  margin: 0;
  font-size: 1rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: var(--gray-600, #4b5563);
}

.close-btn:hover {
  color: var(--gray-900, #111827);
}

.code-popup-body {
  padding: 1rem;
  max-height: 400px;
  overflow-y: auto;
}

.popup-hint {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  color: var(--gray-600, #4b5563);
}

.code-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.code-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.code-checkbox-item:hover {
  background: var(--gray-100, #f3f4f6);
}

.code-checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.code-checkbox-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--gray-300, #d1d5db);
}

.code-checkbox-label {
  flex: 1;
  font-size: 0.95rem;
}

.code-popup-footer {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--gray-200, #e5e7eb);
  justify-content: flex-end;
}

/* Word frequency section */
.word-frequency {
  margin: 2rem 0;
}

.frequency-controls {
  display: flex;
  gap: 1rem;
  margin: 1rem 0;
}

.frequency-results {
  margin-top: 1.5rem;
}

.frequency-results.hidden {
  display: none;
}

.frequency-results h3 {
  margin-bottom: 1rem;
}

.frequency-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 6px;
}

.frequency-actions .selection-count {
  margin-left: auto;
  font-weight: 600;
  color: #3b82f6;
}

.table-wrapper {
  overflow-x: auto;
}

.frequency-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.frequency-table thead {
  background: var(--gray-100, #f3f4f6);
}

.frequency-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 2px solid var(--gray-300, #d1d5db);
}

.frequency-table th:first-child {
  width: 40px;
  text-align: center;
}

.frequency-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.frequency-table td:first-child {
  text-align: center;
}

.frequency-table tr:hover {
  background: var(--gray-50, #f9fafb);
}

.word-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.stopwords-details {
  margin-top: 1.5rem;
}

.stopwords-content {
  margin-top: 1rem;
}

.stopwords-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  resize: vertical;
}

.stopwords-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Coded text highlighting in transcript */
.coded-text {
  background: rgba(59, 130, 246, 0.15);
  border-bottom: 2px solid currentColor;
  padding: 0 2px;
  cursor: pointer;
  position: relative;
}

.coded-text:hover {
  background: rgba(59, 130, 246, 0.25);
}

.coded-text.multi-code {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.15) 25%,
    rgba(16, 185, 129, 0.15) 25%,
    rgba(16, 185, 129, 0.15) 50%,
    rgba(59, 130, 246, 0.15) 50%,
    rgba(59, 130, 246, 0.15) 75%,
    rgba(16, 185, 129, 0.15) 75%
  );
  background-size: 10px 10px;
}

.code-tags {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 100;
  margin-bottom: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.coded-text:hover .code-tags {
  opacity: 1;
}

.code-tag {
  display: inline-block;
  margin-right: 0.25rem;
  padding: 2px 6px;
  border-radius: 3px;
}

/* Search result highlighting */
.search-highlight {
  background: #fef08a;
  border-bottom: 2px solid #facc15;
  padding: 0 2px;
  font-weight: 600;
}

.search-highlight.current {
  background: #fbbf24;
  border-bottom-color: #f59e0b;
}

/* Coding mode controls */
.coding-mode-bar {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.coding-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.coding-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.coding-controls {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.active-code-select {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  min-width: 200px;
  font-size: 0.95rem;
}

.selection-count {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 600;
}

/* Transcript line checkboxes in coding mode */
.transcript-line.coding-mode {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.transcript-line.coding-mode .line-checkbox {
  margin-top: 0.25rem;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.transcript-line.coding-mode .line-content {
  flex: 1;
}

.transcript-line.coding-mode:hover {
  background: #f9fafb;
  cursor: pointer;
}

/* Collapsible Navigation & Stats */
.transcript-nav-details {
  margin-bottom: 1rem;
}

.transcript-nav-details summary.nav-summary {
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-radius: 6px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.transcript-nav-details summary.nav-summary::before {
  content: '▶';
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.transcript-nav-details[open] summary.nav-summary::before {
  transform: rotate(90deg);
}

.transcript-nav-content {
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Code Management Bar */
.code-management-bar {
  margin-bottom: 1rem;
}

.code-management-details summary {
  cursor: pointer;
  padding: 0.5rem 0;
}

.code-management-details summary h3 {
  display: inline;
  margin: 0;
}

.code-management-details .code-manager {
  padding-top: 1rem;
}

/* Speaker Role Manager */
.speaker-role-manager {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.speaker-role-manager summary {
  cursor: pointer;
  color: #6b7280;
}

.speaker-role-content {
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 6px;
  margin-top: 0.5rem;
}

.speaker-roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.speaker-role-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.speaker-role-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.speaker-role-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Horizontal Bar Chart */
.speaker-bar-chart {
  padding: 1rem;
}

.speaker-bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.speaker-bar-label {
  width: 120px;
  flex-shrink: 0;
  font-weight: 500;
  font-size: 0.9rem;
  text-align: right;
  padding-right: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speaker-bar-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.speaker-bar {
  height: 24px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 4px;
  min-width: 4px;
}

.speaker-bar-value {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

/* Chart description */
.chart-description {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

/* Responsive adjustments for navigation */
@media (max-width: 768px) {
  .transcript-nav-content {
    grid-template-columns: 1fr;
  }
  
  .speaker-bar-label {
    width: 80px;
  }
}

