/* ============================================
   NOTED - Sidebar Items & Components
   ============================================ */

/* Sidebar Items */
.sidebar-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 8px;
  position: relative;
  user-select: none;
  font-size: 13px;
  color: var(--text-primary);
  margin: 2px 0;
  text-decoration: none;
}

.sidebar-item:hover {
  background: var(--glass-strong);
}

.sidebar-item.active {
  background: var(--accent-muted) !important;
  color: var(--accent-hover) !important;
  font-weight: 500;
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}

.sidebar-item .item-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  border-radius: 4px;
}

.sidebar-item .item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item:hover .item-name {
  overflow: visible;
  position: relative;
  z-index: 10;
}

.sidebar-item .item-name[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 100%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  z-index: 20;
  pointer-events: none;
}

.sidebar-item .item-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--glass);
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item .item-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-item:hover .item-actions {
  display: flex;
}

.sidebar-item:hover .item-count {
  display: none;
}

.sidebar-item .item-actions button {
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 11px;
  transition: all var(--transition-fast);
}

.sidebar-item .item-actions button:hover {
  background: var(--glass-strong);
  color: var(--text-primary);
}

/* Drag States */
.sidebar-item.dragging {
  opacity: 0.5;
  background: var(--bg-active);
}

.sidebar-item.drag-over {
  border-top: 2px solid var(--accent);
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 180px;
  z-index: 1000;
  backdrop-filter: blur(20px);
  animation: contextMenuIn 120ms ease;
}

@keyframes contextMenuIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.context-menu-item:hover {
  background: var(--glass-strong);
}

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.danger:hover {
  background: var(--danger-muted);
}

.context-menu-item .menu-icon {
  width: 18px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

.context-menu-item .menu-shortcut {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.context-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* Empty State */
.sidebar-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.sidebar-empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* Add Button */
.add-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--glass);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.add-btn:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

/* Global Search */
.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

#global-search {
  width: 100%;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#global-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

#global-search::placeholder {
  color: var(--text-muted);
}

/* Icon Upload */
.icon-upload-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  border: 1px dashed var(--border-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  transition: all var(--transition-fast);
  overflow: hidden;
}

.icon-upload-btn:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.icon-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Sidebar Item Rename Input */
.sidebar-item .rename-input {
  flex: 1;
  background: var(--bg-overlay);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 2px 6px;
  outline: none;
  font-family: inherit;
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* Inline editing for sidebar new items */
.sidebar-item.new-item {
  animation: newItemIn 200ms ease;
}

@keyframes newItemIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  pointer-events: auto;
  animation: toastIn 250ms ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.toast.toast-success {
  border-left: 3px solid var(--success);
}

.toast.toast-error {
  border-left: 3px solid var(--danger);
}

.toast.toast-warning {
  border-left: 3px solid var(--warning);
}

.toast.toast-info {
  border-left: 3px solid var(--info);
}

.toast.toast-out {
  animation: toastOut 200ms ease forwards;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.toast-msg {
  flex: 1;
  min-width: 0;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
  color: var(--text-primary);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}
