/* Playground-Specific Styles for MHDBDB
 * Base styles loaded from ../css/shared.css
 * This file contains only playground-specific components
 */

/* Drag & drop visual feedback */
#uploadZone.dragover {
  border-color: var(--accent-primary) !important;
  background-color: color-mix(in srgb, var(--accent-primary) 12%, transparent) !important;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

/* File list presentation (checkbox version) */
.file-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  background: white;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.file-item input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.125rem;
  cursor: pointer;
  accent-color: #3b75d8;
  flex-shrink: 0;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.file-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 0.75rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Old file item styles (kept for compatibility) */
.file-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--text-base);
  word-break: break-word;
}

/* Highlighting for lemma matches - Improved contrast */
.highlight {
  background-color: #fbbf24;
  color: #78350f;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
  border: 1px solid #f59e0b;
}

/* Multi-lemma highlighting with improved contrast */
.multi-lemma-879 {
  background-color: #fecaca;
  border: 1px solid #ef4444;
  color: #991b1b;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
}

.multi-lemma-7532 {
  background-color: #bbf7d0;
  border: 1px solid #22c55e;
  color: #14532d;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
}

.multi-lemma-1816 {
  background-color: #bfdbfe;
  border: 1px solid #3b82f6;
  color: #1e3a8a;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
}

.multi-lemma-26713 {
  background-color: #f9a8d4;
  border: 1px solid #ec4899;
  color: #831843;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
}

.multi-lemma-712 {
  background-color: #fed7aa;
  border: 1px solid #f97316;
  color: #9a3412;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
}

[class*="multi-lemma-"]:not(.multi-lemma-879):not(.multi-lemma-7532):not(.multi-lemma-1816):not(.multi-lemma-26713):not(.multi-lemma-712) {
  background-color: #c4b5fd;
  border: 1px solid #8b5cf6;
  color: #581c87;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-weight: 600;
}

/* Results summaries */
.result-summary {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-primary);
  background: var(--bg-primary);
  padding: var(--space-4) var(--space-5);
  transition: var(--transition-base);
  cursor: pointer;
}

.result-summary:hover {
  border-color: var(--border-secondary);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
}

.result-summary .summary-preview {
  color: var(--text-secondary);
}

.result-summary .summary-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 15%, transparent);
  border-radius: 9999px;
  padding: var(--space-1) var(--space-2);
  min-height: 24px;
}

.result-summary .result-details {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border-secondary);
  display: none;
}

.result-summary.expanded .result-details {
  display: block;
}

.result-summary .expand-icon {
  transition: var(--transition-base);
  color: var(--text-secondary);
}

.result-summary.expanded .expand-icon {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.detail-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--accent-secondary);
  margin-bottom: var(--space-3);
  transition: var(--transition-fast);
}

.detail-item:hover {
  background: var(--bg-primary);
  border-left-color: var(--accent-primary);
}

.detail-meta {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-primary);
  margin-bottom: var(--space-2);
}

.detail-snippet {
  color: var(--text-primary);
  line-height: 1.5;
}

.file-group {
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  padding: var(--space-3) var(--space-4);
  transition: var(--transition-base);
}

.file-group:hover {
  background: var(--bg-primary);
  border-color: var(--border-secondary);
}

.file-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.file-group-header:hover {
  color: var(--accent-primary);
}

.file-group-count {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--accent-secondary);
  border-radius: 9999px;
  padding: var(--space-1) var(--space-3);
  min-height: 24px;
  display: flex;
  align-items: center;
}

.group-results {
  margin-top: var(--space-3);
  display: grid;
  gap: var(--space-2);
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  backdrop-filter: blur(6px);
  z-index: 20;
  border-radius: inherit;
}

/* Upload progress */
.upload-progress {
  display: grid;
  gap: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  padding: var(--space-4) var(--space-5);
}

.upload-progress-text {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.progress-bar {
  position: relative;
  height: 8px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--border-secondary) 60%, transparent);
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  width: 0%;
  border-radius: 9999px;
  transition: var(--transition-base);
}

/* Ensure proper contrast for interactive elements */
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

/* Custom scrollbar styling */
.overflow-auto::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.overflow-auto::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.overflow-auto::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 4px;
  transition: var(--transition-fast);
}

.overflow-auto::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}

/* Firefox scrollbar */
.overflow-auto {
  scrollbar-width: thin;
  scrollbar-color: var(--border-secondary) var(--bg-tertiary);
}

