/* Atlas MetaLog — Browse / Search Page */
.browse-layout {
  display: flex;
  min-height: 100vh;
}

/* Left sidebar */
.browse-sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}
.browse-sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.browse-sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.browse-sidebar-header .sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#project-select {
  width: 100%;
}

/* Index log list */
.log-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.log-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}
.log-item:hover { background: var(--bg-tertiary); }
.log-item.active { background: var(--accent-dim); border-left-color: var(--accent); }
.log-item-name { font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; justify-content: space-between; }
.log-refresh-btn {
  display: none;
  font-size: 16px;
  line-height: 1;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.log-item:hover .log-refresh-btn,
.log-item.active .log-refresh-btn { display: inline; }
.log-refresh-btn:hover { opacity: 1; }
.log-refresh-btn.spinning { animation: spin 0.8s linear infinite; opacity: 1; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.log-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Main content */
.browse-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Filter bar */
.filter-bar {
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-row-actions {
  gap: 6px;
}
.filter-bar input[type="search"] {
  flex: 1;
  min-width: 200px;
}
.filter-bar select {
  min-width: 100px;
}
.date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}
.date-range input[type="date"] {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
}
.date-sep {
  color: var(--text-secondary);
  font-size: 12px;
}
.filter-results {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* View toggle */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.view-toggle-btn {
  padding: 4px 10px;
  background: none;
  border: none;
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
}
.view-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Clip grid */
.clip-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.clip-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.clip-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.clip-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.clip-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
  overflow: hidden;
}
.clip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.clip-card-body {
  padding: 10px 12px;
}
.clip-card-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.clip-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.clip-card-meta span {
  white-space: nowrap;
}

/* Clip table view */
.clip-table-container { overflow-x: auto; }
.clip-table { width: 100%; }
.clip-table td { font-size: 12px; }
.clip-table tr { cursor: pointer; }

/* Detail panel (right side) */
.detail-panel {
  width: 360px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
  display: none;
}
.detail-panel.open { display: block; }

.detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.detail-header h3 { font-size: 14px; font-weight: 600; }
.detail-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.detail-close:hover { color: var(--text-primary); }

.detail-thumb {
  width: 100%;
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-body { padding: 16px 20px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-label { color: var(--text-secondary); font-weight: 500; }
.detail-value { color: var(--text-primary); text-align: right; max-width: 200px; word-break: break-all; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.pagination-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Empty / loading states */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 16px; }

/* Editable fields in detail panel */
.detail-edit-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.detail-edit-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  margin-top: 12px;
}
.detail-edit-label:first-child { margin-top: 0; }
.detail-edit-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  color: var(--text-primary);
  resize: vertical;
  margin-top: 4px;
}
.detail-edit-input:focus {
  outline: none;
  border-color: var(--accent);
}
.detail-save-status {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  min-height: 16px;
}
.detail-save-status.saved { color: #2ecc71; }
.detail-save-status.error { color: #e74c3c; }

/* Column toggle dropdown */
.column-toggle-wrap {
  position: relative;
}
.column-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
}
.column-dropdown.open { display: block; }
.column-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}
.column-check-item:hover { background: var(--bg-tertiary); }
.column-check-item input[type="checkbox"] { accent-color: var(--accent); }

/* Description/Notes table columns */
.col-desc, .col-notes {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Grid card description preview */
.clip-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

/* Selection mode */
.active-toggle {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.clip-card { position: relative; }
.clip-card-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}
.clip-card-select input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.clip-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
tr.selected td { background: var(--accent-dim); }
.col-select { width: 32px; text-align: center; }
.col-select input[type="checkbox"] { accent-color: var(--accent); }

/* Bulk action bar */
.bulk-action-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg, 12px);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 200;
}
.bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Bulk edit modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Tag badges ── */
.clip-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid transparent;
}
.clip-tag-badge-sm {
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 10px;
}
.tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
}
.tag-remove:hover { opacity: 1; }

/* Tag badges in grid cards */
.clip-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* Tag badges in table view */
.col-tags {
  max-width: 240px;
}
.col-tags .clip-tag-badge-sm { margin: 1px 2px; }

