/* =============================================================================
   lists.css: List panel, overlay, entries, modal
   ============================================================================= */

/* List Panel */
/*------------*/
#list-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 85%;
  max-width: var(--tf-panel-width);
  background: var(--tf-surface);
  border-left: 1px solid var(--tf-border);
  z-index: var(--tf-sidebar-z);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

#list-panel.open {
  transform: translateX(0);
}

#list-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--tf-border);
  flex-shrink: 0;
}

#list-panel-title {
  font-weight: 600;
  font-size: 1rem;
}

#list-panel-header button {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  margin: 0;
}

#list-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

#list-panel-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--tf-border);
}

.list-panel-local-note {
  font-size: 0.75rem;
  color: var(--tf-muted);
  margin: 0 0 0.5rem;
}

.list-view-bookmark-hint {
  font-size: 0.7rem;
  color: var(--tf-muted);
  margin: 0.25rem 0 0;
}

.list-panel-footer-btns {
  display: flex;
  gap: 0.5rem;
}

.list-panel-footer-btns button {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  margin: 0;
}

#delete-all-lists-btn {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

/* List Overlay */
/*--------------*/
#list-overlay {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--tf-overlay-z);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#list-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* List Panel Items */
/*------------------*/
.list-panel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--tf-border);
}

.list-panel-item-info {
  flex: 1;
  min-width: 0;
}

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

.list-panel-item-count {
  font-size: 0.75rem;
  color: var(--tf-muted);
}

.list-panel-item-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.list-panel-item-actions button {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  margin: 0;
}

.list-panel-empty {
  color: var(--tf-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem 0;
  margin: 0;
}

/* List View Header */
/*------------------*/
.list-view-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.list-view-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tf-color);
}

.list-rename-input {
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--tf-accent);
  border-radius: var(--tf-radius);
  background: transparent;
  color: var(--tf-color);
  min-width: 200px;
  margin: 0;
}

.list-rename-btn {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  margin: 0;
}

.list-view-description {
  display: block;
  width: 100%;
  background: var(--tf-input-bg);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  color: var(--tf-color);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
  resize: none;
  overflow: hidden;
}

.list-view-description:focus {
  outline: 2px solid var(--tf-accent);
  outline-offset: 0;
}

.list-view-description::placeholder {
  color: var(--tf-muted);
  font-style: italic;
}

.list-view-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.list-view-actions button {
  font-size: 0.875rem;
  padding: 0.3rem 0.75rem;
  margin: 0;
}

/* Saved State Badges */
/*--------------------*/
.list-saved-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--tf-border-radius-pill);
  font-weight: 500;
  white-space: nowrap;
}

.list-saved-badge--saved {
  background: #dcfce7;
  color: #15803d;
}

[data-theme="dark"] .list-saved-badge--saved {
  background: #166534;
  color: #4ade80;
}

.list-saved-badge--modified {
  background: #fef3c7;
  color: #92400e;
}

[data-theme="dark"] .list-saved-badge--modified {
  background: #78350f;
  color: #fcd34d;
}

.list-saved-badge--unsaved {
  background: var(--tf-border);
  color: var(--tf-muted);
}

/* List Entry Rows */
/*-----------------*/
.list-entry-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--tf-border);
}

.list-entry-row:last-child {
  border-bottom: none;
}

.list-entry-stale {
  opacity: 0.7;
}

.list-entry-num {
  font-size: 0.8rem;
  color: var(--tf-muted);
  min-width: 1.5rem;
  text-align: right;
  flex-shrink: 0;
}

.list-entry-info {
  flex: 1;
  min-width: 0;
}

