/* HeadFinder Modal Styles */

.head-finder-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.head-finder-overlay.visible {
  display: flex;
}

.head-finder-modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
.hf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #E5E5E5;
}

.hf-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.hf-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}

.hf-close:hover {
  color: #333;
}

/* Search */
.hf-search {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid #E5E5E5;
  background: #F9FAFB;
}

.hf-search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #DDD;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
}

.hf-search-input:focus {
  border-color: #14B8A6;
}

.hf-mode-select {
  padding: 10px 14px;
  border: 1px solid #DDD;
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.hf-search-btn {
  padding: 10px 20px;
  background: #14B8A6;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.hf-search-btn:hover {
  background: #0D9488;
}

/* Content area */
.hf-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 300px;
}

/* Results list */
.hf-results {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.hf-loading,
.hf-error,
.hf-empty {
  padding: 40px;
  text-align: center;
  color: #888;
  font-style: italic;
}

.hf-error {
  color: #DC2626;
}

/* Result item */
.hf-item {
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  border: 1px solid #E5E5E5;
  background: white;
  transition: all 0.15s;
}

.hf-item:hover {
  border-color: #14B8A6;
  background: #F0FDFA;
}

.hf-item.selected {
  border-color: #14B8A6;
  background: #CCFBF1;
}

.hf-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.hf-hex-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: #14B8A6;
  background: #F0FDFA;
  padding: 2px 6px;
  border-radius: 4px;
}

.hf-name {
  font-weight: 500;
  color: #333;
}

.hf-commit-msg {
  font-size: 0.85rem;
  color: #666;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hf-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
}

.hf-elo {
  color: #888;
}

.hf-activity {
  color: #14B8A6;
  font-weight: 500;
}

.hf-ancestry-btn {
  padding: 4px 10px;
  background: #F3F4F6;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
}

.hf-ancestry-btn:hover {
  background: #E5E7EB;
}

/* Select button on each item */
.hf-select-btn {
  margin-left: auto;
  padding: 6px 14px;
  background: #14B8A6;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.hf-select-btn:hover {
  background: #0D9488;
}

/* Ancestry Panel */
.hf-ancestry-panel {
  width: 280px;
  border-left: 1px solid #E5E5E5;
  background: #F9FAFB;
  display: flex;
  flex-direction: column;
}

.hf-ancestry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #E5E5E5;
}

.hf-ancestry-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
  color: #333;
}

.hf-ancestry-id {
  font-family: 'JetBrains Mono', monospace;
  color: #14B8A6;
}

.hf-ancestry-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #999;
  cursor: pointer;
}

.hf-ancestry-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.hf-ancestry-list li {
  padding: 8px 10px;
  background: white;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  border: 1px solid #E5E5E5;
}

.hf-ancestry-list code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #0369A1;
  background: #E0F2FE;
  padding: 2px 4px;
  border-radius: 3px;
  margin-right: 6px;
}

.hf-ancestry-msg {
  color: #333;
  display: block;
  margin-top: 4px;
}

.hf-ancestry-time {
  display: block;
  margin-top: 4px;
  color: #888;
  font-size: 0.7rem;
}

/* Footer */
.hf-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #E5E5E5;
  background: #F9FAFB;
}

.hf-selection-count {
  font-size: 0.9rem;
  color: #666;
}

.hf-confirm-btn {
  padding: 10px 24px;
  background: #14B8A6;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.hf-confirm-btn:disabled {
  background: #D1D5DB;
  cursor: not-allowed;
}

.hf-confirm-btn:not(:disabled):hover {
  background: #0D9488;
}

/* Mobile */
@media (max-width: 600px) {
  .head-finder-modal {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .hf-search {
    flex-wrap: wrap;
  }

  .hf-search-input {
    width: 100%;
  }

  .hf-content {
    flex-direction: column;
  }

  .hf-ancestry-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid #E5E5E5;
    max-height: 200px;
  }

  .hf-results {
    padding-bottom: 60px;  /* Extra space for browser chrome */
  }
}