/* Responsive improvements */
@media (max-width: 1024px) {
  /* Stack layout on smaller screens */
  .lg\:grid-cols-\[1fr_1fr_2fr\] {
    grid-template-columns: 1fr;
  }

  /* Adjust spacing */
  :root {
    --space-4: 0.875rem;
    --space-6: 1.25rem;
    --space-8: 1.75rem;
  }

  .upload-progress,
  .result-summary,
  .file-group {
    padding: var(--space-3) var(--space-4);
  }

  /* Header adjustments */
  header .flex-col.lg\\:flex-row {
    gap: var(--space-3);
  }

  header h1 {
    font-size: var(--text-2xl);
  }

  /* Main grid adjustments */
  main.grid.lg\\:grid-cols-\\[1fr_1fr_2fr\\] {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Button grid adjustments */
  .grid.grid-cols-2.gap-2 {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
}

@media (max-width: 768px) {
  /* Header mobile optimization */
  header .px-6 {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  header .py-10 {
    padding-top: var(--space-5);
    padding-bottom: var(--space-5);
  }

  header h1 {
    font-size: var(--text-xl);
  }

  header p {
    font-size: var(--text-sm);
  }

  /* Main content padding */
  main.px-6 {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  /* Section padding */
  section.p-6 {
    padding: var(--space-4);
  }

  /* Button text sizing */
  button {
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
  }

  /* Search input sizing */
  input[type="text"],
  input[type="search"] {
    font-size: 16px; /* Prevent iOS zoom */
  }
}

@media (max-width: 640px) {
  /* Further reduce spacing on mobile */
  :root {
    --space-3: 0.625rem;
    --space-4: 0.75rem;
    --space-6: 1rem;
  }

  /* Ensure touch targets are accessible */
  button,
  [role="button"],
  input,
  select,
  textarea {
    min-height: 44px;
    min-width: 44px;
  }

  .file-group-header,
  .result-summary {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  /* Header ultra-compact */
  header .px-6 {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  header .py-10 {
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }

  header h1 {
    font-size: var(--text-lg);
  }

  header .text-sm {
    font-size: var(--text-xs);
  }

  /* Main content ultra-compact */
  main.px-6 {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }

  main.mt-10 {
    margin-top: var(--space-6);
  }

  /* Section ultra-compact */
  section.p-6 {
    padding: var(--space-3);
    border-radius: var(--radius-lg);
  }

  /* Typography adjustments */
  h2 {
    font-size: var(--text-lg);
  }

  h3 {
    font-size: var(--text-base);
  }

  /* Button full-width on tiny screens */
  .grid.grid-cols-2 button {
    width: 100%;
  }

  /* File upload zone */
  #uploadZone {
    min-height: 120px;
    padding: var(--space-4);
  }

  /* Result cards compact */
  .result-summary {
    padding: var(--space-3);
  }

  .result-summary h3 {
    font-size: var(--text-sm);
  }

  /* Detail items compact */
  .detail-item {
    padding: var(--space-2) var(--space-3);
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  header .py-10 {
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
  }

  header h1 {
    font-size: var(--text-lg);
  }

  header p {
    display: none; /* Hide description in landscape to save space */
  }

  main.mt-10 {
    margin-top: var(--space-4);
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  /* Larger tap targets */
  button,
  a,
  [role="button"] {
    min-height: 48px;
    min-width: 48px;
  }

  /* Remove hover effects on touch devices */
  .file-item:hover,
  .result-summary:hover,
  .file-group:hover {
    transform: none;
    box-shadow: initial;
  }

  /* Add active state instead */
  .file-item:active,
  .result-summary:active,
  .file-group:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

/* Collapsible file list styles */
#filesSummary {
  user-select: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
}

#filesSummary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-secondary);
}

#expandIcon {
  display: inline-block;
  transition: var(--transition-base);
  color: var(--text-secondary);
  font-size: 1rem;
}

#filesSummary.expanded #expandIcon {
  transform: rotate(90deg);
  color: var(--accent-primary);
}

#uploadedFiles {
  max-height: 24rem; /* 384px */
  overflow-y: auto;
}

#uploadedFiles::-webkit-scrollbar {
  width: 6px;
}

#uploadedFiles::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

#uploadedFiles::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 3px;
  transition: var(--transition-fast);
}

#uploadedFiles::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}

.file-item[data-hidden="true"] {
  display: none;
}

#fileFilter {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
}

#fileFilter:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

#fileFilter::placeholder {
  color: var(--text-tertiary);
}

/* ========================================
   MULTI-LEMMA SEARCH MODAL
   ======================================== */

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: var(--space-4);
  animation: fadeIn 200ms ease-out;
}

/* Modal Container */
.modal-container {
  background: var(--bg-primary);
  border-radius: var(--radius-2xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 300ms ease-out;
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-primary);
}

.modal-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Modal Body */
.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 4px;
}

/* Input Sections */
.input-section {
  margin-bottom: var(--space-6);
}

.input-section:last-child {
  margin-bottom: 0;
}

.input-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  letter-spacing: 0.01em;
}

.input-wrapper {
  position: relative;
}

.lemma-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.lemma-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

.lemma-input::placeholder {
  color: var(--text-tertiary);
}

.input-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}

.input-hint svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Lemma Chips */
.lemma-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  min-height: 32px;
}

.lemma-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: chipIn 200ms ease-out;
}

@keyframes chipIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lemma-chip button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: var(--transition-fast);
}

.lemma-chip button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Search Mode Cards */
.search-modes {
  display: grid;
  gap: var(--space-3);
}

.mode-card {
  position: relative;
  display: block;
  padding: var(--space-4);
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.mode-card:hover {
  border-color: var(--border-secondary);
  background: var(--bg-secondary);
}

.mode-card:has(.mode-radio:checked) {
  border-color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 8%, var(--bg-primary));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

.mode-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mode-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.mode-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.mode-card:has(.mode-radio:checked) .mode-icon {
  color: var(--accent-primary);
}

.mode-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  background: var(--accent-primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
}

.mode-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-left: 32px;
}

/* Proximity Controls */
.proximity-controls {
  margin-top: var(--space-3);
  margin-left: 32px;
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border-primary);
  animation: slideDown 200ms ease-out;
}

.proximity-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.proximity-input {
  width: 80px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: center;
}

.proximity-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

/* Modal Footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}

/* Responsive Modal */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 0;
  }

  .modal-container {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .mode-description,
  .proximity-controls {
    margin-left: 0;
  }

  .btn-primary,
  .btn-secondary {
    flex: 1;
  }
}