/* ── Tag filter dropdown ── */
.tag-filter-wrap {
  position: relative;
}
.tag-filter-btn {
  position: relative;
}
.tag-filter-btn.has-filter::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.tag-filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
}
.tag-filter-dropdown.open { display: block; }
.tag-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}
.tag-filter-item:hover { background: var(--bg-tertiary); }
.tag-filter-item input[type="checkbox"] { accent-color: var(--accent); }
.tag-filter-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tag-filter-clear {
  border-top: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
}
.tag-filter-clear:hover { color: var(--accent); background: var(--bg-tertiary); }
.tag-filter-empty {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Detail panel: Tags section ── */
.detail-tags-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.detail-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.detail-tag-input-wrap {
  position: relative;
  margin-top: 6px;
}
.detail-tag-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  color: var(--text-primary);
}
.detail-tag-input:focus {
  outline: none;
  border-color: var(--accent);
}
.tag-suggest-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  max-height: 160px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 110;
}
.tag-suggest-list.open { display: block; }
.tag-suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}
.tag-suggest-item:hover { background: var(--bg-tertiary); }
.tag-suggest-item.create-new {
  color: var(--accent);
  font-weight: 600;
  border-top: 1px solid var(--border);
}
.tag-suggest-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Bulk tag modal ── */
.bulk-tag-action-row {
  display: flex;
  gap: 16px;
}
.bulk-tag-action-row input[type="radio"] { accent-color: var(--accent); }
.bulk-tag-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  background: var(--bg-tertiary);
}
.bulk-tag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}
.bulk-tag-item:hover { background: var(--bg-primary); }
.bulk-tag-item input[type="checkbox"] { accent-color: var(--accent); }
.bulk-tag-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bulk-tag-create-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bulk-tag-create-row input[type="text"] { flex: 1; }
.tag-color-input {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  background: none;
  cursor: pointer;
}
.tag-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.tag-color-input::-webkit-color-swatch { border: none; border-radius: 3px; }

/* Accent button variant for Tag Selected */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-accent:hover { filter: brightness(1.1); }

/* AI button variant */
.btn-ai {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
  border: 1px solid #7c3aed;
}
.btn-ai:hover { filter: brightness(1.1); }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

/* ── AI description in detail panel ── */
.detail-ai-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.ai-description-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-left: 3px solid #8b5cf6;
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
  margin-top: 6px;
}
.ai-description-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
.ai-description-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
}
.ai-generate-btn {
  margin-top: 8px;
}

/* AI progress bar in confirm modal */
.ai-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}
.ai-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #6366f1);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}
.ai-progress-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
  text-align: center;
}
.modal-content-sm { width: 420px; }

/* AI mode toggle */
.ai-mode-toggle {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}
.ai-mode-option {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-mode-option:hover { border-color: var(--text-secondary); }
.ai-mode-active {
  border-color: var(--accent);
  background: rgba(74, 122, 245, 0.08);
}
.ai-mode-option input[type="radio"] { display: none; }
.ai-mode-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.ai-mode-desc {
  font-size: 11px;
  color: var(--text-secondary);
}
.ai-mode-badge {
  display: inline-block;
  background: #8b5cf6;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  vertical-align: middle;
  margin-left: 4px;
}

/* Table: AI description column */
.col-ai-desc {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 900px) {
  .browse-layout { flex-direction: column; }
  .browse-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .log-list { max-height: 200px; }
  .detail-panel {
    width: 100%;
    height: auto;
    position: static;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .clip-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Video proxy playback */
.detail-media-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.detail-media-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.detail-media-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Running timecode readout below video player */
.tc-readout {
  width: 100%;
  text-align: center;
  font-family: 'Menlo', 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #fff;
  background: #111;
  padding: 10px 0;
  flex-shrink: 0;
}

/* Play button overlay on detail thumbnail */
.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 2;
  padding: 0;
}
.play-overlay:hover {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

/* Small play badge on grid thumbnails */
.grid-play-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}