.list-entry-title {
  font-size: 0.9rem;
  font-weight: 500;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-entry-title--stale {
  color: var(--tf-muted);
  font-style: italic;
}

.list-entry-byline {
  font-size: 0.75rem;
  color: var(--tf-muted);
}

.list-entry-stale-note {
  font-size: 0.7rem;
  font-family: monospace;
}

.list-drag-handle {
  color: var(--tf-muted);
  cursor: grab;
  font-size: 1rem;
  flex-shrink: 0;
  padding: 0 0.1rem;
  user-select: none;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.list-entry-row:hover .list-drag-handle {
  opacity: 0.8;
}

.list-entry-row.drag-dragging {
  opacity: 0.4;
}

.list-entry-row.drag-over-top {
  box-shadow: inset 0 2px 0 0 var(--tf-accent);
}

.list-entry-row.drag-over-bottom {
  box-shadow: inset 0 -2px 0 0 var(--tf-accent);
}

@keyframes list-entry-moved {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(245, 168, 72, 0.35); }
}

.list-entry-row.list-entry-moved {
  animation: list-entry-moved 0.35s ease-in-out 2;
}

.list-entry-controls {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.list-move-btn,
.list-remove-btn {
  background: none;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--tf-muted);
  line-height: 1;
  margin: 0;
  box-shadow: none;
  width: auto;
  transition: color 0.15s, border-color 0.15s;
}

.list-move-btn:hover:not(:disabled) {
  color: var(--tf-accent);
  border-color: var(--tf-accent);
}

.list-move-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.list-remove-btn:hover {
  color: var(--tf-danger);
  border-color: var(--tf-danger);
}

/* Card inline buttons (+ List, Copy link) */
/*-----------------------------------------*/
.add-to-list-btn,
.copy-entry-link-btn {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  margin: 0 0 0 0.4rem;
  vertical-align: middle;
  line-height: 1;
}

/* Add to List Modal */
/*-------------------*/
#add-to-list-modal {
  position: fixed;
  inset: 0;
  z-index: var(--tf-modal-z);
  display: flex;
  align-items: center;
  justify-content: center;
}

#add-to-list-modal[hidden] {
  display: none;
}

.list-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.list-modal-inner {
  position: relative;
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius);
  padding: 1.25rem;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.list-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.list-modal-header button {
  font-size: 0.85rem;
  padding: 0.2rem 0.5rem;
  margin: 0;
  flex-shrink: 0;
}

.list-modal-search {
  width: 100%;
  margin: 0 0 0.25rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
}

.list-modal-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tf-muted);
  margin: 0.75rem 0 0.4rem;
}

.list-modal-max-note {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.65;
}

.list-modal-recent {
  display: flex;
  flex-direction: column;
}

.list-modal-item-row + .list-modal-item-row {
  border-top: 1px solid var(--tf-border);
}


@keyframes list-row-flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(74, 222, 128, 0.35); }
}

@keyframes list-row-flash-red {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(248, 113, 113, 0.35); }
}

.list-modal-item-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.75rem 0.5rem;
  border-radius: var(--tf-radius);
}

.list-modal-item-name {
  flex: 1;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-modal-item-row .add-to-existing-list-btn {
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
  font-size: 0.875rem;
  padding: 0.4rem 0;
  margin: 0;
}

.list-modal-goto-btn {
  flex-shrink: 0;
  font-size: 0.875rem;
  padding: 0.4rem 0.6rem;
  margin: 0;
}

.list-item-count {
  font-size: 0.8em;
  color: var(--tf-muted);
}

.list-name-error {
  font-size: 0.8rem;
  color: #ef4444;
  margin: 0.25rem 0 0;
}

[data-theme="dark"] .list-name-error {
  color: #f87171;
}

.list-modal-no-recent {
  font-size: 0.875rem;
  color: var(--tf-muted);
  margin: 0;
}

.list-modal-create {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.4rem;
}

.list-modal-create input {
  flex: 1;
  margin: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
}

.list-modal-create button {
  flex-shrink: 0;
  font-size: 0.875rem;
  padding: 0.35rem 0.75rem;
  margin: 0;
  white-space: nowrap;
}
