/* ── Top Toolbar ────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--toolbar-height);
  padding: 0 12px;
  background: var(--bg-toolbar);
  color: var(--text-toolbar);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-toolbar);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-left {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Logo */
.toolbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  flex-shrink: 0;
}

.toolbar-brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Hamburger toggle button */
.tab-hamburger {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-toolbar-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tab-hamburger:hover {
  background: var(--bg-toolbar-hover);
  color: var(--text-toolbar);
}

/* Tab bar */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: hidden;
  flex: 1;
  min-width: 0;
}

/* When tabs overflow – hide the tab bar, keep only hamburger */
.tabs-overflow .tab-bar {
  display: none;
}

/* Tab dropdown */
.tab-dropdown {
  position: fixed;
  top: var(--toolbar-height);
  z-index: 200;
  min-width: 200px;
  background: var(--bg-dropdown);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  animation: dropdown-in 150ms ease;
}

.tab-dropdown-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.tab-dropdown-item:hover {
  background: var(--accent-light);
}
.tab-dropdown-item.active {
  color: var(--tab-active-color);
  background: var(--tab-active-bg);
}

.tab-dropdown-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-dropdown-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  margin-left: 4px;
}

.tab-dropdown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  opacity: 0.7;
  color: var(--text-primary);
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.tab-dropdown-btn:hover {
  background: var(--tab-action-hover);
  opacity: 1;
}
.tab-dropdown-btn--danger:hover {
  background: var(--danger-light, rgba(231,76,60,0.15));
  color: var(--danger);
  opacity: 1;
}

.tab-dropdown-add {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-toolbar-muted);
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tab-dropdown-add:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.tab-dropdown hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-toolbar-muted);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}
.tab-item:hover {
  background: var(--bg-toolbar-hover);
  color: var(--text-toolbar);
}
.tab-item.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-color);
}

.tab-item .tab-rename,
.tab-item .tab-close {
  display: none;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.tab-item .tab-rename { margin-left: 4px; }
.tab-item .tab-close  { margin-left: 2px; }
.tab-item .tab-rename:hover,
.tab-item .tab-close:hover {
  background: var(--tab-action-hover);
  opacity: 1;
}
.edit-mode .tab-item .tab-rename,
.edit-mode .tab-item .tab-close {
  display: inline-flex;
}

.tab-add {
  display: inline-flex;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-toolbar-muted);
  margin-left: 2px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tab-add:hover {
  background: var(--bg-toolbar-hover);
  color: var(--text-toolbar);
}

/* Overflow ▼ button — shown when tabs are hidden due to bar width */
.tab-overflow-btn {
  display: inline-flex;
  width: 30px;
  height: 26px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-toolbar-muted);
  margin-left: 2px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tab-overflow-btn:hover {
  background: var(--bg-toolbar-hover);
  color: var(--text-toolbar);
}
.tab-overflow-btn.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-color);
}

/* Toolbar buttons */
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-toolbar-muted);
  font-size: 13px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.toolbar-btn:hover {
  background: var(--bg-toolbar-hover);
  color: var(--text-toolbar);
}
.toolbar-btn.active {
  background: var(--accent);
  color: var(--text-on-accent);
}

.toolbar-btn svg {
  flex-shrink: 0;
}

/* User dropdown */
.dropdown-menu {
  position: fixed;
  top: var(--toolbar-height);
  right: 12px;
  z-index: 200;
  min-width: 180px;
  background: var(--bg-dropdown);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  animation: dropdown-in 150ms ease;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}
.dropdown-item:hover {
  background: var(--accent-light);
}
.dropdown-item--danger {
  color: var(--danger);
}

.dropdown-menu hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}

/* Undo/Redo buttons — visible only in edit mode */
.toolbar-undo-redo {
  display: none !important;
}
.edit-mode .toolbar-undo-redo {
  display: flex !important;
}
.toolbar-undo-redo:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Archived tabs indicator */
.tab-archive-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-toolbar-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
.tab-archive-indicator:hover {
  background: var(--bg-toolbar-hover);
  color: var(--text-toolbar);
}
.tab-archive-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 10px;
  font-weight: 600;
}

/* Offline banner */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: var(--warning);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}
