/* Admin layout */
.admin-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.admin-header h1 {
  font-size: 1.25rem;
  color: var(--accent);
}

.admin-header .header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
}

.admin-header .uid-display {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--bg-base);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.admin-body {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  overflow: hidden;
}

/* Left sidebar: folder index */
.folder-index {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.folder-index .panel-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.folder-index .panel-header h2 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
}

.scan-input-group {
  display: flex;
  gap: 0.5rem;
}

.scan-input-group input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
}

.scan-input-group button {
  font-size: 0.8rem;
  padding: 0.5rem 0.85rem;
  white-space: nowrap;
}

.folder-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.folder-item {
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition);
}

.folder-item:hover {
  background: var(--bg-hover);
}

.folder-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.folder-item .folder-name {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-item .folder-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.folder-index .stats-bar {
  padding: 0.85rem 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-base);
}

.stats-bar .stat-value {
  color: var(--accent);
  font-weight: 600;
}

/* Main area: folder browser */
.folder-browser {
  overflow-y: auto;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(200, 148, 74, 0.03) 0%, transparent 50%),
    var(--bg-base);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs .separator {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.breadcrumbs .current {
  color: var(--text-primary);
  font-weight: 500;
}

.scan-status-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}

.scan-status-bar .status-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* New / removed file sections */
.diff-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.diff-section .diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.diff-section.new-files .diff-header {
  background: rgba(90, 138, 90, 0.15);
  color: var(--success);
  border-bottom: 1px solid rgba(90, 138, 90, 0.2);
}

.diff-section.removed-files .diff-header {
  background: rgba(196, 152, 50, 0.12);
  color: var(--warning);
  border-bottom: 1px solid rgba(196, 152, 50, 0.2);
}

/* File list */
.file-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.file-row:hover {
  background: var(--bg-elevated);
}

.file-row.selected {
  background: var(--accent-glow);
  outline: 1px solid var(--accent-muted);
}

.file-row.committed {
  opacity: 0.5;
}

.file-row .file-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.file-row .file-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.file-row .file-name {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-row .file-name.is-folder {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.file-row .file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.file-row .committed-badge {
  font-size: 0.7rem;
  color: var(--success);
  background: rgba(90, 138, 90, 0.15);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-weight: 600;
}

/* Dedup groups */
.dedup-group {
  border: 1px solid var(--warning-muted);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.dedup-group .group-header {
  background: rgba(196, 152, 50, 0.1);
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  color: var(--warning);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* Bulk actions bar */
.bulk-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 0.85rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bulk-bar .selection-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

/* Right panel: commit form */
.commit-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.commit-panel .panel-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.commit-panel .panel-header h2 {
  font-size: 1rem;
  color: var(--text-secondary);
}

.commit-panel .panel-body {
  padding: 1.2rem;
  flex: 1;
}

.commit-panel .form-group {
  margin-bottom: 1rem;
}

.commit-panel .form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.commit-panel .form-group select,
.commit-panel .form-group input {
  font-size: 0.9rem;
}

.commit-panel .selected-files-list {
  margin-bottom: 1.2rem;
}

.commit-panel .selected-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  margin: 0.15rem;
}

.commit-panel .commit-btn {
  width: 100%;
  margin-top: 0.5rem;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.95rem;
  max-width: 320px;
}

/* Settings panel */
.settings-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
}

.settings-panel h3 {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
}

.settings-row .label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.settings-row .value {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-primary);
  background: var(--bg-base);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1100px) {
  .admin-body {
    grid-template-columns: 240px 1fr;
  }
  .commit-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 340px;
    z-index: 100;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 250ms ease;
  }
  .commit-panel.open {
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  .admin-body {
    grid-template-columns: 1fr;
  }
  .folder-index {
    display: none;
  }
}
